Skip to content

Apply loop factories when asyncio is marked via parametrize - #1551

Open
gyanu2507 wants to merge 1 commit into
pytest-dev:mainfrom
gyanu2507:loop-factories-parametrize-asyncio
Open

Apply loop factories when asyncio is marked via parametrize#1551
gyanu2507 wants to merge 1 commit into
pytest-dev:mainfrom
gyanu2507:loop-factories-parametrize-asyncio

Conversation

@gyanu2507

Copy link
Copy Markdown

pytest_generate_tests only looked at the function's own asyncio marker, so this never picked up loop factories:

@pytest.mark.parametrize(
    "backend",
    [pytest.param("asyncio", marks=pytest.mark.asyncio)],
)
async def test_async(backend):
    ...

Also convert those functions during collection so strict mode still owns them.

Fixes #1463.

pytest.param(..., marks=pytest.mark.asyncio) was ignored when selecting pytest_asyncio_loop_factories.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.00000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.62%. Comparing base (40342fa) to head (8aca36b).

Files with missing lines Patch % Lines
pytest_asyncio/plugin.py 45.00% 4 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1551      +/-   ##
==========================================
- Coverage   94.50%   92.62%   -1.89%     
==========================================
  Files           2        2              
  Lines         510      529      +19     
  Branches       62       71       +9     
==========================================
+ Hits          482      490       +8     
- Misses         22       26       +4     
- Partials        6       13       +7     

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

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.

pytest_asyncio_loop_factories hook is not called when pytest.mark.asyncio is added via parametrization

2 participants