示例#1
0
 def test_book_writer(self):
     b = CSVWriter(self.test_file)
     w = b.create_sheet(None)
     for row in self.data:
         w.write_row(row)
     w.close()
     b.close()
     with open(self.test_file, 'r') as f:
         content = f.read().replace('\r', '')
         assert content.strip('\n') == self.result
示例#2
0
 def test_book_writer_to_memroy(self):
     io = get_io(self.file_type)
     b = CSVWriter(io, single_sheet_in_book=True)
     w = b.create_sheet(None)
     for row in self.data:
         w.write_row(row)
     w.close()
     b.close()
     content = io.getvalue().replace('\r', '')
     assert content.strip('\n') == self.result
示例#3
0
 def test_multiple_sheet(self):
     """Write csv book into multiple file"""
     b = CSVWriter("csv_multiple.csv")
     for key, value in self.sheets.items():
         w = b.create_sheet(key)
         w.write_array(value)
         w.close()
     b.close()
     index = 0
     for key, value in self.sheets.items():
         file_name = self.test_file_formatter % (key, index)
         with open(file_name, 'r') as f:
             content = f.read().replace('\r', '')
             assert content.strip('\n') == self.result_dict[key]
         index = index + 1