Skip to content

fix: apply loop factories to parametrized asyncio marks - #1574

Open
Samuel-Hills wants to merge 2 commits into
pytest-dev:mainfrom
Samuel-Hills:fix/parametrized-loop-factories-1463
Open

Samuel-Hills wants to merge 2 commits into
pytest-dev:mainfrom
Samuel-Hills:fix/parametrized-loop-factories-1463

Conversation

@Samuel-Hills

Copy link
Copy Markdown

No description provided.

@codecov-commenter

codecov-commenter commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.68%. Comparing base (0c1bb1f) to head (9930e58).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1574      +/-   ##
==========================================
+ Coverage   94.50%   94.68%   +0.17%     
==========================================
  Files           2        2              
  Lines         510      527      +17     
  Branches       62       65       +3     
==========================================
+ Hits          482      499      +17     
  Misses         22       22              
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Thank you for your interest in contributing! I assume this relates to #1463?

The solution in this PR still parametrizes the whole test function and doesn't resolve the mixed backend problem described in the issue. With two loop factories and asyncio/trio markers, this produces two asyncio and two trio cases. The trio case should only run once. This is the same issue discussed in #1551 which was a attempt at a solution.

Comment thread pytest_asyncio/plugin.py Outdated
if len(marker.args) < 2:
continue
for parameter_set in marker.args[1]:
if any(mark.name == "asyncio" for mark in parameter_set.marks):

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.

Parameter values do not have to be pytest.param objects. In strict mode, an async test for another plugin with, e.g., @pytest.mark.parametrize("value", [1, 2]), now fails during collection.

Comment thread pytest_asyncio/plugin.py Outdated
marker_loop_scope, marker_selected_factory_names = _parse_asyncio_marker(
asyncio_marker
)
if asyncio_marker is None:

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.

This ignores the factory selection on the parameter's asyncio mark. With factories "a" and "b", a parameter marked pytest.mark.asyncio(loop_factories=["b"]) still runs with both factories.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants