def test_stringsource(): tbl1 = (('foo', 'bar'), ('a', '1'), ('b', '2'), ('c', '2')) # test writing to a string buffer ss = StringSource() etl.tocsv(tbl1, ss) expect = "foo,bar\r\na,1\r\nb,2\r\nc,2\r\n" if not PY2: expect = expect.encode('ascii') actual = ss.getvalue() eq_(expect, actual) # test reading from a string buffer tbl2 = etl.fromcsv(StringSource(actual)) ieq(tbl1, tbl2) ieq(tbl1, tbl2) # test appending etl.appendcsv(tbl1, ss) actual = ss.getvalue() expect = "foo,bar\r\na,1\r\nb,2\r\nc,2\r\na,1\r\nb,2\r\nc,2\r\n" if not PY2: expect = expect.encode('ascii') eq_(expect, actual)
def test_stringsource(): table1 = (('foo', 'bar'), ('a', '1'), ('b', '2'), ('c', '2')) # test writing to a string buffer ss = StringSource() etl.tocsv(table1, ss) expect = "foo,bar\r\na,1\r\nb,2\r\nc,2\r\n" if not PY2: expect = expect.encode('ascii') actual = ss.getvalue() eq_(expect, actual) # test reading from a string buffer table2 = etl.fromcsv(StringSource(actual)) ieq(table1, table2) ieq(table1, table2) # test appending etl.appendcsv(table1, ss) actual = ss.getvalue() expect = "foo,bar\r\na,1\r\nb,2\r\nc,2\r\na,1\r\nb,2\r\nc,2\r\n" if not PY2: expect = expect.encode('ascii') eq_(expect, actual)
def test_stringsource(): table1 = (('foo', 'bar'), ('a', '1'), ('b', '2'), ('c', '2')) # test writing to a string buffer ss = StringSource() tocsv(table1, ss) expect = "foo,bar\r\na,1\r\nb,2\r\nc,2\r\n" actual = ss.getvalue() eq_(expect, actual) # test reading from a string buffer table2 = fromcsv(StringSource(actual)) ieq(table1, table2) ieq(table1, table2) # test appending appendcsv(table1, ss) actual = ss.getvalue() expect = "foo,bar\r\na,1\r\nb,2\r\nc,2\r\na,1\r\nb,2\r\nc,2\r\n" eq_(expect, actual)
def test_stringsource(): table1 = (("foo", "bar"), ("a", "1"), ("b", "2"), ("c", "2")) # test writing to a string buffer ss = StringSource() tocsv(table1, ss) expect = "foo,bar\r\na,1\r\nb,2\r\nc,2\r\n" actual = ss.getvalue() eq_(expect, actual) # test reading from a string buffer table2 = fromcsv(StringSource(actual)) ieq(table1, table2) ieq(table1, table2) # test appending appendcsv(table1, ss) actual = ss.getvalue() expect = "foo,bar\r\na,1\r\nb,2\r\nc,2\r\na,1\r\nb,2\r\nc,2\r\n" eq_(expect, actual)