Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
        setattr(contract, 'functions',
                ContractFunctions(contract.abi, contract.web3))
        setattr(contract, 'events', ContractEvents(contract.abi,
                                                   contract.web3))

        return contract
Ejemplo n.º 4
0
 def factory(cls, class_name, **kwargs):
     return PropertyCheckingFactory(class_name, (cls, ), kwargs)