[Python-checkins] python/nondist/sandbox/csv/test test_csv.py,1.2,1.3

montanaro@users.sourceforge.net montanaro@users.sourceforge.net
Fri, 31 Jan 2003 13:30:50 -0800


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

Modified Files:
	test_csv.py 
Log Message:
add a couple dict tests


Index: test_csv.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/csv/test/test_csv.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_csv.py	31 Jan 2003 04:53:49 -0000	1.2
--- test_csv.py	31 Jan 2003 21:30:43 -0000	1.3
***************
*** 112,115 ****
--- 112,128 ----
          self.writerAssertEqual([[1, 2, 'a\nbc', 3, 4]], '1,2,"a\nbc",3,4\n')
  
+ class TestDictFields(unittest.TestCase):
+     def test_simple_dict(self):
+         fileobj = StringIO()
+         writer = csv.writer(fileobj, dialect="excel",
+                             fieldnames = ["f1", "f2", "f3"])
+         writer.write({"f1": 10, "f3": "abc"})
+         self.assertEqual(fileobj.getvalue(), "10,,abc\n")
+ 
+     def test_no_fields(self):
+         fileobj = StringIO()
+         writer = csv.writer(fileobj, dialect="excel")
+         self.assertRaises(csv.CSVError, writer.write, {"f1": 10, "f3": "abc"})
+ 
  def _testclasses():
      mod = sys.modules[__name__]