def test_set_attr_default_ignores_when_defined(): """ Assert that :func:`~decorstate.set_attr_default` does not set the attribute to the default value when it is already set on the object. """ class Foo(object): exists = True decorstate.set_attr_default(Foo, 'exists', 'default_value') assert Foo.exists is True
def test_set_attr_default_sets_when_not_defined(name, value): """ Assert that :func:`~decorstate.set_attr_default` sets the attribute to the default value when it is not already set on the object. """ class Foo(object): pass decorstate.set_attr_default(Foo, name, value) assert getattr(Foo, name) == value