-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Fix assertion rewriting on Python 3.10 #8540
Conversation
Fixes pytest-dev#8539 This seems to have been the result of https://bugs.python.org/issue43798
for more information, see https://pre-commit.ci
Hmm, looks like the test is failing on master as well. Looks like it's benjaminp/six#352 |
src/_pytest/assertion/rewrite.py
Outdated
@@ -684,12 +684,9 @@ def run(self, mod: ast.Module) -> None: | |||
if not mod.body: | |||
# Nothing to do. | |||
return | |||
|
|||
# Insert some special imports at the top of the module but after any | |||
# docstrings and __future__ imports. |
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.
this comment has been orphaned
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.
That comment is still relevant in its current place! L690-L720 is figuring out the "after any docstrings and __future__
imports part".
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.
it's 40 lines away from the code that's relevant to the comment (the "special imports")
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.
Okay, made a 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.
It currently breaks all builds and even after pytest-dev#8540 it looks like tests still fail because of benjaminp/six#341 As a hotfix, mark it as experimental until everything is fixed, so that our CI isn't all red.
Could someone elaborate on how I can actually reproduce this? I'm trying to fix the testsuite on Python 3.10, but I don't see this issue happening at all. |
for example: https://github.com/asottile/flake8-match
|
Ah, I see - I was running 3.10.0a7 (because that's what @Zac-HD mentioned in the issue), but this is actually a very recent change. I can reproduce it when installing This also explains why this isn't needed on CI - it will be once beta 1 is out. |
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.
Thanks a lot @hauntsaninja!
Should have squashed, my bad! 🤦♂️ |
Will this not break actual alpha 7? |
Hmm I suppose, good point. Should we revert this and wait for beta 1? |
I think we can make the version check more specific. |
I cannot trigger a problem on Python 3.10.0a7, so maybe this is fine. |
FYI, GitHub Actions seems to have pushed a rather weird "beta 1" release which isn't actually beta 1 - so if we're seeing an influx of new reports about this, that'd be why (as |
Referencias: - actions/setup-python#207 - pytest-dev/pytest#8540 (comment) This reverts commit 05e8867.
I'm still having this issue on Python |
@AlirezaTheH please open a new issue with a reproduction |
Required upgrade to 6.25 to fix assertion error running coverage. See: pytest-dev/pytest#8540
Still have this problem:
The output is:
Related info:
|
@parsanoori as seen in the output header, you're actually running pytest 6.2.2 in the virtualenv there. |
It's the git maintainer's problem. |
`poetry update pytest` to get pytest-dev/pytest#8540 for Python 3.10 compatibility
`poetry update pytest` to get pytest-dev/pytest#8540 for Python 3.10 compatibility
Resolves assertion rewriting issue when running in Python 3.10. See pytest-dev/pytest#8540
- Bump pytest from 5.3.4 to 7.2.0 The old version of pytest did not support python3.10 Rel: pytest-dev/pytest#8540
- Bump pytest from 5.3.4 to 7.2.0 - Bump pytest-bdd from 3.2.1 6.1.1 The old version of pytest/pytest-bdd did not support python3.10 Rel: pytest-dev/pytest#8540
- Bump pytest from 5.3.4 to 7.2.0 - Bump pytest-bdd from 3.2.1 4.1.0 The old version of pytest/pytest-bdd did not support python3.10 Rel: pytest-dev/pytest#8540
Bump pytest and pytes-bdd to get support for python3.10 - pytest from 5.3.4 to 7.2.0 - pytest-bdd from 3.2.1 to 4.1.0 (5 and 6 have to many breaking changes) See: https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst Bump other dependencies - boto3 - bravado-core - cryptography - pycodestyle - PyJWT - pytest-parallel - requests The `requirements.txt` was updated wit the output from `pip freeze` after new version of the dependencies was installed Rel: pytest-dev/pytest#8540
Python 3.10 broke pytest <6.2.4: pytest-dev/pytest#8539 (comment) Fix implemented pytest-dev/pytest#8540
Python 3.10 broke pytest <6.2.4: pytest-dev/pytest#8539 (comment) Fix implemented pytest-dev/pytest#8540
… envs See [this PR thread](pytest-dev/pytest#8540) for more information.
… envs See [this PR thread](pytest-dev/pytest#8540) for more information.
Fixes #8539
This seems to have been the result of https://bugs.python.org/issue43798