def test_can_unregister_by_equality(registry: ABIRegistry): registry.unregister(BaseEquals('address')) with pytest.raises(exceptions.NoEntriesFound): registry.get_encoder('address') with pytest.raises(exceptions.NoEntriesFound): registry.get_decoder('address')
def test_can_unregister_by_equality(registry: ABIRegistry): registry.unregister(BaseEquals('address')) with pytest.raises(ValueError, match=r'No matching entries .* encoder registry'): registry.get_encoder('address') with pytest.raises(ValueError, match=r'No matching entries .* decoder registry'): registry.get_decoder('address')
def test_cache_resets_after_unregister_and_unregister_works( registry: ABIRegistry): # Populate cache registry.get_encoder('address') registry.get_decoder('address') # Perform cache resetting action registry.unregister('address') # Confirm cache reset with pytest.raises(exceptions.NoEntriesFound): registry.get_encoder('address') with pytest.raises(exceptions.NoEntriesFound): registry.get_decoder('address')
def test_can_register_and_unregister_string_lookups(registry: ABIRegistry): registry.register( 'bool', encoding.BooleanEncoder, decoding.BooleanDecoder, ) assert isinstance(registry.get_encoder('bool'), encoding.BooleanEncoder) assert isinstance(registry.get_decoder('bool'), decoding.BooleanDecoder) registry.unregister('bool') with pytest.raises(exceptions.NoEntriesFound): registry.get_encoder('bool') with pytest.raises(exceptions.NoEntriesFound): registry.get_decoder('bool')
def test_cache_resets_after_unregister_and_unregister_works( registry: ABIRegistry): # Populate cache registry.get_encoder('address') registry.get_decoder('address') # Perform cache resetting action registry.unregister('address') # Confirm cache reset with pytest.raises(ValueError, match=r'No matching entries .* encoder registry'): registry.get_encoder('address') with pytest.raises(ValueError, match=r'No matching entries .* decoder registry'): registry.get_decoder('address')
def test_can_register_simple_callables(registry: ABIRegistry): encode_bool = lambda x: x decode_bool = lambda x: x registry.register('bool', encode_bool, decode_bool) assert registry.get_encoder('bool') is encode_bool assert registry.get_decoder('bool') is decode_bool
def test_cache_resets_after_register_and_register_works(registry: ABIRegistry): # Populate cache registry.get_encoder('address') registry.get_decoder('address') # Perform cache resetting action registry.register( BaseEquals('address', with_sub=False), encoding.AddressEncoder, decoding.AddressDecoder, label='address without sub', ) # Confirm cache reset with pytest.raises(exceptions.MultipleEntriesFound): registry.get_encoder('address') with pytest.raises(exceptions.MultipleEntriesFound): registry.get_decoder('address')
def test_can_register_and_unregister_string_lookups(registry: ABIRegistry): registry.register( 'bool', encoding.BooleanEncoder, decoding.BooleanDecoder, ) assert isinstance(registry.get_encoder('bool'), encoding.BooleanEncoder) assert isinstance(registry.get_decoder('bool'), decoding.BooleanDecoder) registry.unregister('bool') with pytest.raises(ValueError, match=r'No matching entries .* encoder registry'): registry.get_encoder('bool') with pytest.raises(ValueError, match=r'No matching entries .* decoder registry'): registry.get_decoder('bool')
def test_can_register_simple_callables(registry: ABIRegistry): def encode_bool(x): return x decode_bool = encode_bool registry.register('bool', encode_bool, decode_bool) assert registry.get_encoder('bool') is encode_bool assert registry.get_decoder('bool') is decode_bool
def test_cache_resets_after_register_and_register_works(registry: ABIRegistry): # Populate cache registry.get_encoder('address') registry.get_decoder('address') # Perform cache resetting action registry.register( BaseEquals('address', with_sub=False), encoding.AddressEncoder, decoding.AddressDecoder, label='address without sub', ) # Confirm cache reset pattern = r'Multiple matching entries .* encoder registry' with pytest.raises(ValueError, match=pattern): registry.get_encoder('address') pattern = r'Multiple matching entries .* decoder registry' with pytest.raises(ValueError, match=pattern): registry.get_decoder('address')