Skip to content

build(deps): replace pytest-cases with native pytest fixtures - #279

Open
toby-coleman wants to merge 2 commits into
mainfrom
chore/drop-pytest-cases
Open

build(deps): replace pytest-cases with native pytest fixtures#279
toby-coleman wants to merge 2 commits into
mainfrom
chore/drop-pytest-cases

Conversation

@toby-coleman

@toby-coleman toby-coleman commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

pytest-cases prevents upgrading to pytest 9.1 and pytest-asyncio 1.4. Replace its parametrization with native pytest fixtures and indirect parametrization, without adding a replacement plugin.

Connector variants are immutable ConnectorCase values, with explicit ZMQ proxy-on and proxy-off cases. A shared context manager applies settings only when requested and restores them on teardown. Module fixtures retain their existing connector matrices; process tests use indirect=["connector_cls"] for setup. This removes the duplicated ZMQ fixtures and preserves main's settings-cleanup fixes.

Require pytest-asyncio>=1.4,<2 for the uvloop factory hook, allow pytest 9.1, and assert that tests actually run on uvloop. Remove pytest-cases and its unused transitive dependencies from the lockfile.

Validation:

  • All 436 existing cases retain their parameters, after normalizing renamed IDs and parameter order.
  • Six regression cases cover connector settings restoration on success and failure.
  • Full unit suite: 273 passed, 6 skipped.
  • Affected integration cases using local Asyncio/ZMQ: 39 passed.
  • Ruff lint/format, ty, and lockfile checks pass.
  • Broker-dependent integration and additional RayProcess cases were not run locally; Docker is stopped.

@github-actions

Copy link
Copy Markdown

Benchmark comparison for 78e8f549 (base) vs 8555e7d0 (PR)


------------------------------------------------------------------------------------------------------------------ benchmark: 2 tests -----------------------------------------------------------------------------------------------------------------
Name (time in ms)                                                                         Min                 Max                Mean            StdDev              Median               IQR            Outliers     OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_process_run (main/.benchmarks/Linux-CPython-3.14-64bit/0001_base)     543.7379 (1.0)      552.0260 (1.0)      546.4201 (1.0)      3.4445 (1.0)      545.1890 (1.0)      4.6461 (1.51)          1;0  1.8301 (1.0)           5           1
test_benchmark_process_run (pr/.benchmarks/Linux-CPython-3.14-64bit/0001_pr)         543.9373 (1.00)     552.4100 (1.00)     550.1646 (1.01)     3.5378 (1.03)     551.7915 (1.01)     3.0804 (1.0)           1;1  1.8176 (0.99)          5           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

pytest-cases 3.10.1 builds the private _pytest.python.IdMaker
positionally, so it fails to import under pytest 9.1, and its
SuperClosure prunes the fixture that pytest-asyncio 1.4 injects for
loop factories. Both upstream fixes are unreleased, so the test
extras were pinned below those versions.

The suite used pytest-cases only to reference a fixture from a
parametrisation. Fixture unions become plain parametrised fixtures
plus pytest-lazy-fixtures lf(), which resolves references through
public pytest APIs, so the pytest and pytest-asyncio bounds reopen.

The uvloop loop factory hook also takes effect for the first time:
pytest-asyncio 1.3 has no such hookspec, so the suite ran on the
default event loop. tests/unit/test_conftest.py now asserts the
running loop instead of the hook return value.

Refs smarie/python-pytest-cases#385
@toby-coleman
toby-coleman force-pushed the chore/drop-pytest-cases branch from 8555e7d to f22ce74 Compare September 6, 2026 21:05
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Benchmark comparison for 7b0cbeda (base) vs f22ce749 (PR)


------------------------------------------------------------------------------------------------------------------- benchmark: 2 tests ------------------------------------------------------------------------------------------------------------------
Name (time in ms)                                                                         Min                 Max                Mean             StdDev              Median                IQR            Outliers     OPS            Rounds  Iterations
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_process_run (main/.benchmarks/Linux-CPython-3.14-64bit/0001_base)     282.5185 (1.0)      325.6491 (1.06)     294.1860 (1.0)      18.5042 (2.24)     283.4941 (1.0)      20.7217 (1.90)          1;0  3.3992 (1.0)           5           1
test_benchmark_process_run (pr/.benchmarks/Linux-CPython-3.14-64bit/0001_pr)         286.9364 (1.02)     308.0382 (1.0)      295.0203 (1.00)      8.2722 (1.0)      294.6342 (1.04)     10.9288 (1.0)           1;0  3.3896 (1.00)          5           1
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

