protolambda 675d404c38
Package eth2spec for tooling and experimentation
See tests/core/pyspec/README.md for usage description.

This commit:
- refactors config loading to be part of the pyspec package
- updates requirements and main files to use new config loading
- cleans up the build script
- converts the build script to a distutil command
- runs pyspec build as part of build package command
- provides pyspecdev command to get editable spec python files
2020-01-25 01:57:11 +01:00

40 lines
1023 B
Python

from eth2spec.config import config_util
from eth2spec.test.context import reload_specs
# We import pytest only when it's present, i.e. when we are running tests.
# The test-cases themselves can be generated without installing pytest.
def module_exists(module_name):
try:
__import__(module_name)
except ImportError:
return False
else:
return True
def fixture(*args, **kwargs):
if module_exists("pytest"):
import pytest
return pytest.fixture(*args, **kwargs)
else:
def ignore():
pass
return ignore
def pytest_addoption(parser):
parser.addoption(
"--config", action="store", default="minimal", help="config: make the pyspec use the specified configuration"
)
@fixture(autouse=True)
def config(request):
config_name = request.config.getoption("--config")
config_util.prepare_config('../../../configs/', config_name)
# now that the presets are loaded, reload the specs to apply them
reload_specs()