-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Mark tests for async test suite more accurately #3180
Mark tests for async test suite more accurately #3180
Conversation
tox.ini
Outdated
core: pytest {posargs:tests/core -k "not async"} | ||
core_async: pytest {posargs:tests/core -k async} | ||
core: pytest {posargs:tests/core -m "not asyncio" -k "not async"} | ||
core_async: pytest {posargs:tests/core -k "asyncio or async"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should asyncio
be part of the mark expression flag? I think this will find any test names containing asyncio
or async
(which in turn finds anything that would include asyncio
I believe).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, good catch. I think it should be the opposite of the previous. Will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach needs to be revised actually... I don't believe the -m
and -k
work well enough together. We may just have to run asyncio
marked tests and the opposite as:
pytest tests/core -m asyncio
: run tests that are actually asynchronous in naturepytest tests/core -m "not asyncio"
: run all other tests, including those that may involve async classes but aren't asynchronous in nature (e.g. testing some static, non-asynchronous, property of some asynchronous class)
8ea55be
to
b5d8fca
Compare
aa99744
to
493fa0a
Compare
- All async tests need the ``@pytest.mark.asyncio`` decorator to be picked up by pytest-asyncio. This already marks them as asyncio tests, so we should use the ``-m`` option to call them as well as looking for "async" in the test name with the``-k`` option. This is necessary since some async tests only test for properties and aren't actually asynchronous but we want to consider them as part of the async test suite (e.g. testing some attribute on the AsyncHttpProvider). - Reviewers, be sure to check that the selected number in one test run equals the deselected number in the other.
493fa0a
to
dbfe191
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to see the marker flag, way more robust than relying on the test name itself.
I looked at the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Much cleaner! 🧹
What was wrong?
All async tests need the
@pytest.mark.asyncio
decorator to be picked up by pytest-asyncio. This already marks them as asyncio tests, so we should use the-m
option to call them. Looking for "async" in the test name with the-k
option caused us to miss some tests that we didn't name with "async" in them in the async test suite.Note to any reviewers: Be sure to check that the selected number in one test run equals the deselected number in the other.
Todo:
Cute Animal Picture