def test_context_flocked_object(self): obj = flock({'one': {'two': lambda: 3, 'three': 4}}) assert get_context(obj) == obj assert get_context(obj.one) == obj assert get_context(obj.one.two) == obj
def test_flock_nested_object(self): Class = type(str('Class'), (object, ), {}) obj = flock({'attr': Class()}) assert isinstance(obj.attr, Class)
def test_flock_unflock(self): definition = {'one': {'two': {'three': self.func}}} assert unflock(flock(definition)) == definition
def test_flock_nested_attributes(self): obj = flock({'one': {'two': {'three': 1, 'four': [1, {'five': 5}]}}}) assert obj.one.two.three == 1 assert obj.one.two.four == [1, {'five': 5}]
def test_flock_nested_methods(self): obj = flock({'one': {'two': {'three': self.func}}}) assert six.callable(obj.one.two.three) assert isinstance(obj.one.two.three, type(obj.one.two.three)) assert obj.one.two.three() == 1
def test_flock_flat_attribute(self): assert flock({'one': 1}).one == 1
def test_flock_flat_method(self): obj = flock({'one': self.func}) assert six.callable(obj.one) assert isinstance(obj.one, type(self.func)) assert obj.one() == 1
def test_flock_nested_object(self): Class = type(str('Class'), (object,), {}) obj = flock({'attr': Class()}) assert isinstance(obj.attr, Class)