Skip to content

refactor(consume): create explicit pytest plugin structure #1801

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

Merged
merged 11 commits into from
Jun 27, 2025

Conversation

danceratopz
Copy link
Member

@danceratopz danceratopz commented Jun 25, 2025

🗒️ Description

This PR refactors the consume simulator architecture to use explicit pytest plugin structure, improving organization and preparing for future multi-client architectures.

With this PR, we now explicitly register a single plugin for each consume sub-command; this central sub-command specific plugin, specified in src/cli/pytest_commands/processors.py, then dynamically registers all the required plugins in order to define the sub-command behavior. This is achieved via the pytest_plugins variable
, e.g.,

pytest_plugins = (
"pytest_plugins.pytest_hive.pytest_hive",
"pytest_plugins.consume.simulators.base",
"pytest_plugins.consume.simulators.single_test_client",
"pytest_plugins.consume.simulators.test_case_description",
"pytest_plugins.consume.simulators.timing_data",
"pytest_plugins.consume.simulators.exceptions",
)

🏗️ Explicit Pytest Plugin Structure

  • Replace automatic pytest plugin discovery with explicit registration (implicit registration occurred due how pytest registers plugins called conftest.py in subpaths to the provided test module paths, in this case test_via_engine.py/test_via_rlp.py.
  • Split functionality into focused, composable plugins: base.py, single_test_client.py, exceptions.py, test_case_description.py, timing_data.py.

📁 Improved Directory Organization

  • Rename hive_simulators/simulators/ for clarity.
  • Move shared utilities to helpers/ sub-package.
  • Consolidate test execution files in hive_tests/ directory (this will allow re-use of test_via_engine.py for the enginex simulator.
  • Maintain simulator-specific configs in their respective directories.

🔌 Plugin Registration System

  • Add explicit plugin registration based on command name (in src/cli/pytest_commands/).

🔗 Related Issues

This PR is a base for the new enginex simulator:

✅ 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: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@danceratopz danceratopz added type:refactor Type: Refactor scope:consume Scope: Consume command suite labels Jun 25, 2025
@danceratopz danceratopz force-pushed the refactor/consume-explicit-pytest-plugin-structure branch from 689f212 to b610953 Compare June 25, 2025 09:31
@danceratopz danceratopz marked this pull request as ready for review June 25, 2025 09:35
Copy link
Contributor

@spencer-tb spencer-tb left a comment

Choose a reason for hiding this comment

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

LGTM! Refactor is very nice. We've needed this for a while. Couldn't spot anything out of the ordinary :)

@danceratopz danceratopz force-pushed the refactor/consume-explicit-pytest-plugin-structure branch from 1b80ed9 to 284cc03 Compare June 25, 2025 14:17
Plugins called 'conftest' are registered automatically if in a sub-path to a test. This rename requires an explicit registration, which is specified by defining the `pytest_plugins` variable in 'engine/conftest.py', respectively, 'rlp/conftest.py'.
These are fixtures that can also be shared by multi-client architecture simulators.
…ectory

Consolidate test_via_engine.py and test_via_rlp.py into a shared hive_tests/
directory to improve organization and prepare for future multi-client architectures.

- Create src/pytest_plugins/consume/simulators/hive_tests/ directory.
- Move test_via_engine.py from engine/ to hive_tests/.
- Move test_via_rlp.py from rlp/ to hive_tests/.
- Update get_command_paths() to reference new locations.
- Maintain separation: plugin configs (conftest.py) stay with their simulators.

This provides better logical organization of test execution files while
maintaining explicit pytest plugin structure.
… configs

With the move to hive_tests/, the simulator-specific conftest.py files are no
longer automatically discovered. Add explicit plugin registration to ensure
_supported_fixture_formats and other simulator configs are properly loaded.

- Add command_name parameter to HiveEnvironmentProcessor.
- Register simulator-specific plugins based on command name.
- Update ConsumeCommand to pass command_name to processors.
- Fix AttributeError: 'Config' object has no attribute '_supported_fixture_formats'.
…conftest files

Move pytest_hive plugin registration from HiveEnvironmentProcessor to individual
simulator conftest files to centralize all plugin configuration in one place
per simulator.
@danceratopz danceratopz force-pushed the refactor/consume-explicit-pytest-plugin-structure branch from cf865b4 to b2e4a3b Compare June 26, 2025 20:31
Copy link
Member Author

@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.

Just a couple of explanatory comments.

Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@marioevz marioevz merged commit 1817346 into main Jun 27, 2025
27 checks passed
@marioevz marioevz deleted the refactor/consume-explicit-pytest-plugin-structure branch June 27, 2025 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:consume Scope: Consume command suite type:refactor Type: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants