Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins/forks): Make fork_covariant_parametrize into a marker #1057

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

marioevz
Copy link
Member

@marioevz marioevz commented Jan 7, 2025

🗒️ Description

Convert fork_covariant_parametrize into a marker pytest.mark.fork_parametrize in order to not have to import the function.

🔗 Related Issues

None

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • Tests: All converted JSON/YML tests from ethereum/tests have been added to converted-ethereum-tests.txt.
  • Tests: A PR with removal of converted JSON/YML tests from ethereum/tests have been opened.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@marioevz marioevz added scope:pytest Scope: Changes EEST's pytest plugins type:chore Type: Chore labels Jan 7, 2025
@marioevz marioevz requested a review from danceratopz January 7, 2025 17:15
Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I've warmed up this approach 🙂 Although it is possible to achieve the same functionality by adding a parametrized fixture that uses the fork fixture, I find parameterizing the test function much cleaner, explicit and easier to read.

I also prefer a pytest marker over a decorator, even if they achieve the same thing. It feels pytestic 🙂

To keep syntax more consistent with pytest.mark.parametrize(), I would suggest to:

  1. Rename the marker pytest.mark.parametrize_by_fork().
  2. Change the parameter_names list and fn keyword arguments to str positional arguments to be more consistent with pytest.mark.parametrize's syntax (for argnames and argvalues).

Then you have, for example,

@pytest.mark.parametrize_by_fork(
    "header_excess_blobs_delta", lambda fork: range(1, fork.max_blobs_per_block())
)
@pytest.mark.parametrize_by_fork(
    "parent_blobs", lambda fork: range(0, fork.target_blobs_per_block() + 1)
)
@pytest.mark.parametrize("parent_excess_blobs", [0])  # Start at 0
@pytest.mark.parametrize("new_blobs", [1])
def test_invalid_excess_blob_gas_target_blobs_increase_from_zero(
...

What do you think?

docs/writing_tests/test_markers.md Outdated Show resolved Hide resolved
@marioevz
Copy link
Member Author

marioevz commented Jan 9, 2025

@danceratopz great suggestions, I'll apply them in a bit!

@marioevz marioevz force-pushed the rename-fork-covariant-parametrize branch from 7430c10 to a531a2c Compare January 9, 2025 16:24
@marioevz marioevz merged commit 518fbee into main Jan 9, 2025
21 checks passed
@marioevz marioevz deleted the rename-fork-covariant-parametrize branch January 9, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:pytest Scope: Changes EEST's pytest plugins type:chore Type: Chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants