Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--fork cli option: fix the case of using pytest -k without setting directory path #2688

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions tests/core/pyspec/eth2spec/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,27 @@ def pytest_addoption(parser):
)


def _validate_fork_name(forks):
for fork in forks:
if fork not in ALL_PHASES:
raise ValueError(
f'The given --fork argument "{fork}" is not an available fork.'
f' The available forks: {ALL_PHASES}'
)


@fixture(autouse=True)
def preset(request):
context.DEFAULT_TEST_PRESET = request.config.getoption("--preset")


@fixture(autouse=True)
def run_phases(request):
phases = request.config.getoption("--fork")
if phases:
phases = [phase.lower() for phase in phases]
context.DEFAULT_PYTEST_FORKS = set(phases)
forks = request.config.getoption("--fork", default=None)
if forks:
forks = [fork.lower() for fork in forks]
_validate_fork_name(forks)
context.DEFAULT_PYTEST_FORKS = set(forks)
else:
context.DEFAULT_PYTEST_FORKS = ALL_PHASES

Expand Down