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
| 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.
this comment has been orphaned
There was a problem hiding this comment.
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.
it's 40 lines away from the code that's relevant to the comment (the "special imports")
There was a problem hiding this comment.
Okay, made a change! :-)
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. |
nicoddemus
left a comment
There was a problem hiding this comment.
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
Increased the version of pytest to make it work with py 3.10 [0]. The GET calls no longer return list but the object itself, fixed the tests and assertions to account for that. The tests did not account for the later added `allow_user_remove_domain` setting. And there were issues with missing and non-stopped patchers/mocks. Now all tests are at least passing. [0] pytest-dev/pytest#8540

Fixes #8539
This seems to have been the result of https://bugs.python.org/issue43798