1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
import pytest
@pytest.fixture(params=["auto", "explicit", "env"])
def keccak(monkeypatch, request, keccak_auto):
if request.param == "auto":
return keccak_auto
elif request.param == "explicit":
from eth_hash import (
Keccak256,
)
from eth_hash.backends import (
pysha3,
)
return Keccak256(pysha3)
elif request.param == "env":
monkeypatch.setenv("ETH_HASH_BACKEND", "pysha3")
from eth_hash.auto import (
keccak,
)
return keccak
else:
raise AssertionError(f"Unrecognized approach to import keccak: {request.param}")
|