Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
    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,
        )
        contract.functions = ContractFunctions(contract.abi, contract.web3)
        contract.caller = ContractCaller(contract.abi, contract.web3,
                                         contract.address)
        contract.events = ContractEvents(contract.abi, contract.web3)
        contract.fallback = Contract.get_fallback_function(
            contract.abi, contract.web3)

        return contract
Beispiel #4
0
 def factory(cls, class_name, **kwargs):
     return PropertyCheckingFactory(class_name, (cls, ),
                                    kwargs)(kwargs.get('abi'))