Пример #1
0
 def test_should_format_single_string_row(self):
     assert format_csv_rows([['abc', 'def']]) == 'abc,def'
Пример #2
0
 def test_should_format_multiple_string_rows(self):
     assert (
         format_csv_rows([['abc', 'def'], ['123', '456']]).splitlines()
         == ['abc,def', '123,456']
     )
Пример #3
0
 def test_should_format_single_int_cell(self):
     assert format_csv_rows([[123]]) == '123'
Пример #4
0
 def test_should_format_single_byte_cell(self):
     assert format_csv_rows([[UNICODE_STR_1.encode('utf-8')]]) == UNICODE_STR_1
Пример #5
0
 def test_should_format_single_unicode_cell(self):
     assert format_csv_rows([[UNICODE_STR_1]]) == UNICODE_STR_1
Пример #6
0
 def test_should_format_empty_rows(self):
     assert format_csv_rows([]) == ''
Пример #7
0
def to_csv(rows, delimiter):
    return (format_csv_rows(rows, delimiter).replace('\r\n', '\n') + '\n').encode('utf-8')