Skip to content

refactor: simplify pytest_configure, warn on era mismatch - #3702

Merged
mkoura merged 2 commits into
masterfrom
warn_era_mismatch
Sep 21, 2026
Merged

mkoura merged 2 commits into
masterfrom
warn_era_mismatch

Conversation

@mkoura

@mkoura mkoura commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Two changes to cardano_node_tests/tests/conftest.py.

Warn when Tx era differs from cluster era

Running with a transaction era that doesn't match the cluster era is
not a supported configuration, but nothing said so - the run just
failed later in confusing ways. pytest_configure now logs a warning
naming both eras.

Split pytest_configure

pytest_configure had grown to ~80 lines of mostly
config.stash[metadata_key][...] = .... Split into:

  • _set_metadata(config) - report metadata. Binds
    config.stash[metadata_key] to a local, dropping ~40 repetitions of
    the subscript chain.
  • _warn_on_setup() - the custom-path warnings plus the new era
    warning. Resolves the executable paths with shutil.which itself
    rather than reading them back from the metadata stash, so it has no
    ordering dependency on _set_metadata.

pytest_configure is now the socket check, the skipall bail, and
two calls.

Behavior change beyond the new warning: _warn_on_setup runs only on
the xdist controller (not hasattr(config, "workerinput")), so the
warnings are logged once instead of once per worker. Metadata
collection still runs everywhere, unchanged.

Running with a transaction era that doesn't match the cluster era
is not a supported configuration. Warn about it at configure time,
naming both eras, so unexpected failures are easier to explain.
Move report metadata collection into `_set_metadata` and the setup
warnings into `_warn_on_setup`. Binding `config.stash[metadata_key]`
to a local drops ~40 repetitions of the subscript chain.

`_warn_on_setup` resolves the executable paths itself instead of
reading them back from the metadata stash, so it does not depend on
`_set_metadata` having run. It is now called only on the xdist
controller, so the warnings are not repeated by every worker.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved review issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Refactors pytest setup and adds warnings for transaction/cluster era mismatches.

Changes:

  • Extracts metadata handling into _set_metadata.
  • Extracts setup warnings into _warn_on_setup.
  • Limits warnings to the xdist controller.
File Description
cardano_node_tests/​tests/​conftest.py Refactored pytest configuration and added setup warnings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mkoura
mkoura merged commit 1dcf074 into master Sep 21, 2026
4 checks passed
@mkoura
mkoura deleted the warn_era_mismatch branch September 21, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants