pytest: Latest 8.0.0 is breaking on 3.8+
Comment by pytest maintainers: pytest-asyncio is not yet compatible with pytest 8; if you’re using pytest-asyncio, stick with pytest<8 until the issue is resolved.
Description
Prior to 8.0.0 all tests on 3.7 – 3.11 were passing. Then today when 8.0.0 was released 3.8+ started failing.
See screen shot, rerunning tests that passed on 27 Jan, failed today on 28 Jan.
Failure is happening on 3.8+
The only requirements for the project are pytest and pytest-asyncio. For reference, the project is FairAsyncRLock. The git action workflow for the Ci/Cd is here.
Traceback
This is the problem. It’s the same for all 3.8+.
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/main.py", line 272, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/main.py", line 325, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_manager.py", line 119, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 138, in _multicall
INTERNALERROR> raise exception.with_traceback(exception.__traceback__)
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/logging.py", line 783, in pytest_collection
INTERNALERROR> return (yield)
INTERNALERROR> ^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/warnings.py", line 1[18](https://github.com/Joshuaalbert/FairAsyncRLock/actions/runs/7680017808/job/20940748975#step:6:19), in pytest_collection
INTERNALERROR> return (yield)
INTERNALERROR> ^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR> teardown.throw(exception) # type: ignore[union-attr]
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1365, in pytest_collection
INTERNALERROR> return (yield)
INTERNALERROR> ^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 102, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/main.py", line 336, in pytest_collection
INTERNALERROR> session.perform_collect()
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/main.py", line 799, in perform_collect
INTERNALERROR> self.items.extend(self.genitems(node))
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/main.py", line 942, in genitems
INTERNALERROR> yield from self.genitems(subnode)
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/main.py", line 937, in genitems
INTERNALERROR> rep, duplicate = self._collect_one_node(node, handle_dupes)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/main.py", line 825, in _collect_one_node
INTERNALERROR> rep = collect_one_node(node)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/_pytest/runner.py", line 566, in collect_one_node
INTERNALERROR> ihook.pytest_collectstart(collector=collector)
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_manager.py", line 1[19](https://github.com/Joshuaalbert/FairAsyncRLock/actions/runs/7680017808/job/20940748975#step:6:20), in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 138, in _multicall
INTERNALERROR> raise exception.with_traceback(exception.__traceback__)
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pluggy/_callers.py", line 102, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pytest_asyncio/plugin.py", line 6[26](https://github.com/Joshuaalbert/FairAsyncRLock/actions/runs/7680017808/job/20940748975#step:6:27), in pytest_collectstart
INTERNALERROR> pyobject = collector.obj
INTERNALERROR> ^^^^^^^^^^^^^
INTERNALERROR> AttributeError: 'Package' object has no attribute 'obj'
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 4
- Comments: 22 (9 by maintainers)
Commits related to this issue
- * Temporarily pin pytest version until https://github.com/pytest-dev/pytest/issues/11868 is resolved. — committed to Joshuaalbert/FairAsyncRLock by Joshuaalbert 5 months ago
- Add a changelog entry about FixtureManager.getfixtureclosure losing a default argument As discussed in #11868. — committed to nicoddemus/pytest by nicoddemus 5 months ago
- Reintroduce default value for ignore_args argument of FixtureManager.getfixtureclosure Fix #11868 — committed to nicoddemus/pytest by nicoddemus 5 months ago
- Reintroduce default value for ignore_args argument of FixtureManager.getfixtureclosure Fix #11868 — committed to nicoddemus/pytest by nicoddemus 5 months ago
- Reintroduce default value for ignore_args argument of FixtureManager.getfixtureclosure Fix #11868 — committed to nicoddemus/pytest by nicoddemus 5 months ago
- Reintroduce default value for ignore_args argument of FixtureManager.getfixtureclosure Fix #11868 — committed to nicoddemus/pytest by nicoddemus 5 months ago
- Add a changelog entry about FixtureManager.getfixtureclosure losing a default argument As discussed in #11868. — committed to nicoddemus/pytest by nicoddemus 5 months ago
- Add changelog entry about FixtureManager.getfixtureclosure changing (#11887) As discussed in #11868. — committed to pytest-dev/pytest by nicoddemus 5 months ago
- Limit pytest to "<8.0.0" * Pytest 8 breaks when using the asyncio library, see issue https://github.com/pytest-dev/pytest/issues/11868 * We should use pytest-asyncio instead of the asyncio library di... — committed to argoproj-labs/hera by elliotgunton 5 months ago
- Limit pytest to <8.0.0 (#945) Limits [pytest](https://github.com/pytest-dev/pytest) to <8.0.0. * Pytest 8 breaks when using the asyncio library, see issue https://github.com/pytest-dev/pytest/issue... — committed to argoproj-labs/hera by dependabot[bot] 5 months ago
I completely understand the feeling, and it is frustrating to us as well… believe us, we don’t make light to introduce breaking changes, even for internal APIs – @bluetech goes to great pains grepping a large number of plugins to check if internal changes are breaking them, for example.
Having said that, we have been doing some nice refactorings in the direction of cleaning up pytest internals (especially @bluetech and @sadra-barikbin, who have been doing fantastic work). Unfortunately much of the pytest internal design/implementation just grew organically over the years (pytest is really old, started in 2008 or so I believe), without an overall design driving the changes, so we are playing catch up – and the moving is slow, because we have limited time as maintainers and also because we realize we should make baby steps in order to avoid breaking things; and even so, we end up breaking downstream projects using the internals all the time.
Seems like pytest-asyncio isn’t compatible with pytest 8 yet, so until this is fixed, stick with pytest<8. Hopefully pytest-asyncio can do a release which requires pytest<8 soon (until pytest 8 support is added) so this happens automatically.
@sthagen This error indicates that one of the plugins you use is overriding the internal
getfixtureclosurefunction. Because the plugin name does not appear in the stack trace, it’s not possible to know which. Perhaps you can do agrep -R 'def getfixtureclosure'in your venv directory to find the plugin (excluding pytest itself of course).Pytest-asyncio specifies an upper bound on the supported pytest version since v0.23.4a2. Unfortunately, the pre-release didn’t make it in time for the pytest 8 release.
I just released v0.23.4 which correctly specifies the compatible pytest versions. This should prevent pytest-asyncio from being installed together with pytest 8 by accident, until the compatibility issue is resolved on the pytest-asyncio side.
Sorry for causing noise on the pytest bug tracker. Feel free to ping me directly in this kind of issues.
Perhaps @bluetech could add Sybil to the plugins checked? I’ve lost count of the number of times I’ve had new release of pytest break Sybil because it has to use “non-public” APS…
Thanks folks, closing this then as there’s nothing to be done on pytest’s side.
The
getfixtureclosurecrash likely comes from pytest-cases according to https://github.com/smarie/python-pytest-cases/issues/330.Having the same issue on Python3.12 and pytest-asyncio
@cjw296 that sounds like a great idea! Feel free to open a PR in that regard to get the ball rolling if you want.