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
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
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
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
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
def test_can_define_specifications_for_built_in_types(): sm = SpecificationMapper() sm.define_specification_for(Bar, const(1)) assert sm.specification_for(Bar) == 1
def test_can_define_specifications(): sm = SpecificationMapper() sm.define_specification_for("foo", const(1)) assert sm.specification_for("foo") == 1
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
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