def test_be_able_to_write_csv_file(self): data = [['name', 'age', 'color'], ['John hopskin', 15, 'Blue sky']] output_path = 'test/output_file/test_write_csv.csv' obj = Writer() obj.to_csv(data, output_path) with open(output_path, 'r') as reader: expect = reader.read() self.assertEqual('name,age,color\nJohn hopskin,15,Blue sky\n', expect)
def test_be_able_to_write_csv_when_there_is_comma_between_data(self): data = [['name', 'age', 'color'], ['John, hopskin', 15, 'Blue, sky']] output_path = 'test/output_file/test_write_csv_comma.csv' obj = Writer() obj.to_csv(data, output_path) with open(output_path, 'r') as reader: expect = reader.read() self.assertEqual('name,age,color\n"John, hopskin",15,"Blue, sky"\n', expect)