Skip to content
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

Introduce way to determine if a pytest Item is a pytest-asyncio test #686

Merged
merged 5 commits into from
Nov 27, 2023

Conversation

seifertm
Copy link
Contributor

@seifertm seifertm commented Nov 26, 2023

This PR introduces the public function is_async_test(pytest.Item) -> bool. The function is intended to be used in pytest hooks or by plugins to determine whether a test item is an async test managed by pytest-asyncio.

The new function allows more convenient marking of all async tests in a test suite (see #676)

…ubclass rather than the instance.

Previously, PytestAsyncioFunction.substitute returned the Item instance unchanged, when no substitution occured. This change allows for different code branches based on whether the substitution happened or not.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…ted own_markers from being transferred to the subclass instance.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…test_collection_modifyitems to pytest_pycollect_makeitem.

This change causes PytestAsyncioFunction items to exclusively replace those pytest.Function items that are eligible as async tests. That means, once a test item has been substituted, an isinstance check is sufficient to determine if the item is an async test.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…lementation of PytestAsyncioFunction subclasses.

Added assertion for existing asyncio marker in PytestAsyncioFunction._from_function.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
@seifertm seifertm added this to the v0.23 milestone Nov 26, 2023
…est Item is an async test managed by pytest-asyncio.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
@codecov-commenter
Copy link

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (fac9092) 94.60% compared to head (62ff26f) 94.81%.

Files Patch % Lines
pytest_asyncio/plugin.py 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #686      +/-   ##
==========================================
+ Coverage   94.60%   94.81%   +0.21%     
==========================================
  Files           2        2              
  Lines         463      463              
  Branches       95       92       -3     
==========================================
+ Hits          438      439       +1     
  Misses         16       16              
+ Partials        9        8       -1     

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

@seifertm seifertm added this pull request to the merge queue Nov 27, 2023
Merged via the queue into pytest-dev:main with commit 5fc341a Nov 27, 2023
9 checks passed
@seifertm seifertm deleted the is_async_test branch November 27, 2023 06:38
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.

None yet

2 participants