class SublimeMock: Region = _MockObject() def __getattr__(self, key): if key.isupper(): return hash(key) else: raise AttributeError(key)
def test_abc_MockObject(): mock = _MockObject() class Base: @abc.abstractmethod def __init__(self): pass class Derived(Base, mock.SubClass): pass obj = Derived() assert isinstance(obj, Base) assert isinstance(obj, _MockObject) assert isinstance(obj.some_method(), Derived)
def test_MockObject(): mock = _MockObject() assert isinstance(mock.some_attr, _MockObject) assert isinstance(mock.some_method, _MockObject) assert isinstance(mock.attr1.attr2, _MockObject) assert isinstance(mock.attr1.attr2.meth(), _MockObject) class SubClass(mock.SomeClass): """docstring of SubClass""" def method(self): return "string" obj = SubClass() assert SubClass.__doc__ == "docstring of SubClass" assert isinstance(obj, SubClass) assert obj.method() == "string" assert isinstance(obj.other_method(), SubClass)
def test_MockObject(): mock = _MockObject() assert isinstance(mock.some_attr, _MockObject) assert isinstance(mock.some_method, _MockObject) assert isinstance(mock.attr1.attr2, _MockObject) assert isinstance(mock.attr1.attr2.meth(), _MockObject) class SubClass(mock.SomeClass): """docstring of SubClass""" def method(self): return "string" obj = SubClass() assert SubClass.__doc__ == "docstring of SubClass" assert isinstance(obj, SubClass) assert obj.method() == "string" assert isinstance(obj.other_method(), SubClass)