Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
PR feedback, thanks to CC
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed May 13, 2019
1 parent c234a02 commit 56a4d78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"pytest-mock==1.10.4",
# only needed for p2p
"pytest-asyncio-network-simulator==0.1.0a2;python_version>='3.6'",
# only for eth2
"ruamel.yaml<=0.15",
],
'lint': [
"flake8==3.5.0",
Expand Down
33 changes: 17 additions & 16 deletions tests/eth2/beacon/state-fixtures/test_minimal_state.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from pathlib import Path
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
import pytest
from ruamel.yaml import (
YAML,
)

from eth_utils import (
to_tuple,
Expand Down Expand Up @@ -36,7 +34,7 @@

FIXTURE_FILE_NAMES = [
"sanity-check_small-config_32-vals.yaml",
# "sanity-check_default-config_100-vals.yaml",
"sanity-check_default-config_100-vals.yaml",
]


Expand Down Expand Up @@ -67,16 +65,17 @@ def mock_bls(mocker, request):
# Helpers for generating test suite
#
def get_all_test_cases(file_names):
test_cases = []
test_cases = {}
yaml = YAML()
for file_name in file_names:
file_to_open = BASE_FIXTURE_PATH / file_name
with open(file_to_open, 'U') as f:
# TODO: `proof_of_possession` is used in v0.5.1 spec and will be renamed to `signature`
# Trinity renamed it ahead due to py-ssz signing_root requirements
new_text = f.read().replace('proof_of_possession', 'signature')
try:
data = yaml.load(new_text, Loader=Loader)
test_cases += data['test_cases']
data = yaml.load(new_text)
test_cases[file_name] = data['test_cases']
except yaml.YAMLError as exc:
print(exc)
return test_cases
Expand All @@ -92,13 +91,15 @@ def state_fixture_mark_fn(fixture_name):
@to_tuple
def get_test_cases(fixture_file_names):
test_cases = get_all_test_cases(fixture_file_names)
for test_case in test_cases:
test_name = test_case['name']
mark = state_fixture_mark_fn(test_name)
if mark is not None:
yield pytest.param(test_case, id=test_name, marks=(mark,))
else:
yield pytest.param(test_case, id=test_name)
for file_name, test_cases in test_cases.items():
for test_case in test_cases:
test_name = test_case['name']
test_id = f"{file_name}::{test_name}:{test_case.lc.line}"
mark = state_fixture_mark_fn(test_name)
if mark is not None:
yield pytest.param(test_case, id=test_id, marks=(mark,))
else:
yield pytest.param(test_case, id=test_id)


all_test_cases = get_test_cases(FIXTURE_FILE_NAMES)
Expand Down

0 comments on commit 56a4d78

Please sign in to comment.