def test_truthy_on_change(): exp = Expando() exp.x = 'y' assert exp
def test_falsy_when_new(): assert not Expando()
def test_falsy_on_change(): exp = Expando(x='y') del exp.x assert not exp
def test_truthy_when_new(): assert Expando(content='something') and True or False
def obj(): return Expando(a=1)
def test_nested_context(): "Should handle nested context managers correctly" env = Expando(foo='bar', bar='baz') with state(env, foo='baz') as _, state(env, bar='foo') as _: assert env.foo == 'baz' assert env.bar == 'foo'
def test_patch_sys_modules(): with (state(sys.modules, fakey=Expando(foo='bar'))): import fakey assert fakey.foo == 'bar' with (pytest.raises(ImportError)): import fakey