@toby-coleman toby-coleman changed the title build(deps): drop pytest-cases for pytest 9.1 build(deps): replace pytest-cases with native pytest fixtures Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Benchmark comparison for 7b0cbeda (base) vs e778d47a (PR)


------------------------------------------------------------------------------------------------------------------ benchmark: 2 tests -----------------------------------------------------------------------------------------------------------------
Name (time in ms)                                                                         Min                 Max                Mean            StdDev              Median               IQR            Outliers     OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_process_run (pr/.benchmarks/Linux-CPython-3.14-64bit/0001_pr)         374.6671 (1.0)      381.1057 (1.0)      377.6614 (1.0)      2.7345 (1.0)      376.7706 (1.0)      4.6450 (1.0)           2;0  2.6479 (1.0)           5           1
test_benchmark_process_run (main/.benchmarks/Linux-CPython-3.14-64bit/0001_base)     378.8515 (1.01)     391.0242 (1.03)     385.4952 (1.02)     4.6408 (1.70)     384.8948 (1.02)     6.3310 (1.36)          2;0  2.5941 (0.98)          5           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are cohesive and test-focused, and the only noted follow-ups are minor test-ID readability improvements rather than correctness blockers.

Pull request overview

This PR removes the pytest-cases dependency by rewriting test parametrization using native pytest fixtures/@pytest.mark.parametrize, while updating test dependencies to support newer pytest/pytest-asyncio and keeping connector-variant setup (including ZMQ proxy on/off) explicit and safely restored.

Changes:

  • Replaced pytest-cases fixtures/parametrization with pytest fixtures, indirect parametrization, and per-module connector matrices.
  • Added shared ConnectorCase + configured_connector plumbing in tests/conftest.py and regression tests ensuring settings restoration and uvloop usage.
  • Updated pyproject.toml/uv.lock to remove pytest-cases and allow pytest 9.1+ with pytest-asyncio 1.4+.
File summaries
File Description
uv.lock Removes pytest-cases (and transitive deps) and updates pins for pytest/pytest-asyncio.
pyproject.toml Updates test dependency ranges and drops pytest-cases.
tests/conftest.py Introduces ConnectorCase, configured_connector, and an indirect connector_cls fixture; keeps uvloop loop factory hook.
tests/unit/test_connector_pubsub.py Switches connector parametrization to native pytest fixture + @pytest.mark.parametrize.
tests/unit/test_conftest.py Updates uvloop verification test and adds regression coverage for connector settings restoration.
tests/unit/test_channel.py Replaces pytest-cases connector matrices with ConnectorCase-backed fixtures (incl. mp variant).
tests/integration/test_state_backend_multiprocess.py Replaces pytest-cases parametrization with pytest.mark.parametrize.
tests/integration/test_process_with_components_run.py Converts connector matrix to indirect parametrization using ConnectorCase (proxy on/off explicit).
tests/integration/test_process_stop_cancel.py Converts connector matrix to indirect parametrization using ConnectorCase (proxy on/off explicit).
tests/integration/test_connector_pubsub.py Updates connector fixture and parametrization away from pytest-cases.
tests/integration/test_component_event_handlers.py Updates connector fixture to use ConnectorCase (proxy on/off explicit).
tests/integration/test_component_decorator.py Replaces pytest-cases parametrization with pytest.mark.parametrize.
tests/integration/test_channel.py Updates connector fixtures (including mp) and parametrization away from pytest-cases.
Review details
  • Files reviewed: 12/13 changed files
  • Comments generated: 2
  • Review effort level: Lite

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

(RayProcess, ConnectorCase(RabbitMQConnector)),
],
indirect=["connector_cls"],
ids=connector_case_id,
(RayProcess, ConnectorCase(RabbitMQConnector)),
],
indirect=["connector_cls"],
ids=connector_case_id,
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