コード例 #1
0
def test_itercsv_emits_data_lines():
    """itercsv should yield individual lines of CSV, with headers"""
    expected = [
        b'Hello,World\r\n',
        b'1,2\r\n',
        b'3,4\r\n'
    ]
    assert list(itercsv(['Hello', 'World'], [[1, 2], [3, 4]])) == expected
コード例 #2
0
def test_itercsv_always_emits_headers():
    """itercsv should always emit headers, even where there is no data"""
    assert list(itercsv(['Hello', 'World'], [])) == [b'Hello,World\r\n']
コード例 #3
0
def test_itercsv_emits_data_lines():
    """itercsv should yield individual lines of CSV, with headers"""
    expected = [b"Hello,World\r\n", b"1,2\r\n", b"3,4\r\n"]
    assert list(itercsv(["Hello", "World"], [[1, 2], [3, 4]])) == expected
コード例 #4
0
def test_itercsv_always_emits_headers():
    """itercsv should always emit headers, even where there is no data"""
    assert list(itercsv(["Hello", "World"], [])) == [b"Hello,World\r\n"]