[Python-checkins] python/nondist/sandbox/csv/test test_csv.py,1.6,1.7

montanaro@users.sourceforge.net montanaro@users.sourceforge.net
Sun, 02 Feb 2003 17:42:24 -0800


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

Modified Files:
	test_csv.py 
Log Message:
Should be generating array expected values from the array, not the data fed
into the array.  Added a test of writing single-precision floats (which
won't work if you generate the expected values from the inputs to the array
constructor).


Index: test_csv.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/csv/test/test_csv.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test_csv.py	3 Feb 2003 01:33:00 -0000	1.6
--- test_csv.py	3 Feb 2003 01:42:22 -0000	1.7
***************
*** 133,137 ****
          writer = csv.writer(fileobj, dialect="excel")
          writer.write(a)
!         expected = ",".join([str(i) for i in contents])+"\r\n"
          self.assertEqual(fileobj.getvalue(), expected)
  
--- 133,137 ----
          writer = csv.writer(fileobj, dialect="excel")
          writer.write(a)
!         expected = ",".join([str(i) for i in a])+"\r\n"
          self.assertEqual(fileobj.getvalue(), expected)
  
***************
*** 143,147 ****
          writer = csv.writer(fileobj, dialect="excel")
          writer.write(a)
!         expected = ",".join([str(i) for i in contents])+"\r\n"
          self.assertEqual(fileobj.getvalue(), expected)
  
--- 143,157 ----
          writer = csv.writer(fileobj, dialect="excel")
          writer.write(a)
!         expected = ",".join([str(i) for i in a])+"\r\n"
!         self.assertEqual(fileobj.getvalue(), expected)
! 
!     def test_float_write(self):
!         import array
!         contents = [(20-i)*0.1 for i in range(20)]
!         a = array.array('f', contents)
!         fileobj = StringIO()
!         writer = csv.writer(fileobj, dialect="excel")
!         writer.write(a)
!         expected = ",".join([str(i) for i in a])+"\r\n"
          self.assertEqual(fileobj.getvalue(), expected)
  
***************
*** 152,156 ****
          writer = csv.writer(fileobj, dialect="excel")
          writer.write(a)
!         expected = ",".join(string.letters)+"\r\n"
          self.assertEqual(fileobj.getvalue(), expected)
  
--- 162,166 ----
          writer = csv.writer(fileobj, dialect="excel")
          writer.write(a)
!         expected = ",".join(a)+"\r\n"
          self.assertEqual(fileobj.getvalue(), expected)