def test_contracted_shortcut(): def f(hub): pass c = Contracted(hub="a hub", contracts=[], func=f, ref=None, name=None) c.contract_functions['pre'] = [ None ] # add some garbage so we raise if we try to evaluate contracts c()
def __init__(self, c): mock_func = create_autospec(c.func, spec_set=True) mock_func.__module__ = c.func.__module__ mock_func.__dict__.update(copy.deepcopy(c.func.__dict__)) self.__dict__['contracted'] = Contracted(c.hub, c._mod, c.contracts, mock_func) self.signature = c.signature
def _mock_function(self, f): return Contracted( hub=self._lazy_hub(), contracts=f.contracts, func=f.func, ref=f.ref, name=f.__name__, )
def _mock_function(self, f: Contracted) -> Contracted: return Contracted( hub=self._lazy_hub(), contracts=None, func=f.func, ref=f.ref, name=f.__name__, )
def mock_contracted(contract_hub, c): mock_func = create_autospec(c.func, spec_set=True) mock_func.__signature__ = c.signature # required for python 3.6 mock_func.__module__ = c.func.__module__ mock_func.__dict__.update(copy.deepcopy(c.func.__dict__)) return Contracted(contract_hub, c.contracts, mock_func, c.ref, c.__name__)
def mock_contracted(c): mock_func = create_autospec(c.func, spec_set=True) mock_func.__module__ = c.func.__module__ mock_func.__dict__.update(copy.deepcopy(c.func.__dict__)) return Contracted(c.hub, c.contracts, mock_func, c.ref, c.name)