[Python-checkins] python/dist/src/Lib/test test_csv.py,1.22,1.23
andrewmcnamara at users.sourceforge.net
andrewmcnamara at users.sourceforge.net
Wed Jan 12 08:44:45 CET 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19456/Lib/test
Modified Files:
test_csv.py
Log Message:
When using QUOTE_NONNUMERIC, we now test for "numericness" with
PyNumber_Check, rather than trying to convert to a float. Reimplemented
writer - now raises exceptions when it sees a quotechar but neither
doublequote or escapechar are set. Doublequote results are now more
consistent (eg, single quote should generate """", rather than "",
which is ambiguous).
Index: test_csv.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- test_csv.py 12 Jan 2005 03:45:09 -0000 1.22
+++ test_csv.py 12 Jan 2005 07:44:42 -0000 1.23
@@ -152,25 +152,35 @@
(bigstring, bigstring))
def test_write_quoting(self):
- self._write_test(['a','1','p,q'], 'a,1,"p,q"')
+ self._write_test(['a',1,'p,q'], 'a,1,"p,q"')
self.assertRaises(csv.Error,
self._write_test,
- ['a','1','p,q'], 'a,1,"p,q"',
+ ['a',1,'p,q'], 'a,1,p,q',
quoting = csv.QUOTE_NONE)
- self._write_test(['a','1','p,q'], 'a,1,"p,q"',
+ self._write_test(['a',1,'p,q'], 'a,1,"p,q"',
quoting = csv.QUOTE_MINIMAL)
- self._write_test(['a','1','p,q'], '"a",1,"p,q"',
+ self._write_test(['a',1,'p,q'], '"a",1,"p,q"',
quoting = csv.QUOTE_NONNUMERIC)
- self._write_test(['a','1','p,q'], '"a","1","p,q"',
+ self._write_test(['a',1,'p,q'], '"a","1","p,q"',
quoting = csv.QUOTE_ALL)
def test_write_escape(self):
- self._write_test(['a','1','p,q'], 'a,1,"p,q"',
+ self._write_test(['a',1,'p,q'], 'a,1,"p,q"',
escapechar='\\')
-# FAILED - needs to be fixed [am]:
-# self._write_test(['a','1','p,"q"'], 'a,1,"p,\\"q\\"',
-# escapechar='\\', doublequote = 0)
- self._write_test(['a','1','p,q'], 'a,1,p\\,q',
+ self.assertRaises(csv.Error,
+ self._write_test,
+ ['a',1,'p,"q"'], 'a,1,"p,\\"q\\""',
+ escapechar=None, doublequote=False)
+ self._write_test(['a',1,'p,"q"'], 'a,1,"p,\\"q\\""',
+ escapechar='\\', doublequote = False)
+ self._write_test(['"'], '""""',
+ escapechar='\\', quoting = csv.QUOTE_MINIMAL)
+ self._write_test(['"'], '\\"',
+ escapechar='\\', quoting = csv.QUOTE_MINIMAL,
+ doublequote = False)
+ self._write_test(['"'], '\\"',
+ escapechar='\\', quoting = csv.QUOTE_NONE)
+ self._write_test(['a',1,'p,q'], 'a,1,p\\,q',
escapechar='\\', quoting = csv.QUOTE_NONE)
def test_writerows(self):
More information about the Python-checkins
mailing list