[Python-checkins] python/nondist/sandbox/csv/test test_csv.py,1.12,1.13

montanaro@users.sourceforge.net montanaro@users.sourceforge.net
Mon, 03 Feb 2003 09:37:34 -0800


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

Modified Files:
	test_csv.py 
Log Message:
a few more productive tests dealing with quoting and escaping.


Index: test_csv.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/csv/test/test_csv.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** test_csv.py	3 Feb 2003 17:28:55 -0000	1.12
--- test_csv.py	3 Feb 2003 17:37:29 -0000	1.13
***************
*** 112,115 ****
--- 112,141 ----
          self.writerAssertEqual([[1, 2, 'a\nbc', 3, 4]], '1,2,"a\nbc",3,4\r\n')
  
+ class EscapedExcel(csv.excel):
+     quoting = csv.QUOTE_NONE
+     escapechar = '\\'
+ 
+ class TestEscapedExcel(TestCsvBase):
+     dialect = EscapedExcel()
+ 
+     def test_escape_fieldsep(self):
+         self.writerAssertEqual([['abc,def']], 'abc\\,def\r\n')
+ 
+     def test_read_escape_fieldsep(self):
+         self.readerAssertEqual('abc\\,def\r\n', [['abc,def']])
+ 
+ class QuotedEscapedExcel(csv.excel):
+     quoting = csv.QUOTE_NONNUMERIC
+     escapechar = '\\'
+ 
+ class TestQuotedEscapedExcel(TestCsvBase):
+     dialect = QuotedEscapedExcel()
+ 
+     def test_write_escape_fieldsep(self):
+         self.writerAssertEqual([['abc,def']], '"abc,def"\r\n')
+ 
+     def test_read_escape_fieldsep(self):
+         self.readerAssertEqual('"abc\\,def"\r\n', [['abc,def']])
+ 
  class TestDictFields(unittest.TestCase):
      def test_simple_dict(self):