コード例 #1
0
ファイル: test_local.py プロジェクト: candlerb/pato
def test_setattrs_nested():
    foo = local_factory()
    assert foo is not ctx
    assert not hasattr(foo, 'a')
    foo.b = 'grumpy'
    with setattrs(foo, a='hello', b='world'):
        assert foo.a == 'hello'
        assert foo.b == 'world'
        with setattrs(foo, a='goodbye'):
            assert foo.a == 'goodbye'
            assert foo.b == 'world'
        assert foo.a == 'hello'
        assert foo.b == 'world'
    assert not hasattr(foo, 'a')
    assert foo.b == 'grumpy'
コード例 #2
0
ファイル: test_local.py プロジェクト: candlerb/pato
def test_setattrs_ctx():
    """
    There is a shared ctx object which is the default target
    """
    ctx = get_ctx()
    assert not hasattr(ctx, 'a')
    assert not hasattr(ctx, 'b')
    with setattrs(a='hello', b='world'):
        assert ctx.a == 'hello'
        assert ctx.b == 'world'
        with setattrs(a='goodbye'):
            assert ctx.a == 'goodbye'
            assert ctx.b == 'world'
        assert ctx.a == 'hello'
        assert ctx.b == 'world'
    assert not hasattr(ctx, 'a')
    assert not hasattr(ctx, 'b')
コード例 #3
0
ファイル: test_local.py プロジェクト: candlerb/pato
def test_setattrs_local():
    foo = AnyObject()
    assert not hasattr(foo, 'a')
    assert not hasattr(foo, 'b')
    with setattrs(foo, a='hello', b='world'):
        assert foo.a == 'hello'
        assert foo.b == 'world'
    assert not hasattr(foo, 'a')
    assert not hasattr(foo, 'b')