[Python-checkins] python/dist/src/Lib/test test_csv.py,1.25,1.26

andrewmcnamara at users.sourceforge.net andrewmcnamara at users.sourceforge.net
Wed Jan 12 12:17:48 CET 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27851/Lib/test

Modified Files:
	test_csv.py 
Log Message:
Add counting of source iterator lines to the reader object - handy for
user error messages (otherwise difficult to do without instrumenting
the source).


Index: test_csv.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- test_csv.py	12 Jan 2005 09:45:17 -0000	1.25
+++ test_csv.py	12 Jan 2005 11:17:15 -0000	1.26
@@ -242,7 +242,7 @@
         self._read_test(['1,",3,",5'], [['1', '"', '3', '"', '5']],
                         quoting=csv.QUOTE_NONE, escapechar='\\')
         # will this fail where locale uses comma for decimals?
-        self._read_test([',3,"5",7.3'], [['', 3, '5', 7.3]],
+        self._read_test([',3,"5",7.3, 9'], [['', 3, '5', 7.3, 9]],
                         quoting=csv.QUOTE_NONNUMERIC)
         self.assertRaises(ValueError, self._read_test, 
                           ['abc,3'], [[]],
@@ -267,6 +267,18 @@
         finally:
             csv.field_size_limit(limit)
 
+    def test_read_linenum(self):
+        r = csv.reader(['line,1', 'line,2', 'line,3'])
+        self.assertEqual(r.line_num, 0)
+        r.next()
+        self.assertEqual(r.line_num, 1)
+        r.next()
+        self.assertEqual(r.line_num, 2)
+        r.next()
+        self.assertEqual(r.line_num, 3)
+        self.assertRaises(StopIteration, r.next)
+        self.assertEqual(r.line_num, 3)
+
 class TestDialectRegistry(unittest.TestCase):
     def test_registry_badargs(self):
         self.assertRaises(TypeError, csv.list_dialects, None)



More information about the Python-checkins mailing list