def test_csv_emitter(self): ce = CSVEmitter(self.output, ('x', 'y', 'z')) data = ce.attach([{'x': 1, 'y': 2, 'z': 3}, {'x': 5, 'y': 5, 'z': 5}]) for _ in data: pass self.assertEquals(self.output.getvalue(), 'x,y,z\r\n1,2,3\r\n5,5,5\r\n')
def test_csv_emitter(self): try: import cStringIO # if Python 2.x then use old cStringIO io = cStringIO.StringIO() except: io = StringIO() # if Python 3.x then use StringIO with closing(io) as output: ce = CSVEmitter(output, ('x','y','z')) list(ce.attach([{'x':1, 'y':2, 'z':3}, {'x':5, 'y':5, 'z':5}])) self.assertEqual(output.getvalue(), 'x,y,z\r\n1,2,3\r\n5,5,5\r\n')
def test_csv_emitter(self): ce = CSVEmitter(self.output, ('x','y','z')) data = ce.attach([{'x':1,'y':2,'z':3}, {'x':5, 'y':5, 'z':5}]) for _ in data: pass self.assertEquals(self.output.getvalue(), 'x,y,z\r\n1,2,3\r\n5,5,5\r\n')