Move pytests for faster dev iteration

This commit is contained in:
protolambda 2019-04-17 17:47:56 +10:00
parent dbb112b237
commit 90cf8738bf
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
18 changed files with 44 additions and 50 deletions

View File

@ -2,7 +2,6 @@ SPEC_DIR = ./specs
SCRIPT_DIR = ./scripts
TEST_LIBS_DIR = ./test_libs
PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec
PY_TEST_DIR = ./py_tests
YAML_TEST_DIR = ./yaml_tests
GENERATOR_DIR = ./test_generators
CONFIGS_DIR = ./configs
@ -24,7 +23,7 @@ all: $(PY_SPEC_ALL_TARGETS) $(YAML_TEST_DIR) $(YAML_TEST_TARGETS)
clean:
rm -rf $(YAML_TEST_DIR)
rm -rf $(GENERATOR_VENVS)
rm -rf $(PY_TEST_DIR)/venv $(PY_TEST_DIR)/.pytest_cache
rm -rf $(PY_SPEC_DIR)/venv $(PY_SPEC_DIR)/.pytest_cache
rm -rf $(PY_SPEC_ALL_TARGETS)
# "make gen_yaml_tests" to run generators
@ -32,7 +31,7 @@ gen_yaml_tests: $(YAML_TEST_DIR) $(YAML_TEST_TARGETS)
# runs a limited set of tests against a minimal config
test: $(PY_SPEC_ALL_TARGETS)
cd $(PY_TEST_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt; python -m pytest -m minimal_config .
cd $(PY_SPEC_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt; python -m pytest -m minimal_config .
# "make pyspec" to create the pyspec for all phases.
pyspec: $(PY_SPEC_ALL_TARGETS)

View File

@ -37,6 +37,5 @@ The following are the broad design goals for Ethereum 2.0:
Documentation on the different components used during spec writing can be found here:
* [YAML Test Generators](test_generators/README.md)
* [Executable Python Spec](test_libs/pyspec/README.md)
* [Py-tests](py_tests/README.md)
* [Executable Python Spec, with Py-tests](test_libs/pyspec/README.md)

View File

@ -1,30 +0,0 @@
# ETH 2.0 py-tests
These tests are not intended for client-consumption.
These tests are sanity tests, to verify if the spec itself is consistent.
There are ideas to port these tests to the YAML test suite,
but we are still looking for inputs on how this should work.
## How to run tests
### Automated
Run `make test` from the root of the spec repository.
### Manual
From within the py_tests folder:
Install dependencies:
```bash
python3 -m venv venv
. venv/bin/activate
pip3 install -r requirements.txt
```
Note: make sure to run `make pyspec` from the root of the specs repository, to build the pyspec requirement.
Run the tests:
```
pytest -m minimal_config .
```

View File

@ -1,7 +0,0 @@
eth-utils>=1.3.0,<2
eth-typing>=2.1.0,<3.0.0
oyaml==0.7
pycryptodome==3.7.3
py_ecc>=1.6.0
pytest>=3.6,<3.7
../test_libs/pyspec

View File

@ -7,6 +7,7 @@ With this executable spec,
test-generators can easily create test-vectors for client implementations,
and the spec itself can be verified to be consistent and coherent, through sanity tests implemented with pytest.
## Building
All the dynamic parts of the spec can be build at once with `make pyspec`.
@ -15,12 +16,42 @@ Alternatively, you can build a sub-set of the pyspec: `make phase0`.
Or, to build a single file, specify the path, e.g. `make test_libs/pyspec/eth2spec/phase0/spec.py`
## Py-tests
These tests are not intended for client-consumption.
These tests are sanity tests, to verify if the spec itself is consistent.
### How to run tests
#### Automated
Run `make test` from the root of the spec repository.
#### Manual
From within the `pyspec` folder:
Install dependencies:
```bash
python3 -m venv venv
. venv/bin/activate
pip3 install -r requirements.txt
```
Note: make sure to run `make pyspec` from the root of the specs repository,
to build the parts of the pyspec module derived from the markdown specs.
Run the tests:
```
pytest -m minimal_config .
```
## Contributing
Contributions are welcome, but consider implementing your idea as part of the spec itself first.
The pyspec is not a replacement.
If you see opportunity to include any of the `pyspec/eth2spec/utils/` code in the spec,
please submit an issue or PR.
## License

View File

@ -2,3 +2,4 @@ eth-utils>=1.3.0,<2
eth-typing>=2.1.0,<3.0.0
pycryptodome==3.7.3
py_ecc>=1.6.0
pytest>=3.6,<3.7

View File

@ -3,6 +3,7 @@ from setuptools import setup, find_packages
setup(
name='pyspec',
packages=find_packages(),
tests_require=["pytest"],
install_requires=[
"eth-utils>=1.3.0,<2",
"eth-typing>=2.1.0,<3.0.0",

View File

View File

@ -11,7 +11,7 @@ from eth2spec.phase0.spec import (
process_attestation,
slot_to_epoch,
)
from phase0.helpers import (
from tests.helpers import (
build_empty_block_for_next_slot,
get_valid_attestation,
)

View File

@ -7,7 +7,7 @@ from eth2spec.phase0.spec import (
get_beacon_proposer_index,
process_attester_slashing,
)
from phase0.helpers import (
from tests.helpers import (
get_valid_attester_slashing,
)

View File

@ -8,7 +8,7 @@ from eth2spec.phase0.spec import (
advance_slot,
process_block_header,
)
from phase0.helpers import (
from tests.helpers import (
build_empty_block_for_next_slot,
next_slot,
)

View File

@ -8,7 +8,7 @@ from eth2spec.phase0.spec import (
ZERO_HASH,
process_deposit,
)
from phase0.helpers import (
from tests.helpers import (
build_deposit,
privkeys,
pubkeys,

View File

@ -7,7 +7,7 @@ from eth2spec.phase0.spec import (
get_current_epoch,
process_proposer_slashing,
)
from phase0.helpers import (
from tests.helpers import (
get_valid_proposer_slashing,
)

View File

@ -9,7 +9,7 @@ from eth2spec.phase0.spec import (
get_current_epoch,
process_voluntary_exit,
)
from phase0.helpers import (
from tests.helpers import (
build_voluntary_exit,
pubkey_to_privkey,
)