Example #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
Example #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
Example #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
Example #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
Example #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
Example #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
Example #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
Example #8
0
def test_can_define_specifications():
    sm = SpecificationMapper()
    sm.define_specification_for("foo", const(1))
    assert sm.specification_for("foo") == 1
Example #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
Example #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
Example #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
Example #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
Example #13
0
def test_can_define_specifications():
    sm = SpecificationMapper()
    sm.define_specification_for("foo", const(1))
    assert sm.specification_for("foo") == 1
Example #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