def test_property_checking_metaclass_inherited_attributes(): from_inherited_namespace = {'arg0': True, 'arg1': True} PropertyCheckingFactory('class_name', (BaseClass, ), from_inherited_namespace) from_base_namespace = {'arg2': True, 'arg3': True} PropertyCheckingFactory('class_name', (BaseClass, ), from_base_namespace)
def test_property_checking_metaclass_attribute_error(): # Test proper attribute checking, arg from both bases. namespace = {'arg2': True, 'arg0': True, 'arg4': True} with pytest.raises(AttributeError): PropertyCheckingFactory('class_name', (BaseClass, ), namespace) # Test proper attribute checking, only absent arg. namespace = {'arg4': True} with pytest.raises(AttributeError): PropertyCheckingFactory('class_name', (BaseClass, ), namespace)
def factory(cls, web3, class_name=None, **kwargs): kwargs['web3'] = web3 normalizers = { 'abi': normalize_abi, 'address': partial(normalize_address, kwargs['web3'].ens), 'bytecode': normalize_bytecode, 'bytecode_runtime': normalize_bytecode, } contract = PropertyCheckingFactory(class_name or cls.__name__, (cls, ), kwargs, normalizers=normalizers) setattr(contract, 'functions', ContractFunctions(contract.abi, contract.web3)) setattr(contract, 'events', ContractEvents(contract.abi, contract.web3)) return contract
def factory(cls, class_name, **kwargs): return PropertyCheckingFactory(class_name, (cls, ), kwargs)