예제 #1
0
def test_truthy_on_change():
    exp = Expando()
    exp.x = 'y'
    assert exp
예제 #2
0
def test_falsy_when_new():
    assert not Expando()
예제 #3
0
def test_falsy_on_change():
    exp = Expando(x='y')
    del exp.x
    assert not exp
예제 #4
0
def test_truthy_on_change():
    exp = Expando()
    exp.x = 'y'
    assert exp
예제 #5
0
def test_truthy_when_new():
    assert Expando(content='something') and True or False
예제 #6
0
def obj():
    return Expando(a=1)
예제 #7
0
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'
예제 #8
0
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