Skip to content

Commit 0900aa8

Browse files
authored
feat(fill): emphasize that no tests were executed during a fill pytest session (#887)
* feat(forks): improve language; 'tests executed' -> 'generated' * feat(fill): emphasize no (client) tests were ran in summary * docs: update changelog * fix(fill): remove custom fields from stats; this breaks pytester * feat(fill): add more emphasis to 'No tests executed' summary line * feat(fill): set custom verbose test report labels via plugin The previous attempt in d27a0ab broke xfail behaviour; this plugin accounts for tests marked as xfail. This issue was visible in `src/pytest_plugins/forks/tests/test_covariant_markers.py::test_fork_covariant_markers[with_all_tx_types_with_marks_lambda_multiple_marks]`. * docs: fix typo in changelog * feat(cli): add long overdue alias for fill This change requires the pytest-custom-report plugin. * tests(phil): assert unicorns * tests(phil): fix docstring in unicorn test
1 parent 619e7d8 commit 0900aa8

File tree

8 files changed

+94
-6
lines changed

8 files changed

+94
-6
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Test fixtures for use by clients are available for each release on the [Github r
4747
- ✨ Pin EELS versions in `eels_resolutions.json` and include this file in fixture releases ([#872](https://github.com/ethereum/execution-spec-tests/pull/872)).
4848
- 🔀 Replace `ethereum.base_types` with `ethereum-types` ([#850](https://github.com/ethereum/execution-spec-tests/pull/850)).
4949
- 💥 `PragueEIP7692` fork has been renamed to `Osaka` ([#869](https://github.com/ethereum/execution-spec-tests/pull/869))
50+
- ✨ Improve `fill` terminal output to emphasize that filling tests is not actually testing a client ([#807](https://github.com/ethereum/execution-spec-tests/pull/887)).
5051

5152
### 🔧 EVM Tools
5253

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies = [
2929
"requests_unixsocket2>=0.4.0",
3030
"colorlog>=6.7.0,<7",
3131
"pytest>7.3.2,<8",
32+
"pytest-custom-report>=1.0.1,<2",
3233
"pytest-html>=4.1.0,<5",
3334
"pytest-metadata>=3,<4",
3435
"pytest-xdist>=3.3.1,<4",
@@ -81,6 +82,7 @@ docs = [
8182

8283
[project.scripts]
8384
fill = "cli.pytest_commands.fill:fill"
85+
phil = "cli.pytest_commands.fill:phil"
8486
tf = "cli.pytest_commands.fill:tf"
8587
checkfixtures = "cli.check_fixtures:check_fixtures"
8688
consume = "cli.pytest_commands.consume:consume"

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ addopts =
1919
--tb short
2020
--dist loadscope
2121
--ignore tests/cancun/eip4844_blobs/point_evaluation_vectors/
22+
# these customizations require the pytest-custom-report plugin
23+
report_passed_verbose = FILLED
24+
report_xpassed_verbose = XFILLED

src/cli/pytest_commands/fill.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,32 @@ def fill(pytest_args: List[str], **kwargs) -> None:
6565
),
6666
)
6767
sys.exit(result)
68+
69+
70+
@click.command(context_settings=dict(ignore_unknown_options=True))
71+
@common_click_options
72+
def phil(pytest_args: List[str], **kwargs) -> None:
73+
"""
74+
A friendly alias for the fill command.
75+
"""
76+
args = handle_fill_command_flags(
77+
["--index", *pytest_args],
78+
)
79+
result = pytest.main(
80+
args
81+
+ [
82+
"-o",
83+
"report_passed=🦄",
84+
"-o",
85+
"report_xpassed=🌈",
86+
"-o",
87+
"report_failed=👾",
88+
"-o",
89+
"report_xfailed=🦺",
90+
"-o",
91+
"report_skipped=🦘",
92+
"-o",
93+
"report_error=🚨",
94+
],
95+
)
96+
sys.exit(result)

src/cli/tests/test_pytest_fill_command.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import pytest_plugins.filler.filler
1313

14-
from ..pytest_commands.fill import fill
14+
from ..pytest_commands.fill import fill, phil
1515

1616

1717
@pytest.fixture
@@ -191,3 +191,13 @@ def test_fill_html_and_output_options(
191191
assert result.exit_code == pytest.ExitCode.OK
192192
assert html_path.exists()
193193
assert (output_dir / "state_tests").exists(), "No fixtures in output directory"
194+
195+
196+
def test_phil_default_output_options(runner):
197+
"""
198+
A simple sanity test for phil.
199+
"""
200+
fill_args = ["-k", "test_dup and state_test-DUP16 and LEGACY", "--fork", "Frontier"]
201+
result = runner.invoke(phil, fill_args)
202+
assert result.exit_code == pytest.ExitCode.OK
203+
assert "🦄" in result.output

src/pytest_plugins/filler/filler.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from typing import Any, Dict, Generator, List, Type
1616

1717
import pytest
18+
from _pytest.terminal import TerminalReporter
1819
from filelock import FileLock
1920
from pytest_metadata.plugin import metadata_key # type: ignore
2021

@@ -270,10 +271,13 @@ def pytest_report_header(config: pytest.Config):
270271

271272
def pytest_report_teststatus(report, config: pytest.Config):
272273
"""
273-
Disable test session progress report if we're writing the JSON fixtures to
274-
stdout to be read by a consume command on stdin. I.e., don't write this
275-
type of output to the console:
274+
This hook modifies the test results in pytest's terminal output.
276275
276+
We use this:
277+
278+
1. To disable test session progress report if we're writing the JSON
279+
fixtures to stdout to be read by a consume command on stdin. I.e.,
280+
don't write this type of output to the console:
277281
```text
278282
...x...
279283
```
@@ -282,6 +286,32 @@ def pytest_report_teststatus(report, config: pytest.Config):
282286
return report.outcome, "", report.outcome.upper()
283287

284288

289+
@pytest.hookimpl(hookwrapper=True, trylast=True)
290+
def pytest_terminal_summary(
291+
terminalreporter: TerminalReporter, exitstatus: int, config: pytest.Config
292+
):
293+
"""
294+
Modify pytest's terminal summary to emphasize that no tests were ran.
295+
296+
Emphasize that fixtures have only been filled; they must now be executed to
297+
actually run the tests.
298+
"""
299+
yield
300+
stats = terminalreporter.stats
301+
if "passed" in stats and stats["passed"]:
302+
# append / to indicate this is a directory
303+
output_dir = str(strip_output_tarball_suffix(config.getoption("output"))) + "/"
304+
terminalreporter.write_sep(
305+
"=",
306+
(
307+
f' No tests executed - the test fixtures in "{output_dir}" may now be executed '
308+
"against a client "
309+
),
310+
bold=True,
311+
yellow=True,
312+
)
313+
314+
285315
def pytest_metadata(metadata):
286316
"""
287317
Add or remove metadata to/from the pytest report.

src/pytest_plugins/forks/forks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,15 @@ def pytest_report_header(config, start_path):
438438
header = [
439439
(
440440
bold
441-
+ "Executing tests for: "
441+
+ "Generating fixtures for: "
442442
+ ", ".join([f.name() for f in sorted(list(config.fork_set))])
443443
+ reset
444444
),
445445
]
446446
if all(fork.is_deployed() for fork in config.fork_set):
447447
header += [
448448
(
449-
bold + warning + "Only executing tests with stable/deployed forks: "
449+
bold + warning + "Only generating fixtures with stable/deployed forks: "
450450
"Specify an upcoming fork via --until=fork to "
451451
"add forks under development." + reset
452452
)

uv.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)