Exemplo n.º 1
0
def test_sort_with_key(simple_int_csv):
    processor = CSVProcessor(simple_int_csv, types=(int, int, int))

    processor.sort(key=1)

    assert processor.csv == [[4, 5, 6], [0, 5, 7], [1, 8, 3]]
    assert processor.header == ['col1', 'col2', 'col3']
def test_sort_with_key_multi(multiple_types_csv):
    processor = CSVProcessor(multiple_types_csv, types=[int, str, float])
    processor.sort(key=1)

    assert processor.csv == [[2, "'str1'", 7.9], [1, "'str2'", 6.2],
                             [0, "'str3'", 13.1]]
    assert processor.header == ['col1', 'col2', 'col3']
Exemplo n.º 3
0
def test_sort_without_key_multiple_types(multiple_types_csv):
    processor = CSVProcessor(multiple_types_csv, types=(int, str, float))

    processor.sort()

    assert processor.csv == [[0, "'str3'", 13.1], [1, "'str2'", 6.2], [2, "'str1'", 7.9]]
    assert processor.header == ['col1', 'col2', 'col3']
def test_sort_without_key(simple_int_csv):
    processor = CSVProcessor(simple_int_csv, types=[int, int, int])
    processor.sort()

    assert processor.csv == [[0, 5, 7], [1, 8, 3], [4, 5, 6]]
    assert processor.header == ['col1', 'col2', 'col3']