select preset with cli arg
This commit is contained in:
parent
f5c647b47b
commit
a57ff5fc01
|
@ -57,21 +57,22 @@ Caveats:
|
|||
|
||||
Full test usage, with explicit configuration for illustration of options usage:
|
||||
```shell
|
||||
(venv) python -m pytest --config=minimal eth2spec
|
||||
(venv) python -m pytest --preset=minimal eth2spec
|
||||
```
|
||||
|
||||
Or, to run a specific test file, specify the full path:
|
||||
```shell
|
||||
(venv) python -m pytest --config=minimal ./eth2spec/test/phase0/block_processing/test_process_attestation.py
|
||||
(venv) python -m pytest --preset=minimal ./eth2spec/test/phase0/block_processing/test_process_attestation.py
|
||||
```
|
||||
|
||||
Or, to run a specific test function (specify the `eth2spec` module, or the script path if the keyword is ambiguous):
|
||||
```shell
|
||||
(venv) python -m pytest --config=minimal -k test_success_multi_proposer_index_iterations eth2spec
|
||||
(venv) python -m pytest --preset=minimal -k test_success_multi_proposer_index_iterations eth2spec
|
||||
```
|
||||
|
||||
Options:
|
||||
- `--config`, to change the config. Defaults to `minimal`, can be set to `mainnet`, or other configs from the configs directory.
|
||||
- `--preset`, to change the preset (compile-time configurables). Defaults to `minimal`, can be set to `mainnet`.
|
||||
Use `@spec_configured_state_test({config here...}` to override runtime configurables on a per-test basis.
|
||||
- `--disable-bls`, to disable BLS (only for tests that can run without)
|
||||
- `--bls-type`, `milagro` or `py_ecc` (default)
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@ def pytest_addoption(parser):
|
|||
|
||||
@fixture(autouse=True)
|
||||
def preset(request):
|
||||
# TODO: apply to tests, see context.py 'with_presets'
|
||||
preset_flag_value = request.config.getoption("--preset")
|
||||
print("preset:", preset_flag_value)
|
||||
context.DEFAULT_TEST_PRESET = request.config.getoption("--preset")
|
||||
|
||||
|
||||
@fixture(autouse=True)
|
||||
|
|
|
@ -19,6 +19,9 @@ from typing import Any, Callable, Sequence, TypedDict, Protocol, Dict
|
|||
|
||||
from lru import LRU
|
||||
|
||||
# Without pytest CLI arg or pyspec-test-generator 'preset' argument, this will be the config to apply.
|
||||
DEFAULT_TEST_PRESET = MINIMAL
|
||||
|
||||
|
||||
# TODO: currently phases are defined as python modules.
|
||||
# It would be better if they would be more well-defined interfaces for stronger typing.
|
||||
|
@ -339,7 +342,7 @@ def with_phases(phases, other_phases=None):
|
|||
if other_phases is not None:
|
||||
available_phases |= set(other_phases)
|
||||
|
||||
preset_name = MINIMAL
|
||||
preset_name = DEFAULT_TEST_PRESET
|
||||
if 'preset' in kw:
|
||||
preset_name = kw.pop('preset')
|
||||
targets = spec_targets[preset_name]
|
||||
|
|
Loading…
Reference in New Issue