Skip to content

Commit

Permalink
tests: ignore tests not matching --fork arg given to pytest.
Browse files Browse the repository at this point in the history
Mostly a copy-paste from `py-evm` codebase; relevant PRs that
introduced the functionality there:

ethereum/py-evm#1470
ethereum/py-evm#1577
  • Loading branch information
veox committed May 16, 2019
1 parent 56ea99f commit c141e31
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions tests/json-fixtures-over-rpc/test_rpc_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
is_hex,
is_integer,
is_string,
to_tuple,
)

from eth.chains.base import (
Expand Down Expand Up @@ -204,7 +205,7 @@ def fixture_transaction_in_rpc_format(state):
}


def blockchain_fixture_mark_fn(fixture_path, fixture_name):
def blockchain_fixture_mark_fn(fixture_path, fixture_name, fixture_fork):
for slow_test in SLOW_TESTS:
if slow_test in fixture_path or slow_test in fixture_name:
if not should_run_slow_tests():
Expand All @@ -214,13 +215,35 @@ def blockchain_fixture_mark_fn(fixture_path, fixture_name):
return pytest.mark.xfail(reason="Listed in INCORRECT_UPSTREAM_TESTS.")


# TODO: import from `py-evm` if possible?..
def generate_ignore_fn_for_fork(passed_fork):
if passed_fork:
passed_fork = passed_fork.lower()

def ignore_fn(fixture_path, fixture_key, fixture_fork):
return fixture_fork.lower() != passed_fork

return ignore_fn


# TODO: import from `py-evm` if possible?..
@to_tuple
def expand_fixtures_forks(all_fixtures):
for fixture_path, fixture_key in all_fixtures:
fixture = load_fixture(fixture_path, fixture_key)
yield fixture_path, fixture_key, fixture['network']


def pytest_generate_tests(metafunc):
ignore_fn=generate_ignore_fn_for_fork(metafunc.config.getoption('fork'))
generate_fixture_tests(
metafunc=metafunc,
base_fixture_path=BASE_FIXTURE_PATH,
preprocess_fn=expand_fixtures_forks,
filter_fn=filter_fixtures(
fixtures_base_dir=BASE_FIXTURE_PATH,
mark_fn=blockchain_fixture_mark_fn,
ignore_fn=ignore_fn
),
)

Expand Down Expand Up @@ -401,8 +424,9 @@ async def validate_uncles(rpc, block_fixture, at_block):

@pytest.fixture
def chain_fixture(fixture_data):
fixture = load_fixture(*fixture_data)
if fixture['network'] == 'Istanbul':
fixture_path, fixture_key, fixture_fork = fixture_data
fixture = load_fixture(fixture_path, fixture_key)
if fixture_fork == 'Istanbul':
pytest.skip('Istanbul VM rules not yet supported')
return fixture

Expand Down

0 comments on commit c141e31

Please sign in to comment.