예제 #1
0
def test_can_override_in_children():
    sm = SpecificationMapper()
    child = sm.new_child_mapper()
    sm.define_specification_for("foo", const(1))
    child.define_specification_for("foo", const(2))
    assert sm.specification_for("foo") == 1
    assert child.specification_for("foo") == 2
예제 #2
0
def test_can_override_in_children():
    sm = SpecificationMapper()
    child = sm.new_child_mapper()
    sm.define_specification_for("foo", const(1))
    child.define_specification_for("foo", const(2))
    assert sm.specification_for("foo") == 1
    assert child.specification_for("foo") == 2
예제 #3
0
def test_child_can_call_other_specs_on_prototype():
    s = SpecificationMapper()
    s.define_specification_for("bar",
                               lambda t, d: t.specification_for("foo") + 1)
    s2 = s.new_child_mapper()
    s2.define_specification_for("foo", const(1))
    assert s2.specification_for("bar") == 2
예제 #4
0
def test_can_call_other_specs():
    s = SpecificationMapper()
    s.define_specification_for("foo", const(1))
    s.define_specification_for(
        "bar",
        lambda t, _: t.specification_for("foo") + 1
    )
    assert s.specification_for("bar") == 2
예제 #5
0
def test_child_can_call_other_specs_on_prototype():
    s = SpecificationMapper()
    s.define_specification_for(
        "bar",
        lambda t, d: t.specification_for("foo") + 1
    )
    s2 = s.new_child_mapper()
    s2.define_specification_for("foo", const(1))
    assert s2.specification_for("bar") == 2
예제 #6
0
def test_can_create_children():
    sm = SpecificationMapper()
    child = sm.new_child_mapper()
    sm.define_specification_for("foo", const(1))
    assert child.specification_for("foo") == 1
예제 #7
0
def test_can_define_specifications_for_built_in_types():
    sm = SpecificationMapper()
    sm.define_specification_for(Bar, const(1))
    assert sm.specification_for(Bar) == 1
예제 #8
0
def test_can_define_specifications():
    sm = SpecificationMapper()
    sm.define_specification_for("foo", const(1))
    assert sm.specification_for("foo") == 1
예제 #9
0
def test_can_override_specifications():
    s = SpecificationMapper()
    s.define_specification_for("foo", const(1))
    s.define_specification_for("foo", const(2))
    assert s.specification_for("foo") == 2
예제 #10
0
def test_can_call_other_specs():
    s = SpecificationMapper()
    s.define_specification_for("foo", const(1))
    s.define_specification_for("bar",
                               lambda t, _: t.specification_for("foo") + 1)
    assert s.specification_for("bar") == 2
예제 #11
0
def test_can_create_children():
    sm = SpecificationMapper()
    child = sm.new_child_mapper()
    sm.define_specification_for("foo", const(1))
    assert child.specification_for("foo") == 1
예제 #12
0
def test_can_define_specifications_for_built_in_types():
    sm = SpecificationMapper()
    sm.define_specification_for(Bar, const(1))
    assert sm.specification_for(Bar) == 1
예제 #13
0
def test_can_define_specifications():
    sm = SpecificationMapper()
    sm.define_specification_for("foo", const(1))
    assert sm.specification_for("foo") == 1
예제 #14
0
def test_can_override_specifications():
    s = SpecificationMapper()
    s.define_specification_for("foo", const(1))
    s.define_specification_for("foo", const(2))
    assert s.specification_for("foo") == 2