Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
monkey patching environment variables failed due to a strange config for sleep times
  • Loading branch information
fhenneke committed Oct 4, 2024
1 parent de14e80 commit 060c9e8
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/e2e/test_blockchain_data.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
from os import getenv
from os import getenv, environ
from unittest.mock import patch

from dotenv import load_dotenv
import pytest
from web3 import Web3
from src.helpers.blockchain_data import BlockchainData

load_dotenv()


def tests_get_tx_hashes_blocks():
@pytest.fixture()
def set_env_variables(monkeypatch):
"""Set `REMOVE_SOLVER_PK` to a string so that blacklisting can be called."""
with patch.dict(environ, clear=True):
envvars = {
"CHAIN_SLEEP_TIME": "1",
}
for k, v in envvars.items():
monkeypatch.setenv(k, v)
yield # This is the magical bit which restore the environment after


def tests_get_tx_hashes_blocks(set_env_variables):
# import has to happen after patching environment variable
from src.helpers.blockchain_data import BlockchainData

web3 = Web3(Web3.HTTPProvider(getenv("NODE_URL")))
blockchain = BlockchainData(web3)
start_block = 20892118
Expand Down

0 comments on commit 060c9e8

Please sign in to comment.