def test_resolve_with_attributes(): class A(object): a = 'a' def __init__(self): self.b = 'b' scope = Scope(['a']) assert scope.resolve(A()) == 'a' scope = Scope(['b']) assert scope.resolve(A()) == 'b'
def test_resolve(): context = { 'a': { 'b': 'c', }, } scope = Scope(['a', 'b']) assert scope.resolve(context) == 'c'
def test_resolve_attributes(): class Context(object): def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) context = Context(a=Context(b='c')) scope = Scope(['a', 'b']) assert scope.resolve(context) == 'c'