[Python-checkins] python/nondist/sandbox/csv/test test_csv.py,1.31,1.32

montanaro@users.sourceforge.net montanaro@users.sourceforge.net
Tue, 11 Feb 2003 18:44:45 -0800


Update of /cvsroot/python/python/nondist/sandbox/csv/test
In directory sc8-pr-cvs1:/tmp/cvs-serv8545

Modified Files:
	test_csv.py 
Log Message:
add test case for DictReader encountering empty lists from csv.reader.
fix test_write to avoid StringIO's list append behavior.


Index: test_csv.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/csv/test/test_csv.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** test_csv.py	11 Feb 2003 14:51:41 -0000	1.31
--- test_csv.py	12 Feb 2003 02:44:42 -0000	1.32
***************
*** 408,411 ****
--- 408,420 ----
                                           "6": 'DEFAULT'})
  
+     def test_read_with_blanks(self):
+         reader = csv.DictReader(["1,2,abc,4,5,6\r\n","\r\n",
+                                  "1,2,abc,4,5,6\r\n"],
+                                 fieldnames="1 2 3 4 5 6".split())
+         self.assertEqual(reader.next(), {"1": '1', "2": '2', "3": 'abc',
+                                          "4": '4', "5": '5', "6": '6'})
+         self.assertEqual(reader.next(), {"1": '1', "2": '2', "3": 'abc',
+                                          "4": '4', "5": '5', "6": '6'})
+ 
  class TestArrayWrites(unittest.TestCase):
      def test_int_write(self):
***************
*** 503,507 ****
              lastrc = sys.gettotalrefcount()
              rows = [[1,2,3]]*5
!             s = StringIO()
              for i in xrange(20):
                  gc.collect()
--- 512,519 ----
              lastrc = sys.gettotalrefcount()
              rows = [[1,2,3]]*5
!             class NUL:
!                 def write(s, *args):
!                     pass
!             s = NUL()
              for i in xrange(20):
                  gc.collect()