コード例 #1
0
ファイル: collection.py プロジェクト: tngTUDOR/Ocelot
def test_unwrap_functions():
    a = lambda x: False
    b = lambda x: False
    c = lambda x: False
    d = lambda x: False
    e = lambda x: False

    lst = [a, Collection(b, Collection(c, d)), e]
    assert unwrap_functions(lst) == [a, b, c, d, e]
コード例 #2
0
def test_collection_applied_in_order(fake_report):
    collection = Collection(
        "foo",
        lambda x: x + [1],
        lambda x: x + [2]
    )
    report, data = system_model([], collection)
    assert data == [1,2]
コード例 #3
0
ファイル: collection.py プロジェクト: tngTUDOR/Ocelot
def test_collection_contains():
    collection = Collection(1, 2)
    assert 1 in collection
    assert 3 not in collection
コード例 #4
0
ファイル: collection.py プロジェクト: tngTUDOR/Ocelot
def test_collection_len():
    collection = Collection(1, 2)
    assert len(collection) == 2
コード例 #5
0
ファイル: collection.py プロジェクト: tngTUDOR/Ocelot
def test_empty_collection_is_falsey():
    """Passing a bare empty collection will trigger the default configuration"""
    assert not bool(Collection())
コード例 #6
0
ファイル: collection.py プロジェクト: tngTUDOR/Ocelot
def test_can_nest_collections(fake_report):
    empty_collection = Collection()
    report, data = system_model([1, 2, 3, 4], Collection(empty_collection))
    assert data == [1, 2, 3, 4]
コード例 #7
0
ファイル: collection.py プロジェクト: tngTUDOR/Ocelot
def test_can_pass_collection_directly(fake_report):
    """i.e. not in a list"""
    collection = Collection(lambda x: x)
    report, data = system_model([1, 2, 3, 4], collection)
    assert data == [1, 2, 3, 4]
コード例 #8
0
ファイル: collection.py プロジェクト: tngTUDOR/Ocelot
def test_empty_collection(fake_report):
    empty_collection = Collection()
    report, data = system_model([1, 2, 3, 4], [empty_collection])
    assert data == [1, 2, 3, 4]
コード例 #9
0
def test_collection_getitem():
    collection = Collection("foo", 1, 2, 3)
    assert collection[1] == 2
コード例 #10
0
def test_collection_unwrapped():
    collection = Collection("foo", 1, 2, Collection("bar", 3, 4))
    assert collection.functions == [1,2,3,4]
コード例 #11
0
def test_collection_str():
    collection = Collection("foo", 1, 2, 3)
    assert str(collection) == 'Collection foo with 3 functions'
    assert repr(collection) == 'Collection foo with 3 functions'
コード例 #12
0
def test_collection_reversed():
    collection = Collection("foo", 1, 2, 3)
    assert list(reversed(collection)) == [3, 2, 1]
コード例 #13
0
def test_collection_insert():
    collection = Collection("foo", 1, 2, 3)
    collection.insert(0, 'foo')
    assert collection.functions == ['foo', 1, 2, 3]
コード例 #14
0
def test_collection_deltiem():
    collection = Collection("foo", 1, 2, 3)
    del collection[1]
    assert collection.functions == [1, 3]
コード例 #15
0
def test_collection_setitem():
    collection = Collection("foo", 1, 2, 3)
    collection[2] = 'bar'
    assert collection.functions == [1, 2, 'bar']