-
Notifications
You must be signed in to change notification settings - Fork 135
[tests] add Python 3.10 env, update pytest dependency #30
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3b23655
Test in Python 3.10, update dev status classifier
elacuesta 51d1db1
CI: fail-fast=False
elacuesta fa0c493
[tests] update pytest version
elacuesta e573578
Flake8 adjustment
elacuesta 67b446e
Remove testing no-op
elacuesta 1dd2e2c
Remove comment in tests
elacuesta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Taken from | ||
https://github.com/pytest-dev/pytest-asyncio/blob/25cf2b399e00a82b69951474eed074ba26cd0c3b/pytest_asyncio/plugin.py | ||
|
||
Modify pytest_pycollect_makeitem to make use of the Function API | ||
in pytest>=5.4.0 (pytest.Function.from_parent). | ||
|
||
In the context of scrapy-playwright, this allows to unpin the outdated pytest<5.4.0 dependency, | ||
while keeping pytest-asyncio==0.10, as pytest-asyncio>=0.11 currently breaks tests | ||
(likely to be because of https://github.com/pytest-dev/pytest-asyncio/issues/157). | ||
""" | ||
|
||
|
||
import asyncio | ||
import inspect | ||
|
||
import pytest | ||
|
||
try: | ||
from _pytest.python import transfer_markers | ||
except ImportError: # Pytest 4.1.0 removes the transfer_marker api (#104) | ||
|
||
def transfer_markers(*args, **kwargs): # noqa | ||
"""Noop when over pytest 4.1.0""" | ||
pass | ||
elacuesta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def _is_coroutine(obj): | ||
"""Check to see if an object is really an asyncio coroutine.""" | ||
return asyncio.iscoroutinefunction(obj) or inspect.isgeneratorfunction(obj) | ||
|
||
|
||
@pytest.mark.tryfirst | ||
def pytest_pycollect_makeitem(collector, name, obj): | ||
"""A pytest hook to collect asyncio coroutines.""" | ||
if collector.funcnamefilter(name) and _is_coroutine(obj): | ||
item = pytest.Function.from_parent(collector, name=name) | ||
|
||
# Due to how pytest test collection works, module-level pytestmarks | ||
# are applied after the collection step. Since this is the collection | ||
# step, we look ourselves. | ||
transfer_markers(obj, item.cls, item.module) | ||
item = pytest.Function.from_parent(collector, name=name) # To reload keywords. | ||
|
||
if "asyncio" in item.keywords: | ||
return list(collector._genfunctions(name, obj)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is the problem pytest-dev/pytest-asyncio#157 or the fix for it (pytest-dev/pytest-asyncio#156) introduced in 0.12? Is
pytest-asyncio>=0.12
not an option?Uh oh!
There was an error while loading. Please reload this page.
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.
0.11
is the first version that fails. I tried versions0.12
and0.15.1
(the latest at the time of writing) and they also fail. I think upgrading it might take some more research.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.
Upon closer inspection, the errors with
0.12
point to Twisted (RuntimeError: twisted reactor has stopped
). There are probably some unexpected interactions withpytest-twisted
.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.
Since pytest-dev/pytest-asyncio#157 is probably not the issue then, shall we just remove the parenthesized statement from the comment and merge?
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.
Fair point, now the issues are mentioned here for future reference anyway 👍