def test_to_csv_to_stdout(self): table = Table(self.rows, self.columns) output = StringIO() table.to_csv(output) contents1 = output.getvalue() with open('examples/test.csv') as f: contents2 = f.read() self.assertEqual(contents1, contents2)
def test_to_csv_to_stdout(self): table = Table(self.rows, self.column_names, self.column_types) output = StringIO() table.to_csv(output) contents1 = output.getvalue() with open('examples/test.csv') as f: contents2 = f.read() self.assertEqual(contents1, contents2)
def test_to_csv(self): table = Table(self.rows, self.column_names, self.column_types) table.to_csv('.test.csv') with open('.test.csv') as f: contents1 = f.read() with open('examples/test.csv') as f: contents2 = f.read() self.assertEqual(contents1, contents2) os.remove('.test.csv')
def test_to_csv(self): table = Table(self.rows, self.columns) table.to_csv('.test.csv') with open('.test.csv') as f: contents1 = f.read() with open('examples/test.csv') as f: contents2 = f.read() self.assertEqual(contents1, contents2) os.remove('.test.csv')
def test_to_csv_make_dir(self): table = Table(self.rows, self.column_names, self.column_types) table.to_csv('newdir/test.csv') with open('newdir/test.csv') as f: contents1 = f.read() with open('examples/test.csv') as f: contents2 = f.read() self.assertEqual(contents1, contents2) os.remove('newdir/test.csv') os.rmdir('newdir/')
def test_to_csv_file_like_object(self): table = Table(self.rows, self.column_names, self.column_types) with open('.test.csv', 'w') as f: table.to_csv(f) # Should leave the file open self.assertFalse(f.closed) with open('.test.csv') as f: contents1 = f.read() with open('examples/test.csv') as f: contents2 = f.read() self.assertEqual(contents1, contents2) os.remove('.test.csv')
def test_to_csv_file_like_object(self): table = Table(self.rows, self.columns) with open('.test.csv', 'w') as f: table.to_csv(f) # Should leave the file open self.assertFalse(f.closed) with open('.test.csv') as f: contents1 = f.read() with open('examples/test.csv') as f: contents2 = f.read() self.assertEqual(contents1, contents2) os.remove('.test.csv')