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(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_file_like_object(self): table = Table(self.rows, self.columns) with open('.test.csv', 'w') as f: table.to_csv(f) 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')