Ejemplo n.º 1
0
def test_into_double_string():
    with filetext('alice,1\nbob,2', extension='.csv') as source:
        assert into(list, source) == [('alice', 1), ('bob', 2)]

        with tmpfile('.csv') as target:
            csv = into(target, source)
            assert isinstance(csv, CSV)
            with open(target) as f:
                assert 'alice' in f.read()
Ejemplo n.º 2
0
def test_into_double_string():
    with filetext('alice,1\nbob,2', extension='.csv') as source:
        assert into(list, source) == [('alice', 1), ('bob', 2)]

        with tmpfile('.csv') as target:
            csv = into(target, source)
            assert isinstance(csv, CSV)
            with open(target) as f:
                assert 'alice' in f.read()
Ejemplo n.º 3
0
def test_into_append():
    L = []
    result = into(L, (1, 2, 3))
    assert result == [1, 2, 3]
    assert result is L
Ejemplo n.º 4
0
def test_into_convert():
    assert into(list, (1, 2, 3)) == [1, 2, 3]
Ejemplo n.º 5
0
def test_into_string_on_right():
    with filetext('alice,1\nbob,2', extension='.csv') as source:
        assert into([], source) == [('alice', 1), ('bob', 2)]
Ejemplo n.º 6
0
def test_into_curry():
    assert callable(into(list))
    data = (1, 2, 3)
    assert into(list)(data) == into(list, data)
Ejemplo n.º 7
0
def test_into_append():
    L = []
    result = into(L, (1, 2, 3))
    assert result == [1, 2, 3]
    assert result is L
Ejemplo n.º 8
0
def test_into_convert():
    assert into(list, (1, 2, 3)) == [1, 2, 3]
Ejemplo n.º 9
0
def test_into_curry():
    assert callable(into(list))
    data = (1, 2, 3)
    assert into(list)(data) == into(list, data)
Ejemplo n.º 10
0
def test_into_string_on_right():
    with filetext('alice,1\nbob,2', extension='.csv') as source:
        assert into([], source) == [('alice', 1), ('bob', 2)]