pytest: Assertion rewriting fails under Python 3.10.0a7+
Traceback (most recent call last):
...
File "_pytest/assertion/rewrite.py", line 161, in exec_module
source_stat, co = _rewrite_test(fn, self.config)
File "_pytest/assertion/rewrite.py", line 356, in _rewrite_test
co = compile(tree, fn_, "exec", dont_inherit=True)
TypeError: required field "lineno" missing from alias
full traceback
Traceback (most recent call last):
File "/home/runner/.cache/hypothesis-build-runtimes/python-versions/3.10-dev/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/runner/.cache/hypothesis-build-runtimes/python-versions/3.10-dev/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pytest/__main__.py", line 5, in <module>
raise SystemExit(pytest.console_main())
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 185, in console_main
code = main()
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 143, in main
config = _prepareconfig(args, plugins)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 318, in _prepareconfig
config = pluginmanager.hook.pytest_cmdline_parse(
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/callers.py", line 203, in _multicall
gen.send(outcome)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse
config: Config = outcome.get_result()
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1003, in pytest_cmdline_parse
self.parse(args)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1283, in parse
self._preparse(args, addopts=addopts)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1168, in _preparse
self.pluginmanager.consider_preparse(args, exclude_only=False)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 635, in consider_preparse
self.consider_pluginarg(parg)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 660, in consider_pluginarg
self.import_plugin(arg, consider_entry_points=True)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 713, in import_plugin
self.register(mod, modname)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 443, in register
self.consider_module(plugin)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 669, in consider_module
self._import_plugin_specs(getattr(mod, "pytest_plugins", []))
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 676, in _import_plugin_specs
self.import_plugin(import_spec)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 703, in import_plugin
__import__(importspec)
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 161, in exec_module
source_stat, co = _rewrite_test(fn, self.config)
File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 356, in _rewrite_test
co = compile(tree, fn_, "exec", dont_inherit=True)
TypeError: required field "lineno" missing from alias
I discovered this in the Hypothesis CI, with Pytest 6.2.3 on Ubuntu and python3.10-dev (alpha07) from pyenv. Unfortunately I don’t have a smaller reproducing example than that, since my only copy of alpha07 is on that CI server.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 15 (12 by maintainers)
Links to this issue
Commits related to this issue
- Fix assertion rewriting on Python 3.10 Fixes https://github.com/pytest-dev/pytest/issues/8539 This seems to have been the result of https://bugs.python.org/issue43798 — committed to hauntsaninja/pytest by deleted user 3 years ago
- Fix assertion rewriting on Python 3.10 Fixes https://github.com/pytest-dev/pytest/issues/8539 This seems to have been the result of https://bugs.python.org/issue43798 — committed to hauntsaninja/pytest by deleted user 3 years ago
- Fix assertion rewriting on Python 3.10 Fixes https://github.com/pytest-dev/pytest/issues/8539 This seems to have been the result of https://bugs.python.org/issue43798 — committed to hauntsaninja/pytest by deleted user 3 years ago
- ci: Pin Python 3.10 to Alpha 7 See https://github.com/actions/setup-python/issues/207 pytest isn't ready yet: https://github.com/pytest-dev/pytest/issues/8539 — committed to qutebrowser/qutebrowser by The-Compiler 3 years ago
- ci: Pin Python 3.10 to Alpha 7 See https://github.com/actions/setup-python/issues/207 pytest isn't ready yet: https://github.com/pytest-dev/pytest/issues/8539 (cherry picked from commit 0c1414c6aaa... — committed to qutebrowser/qutebrowser by The-Compiler 3 years ago
- Merge #73 73: Update pytest to 6.2.4 r=aragilar a=pyup-bot This PR updates [pytest](https://pypi.org/project/pytest) from **6.2.3** to **6.2.4**. <details> <summary>Changelog</summary> ... — committed to aragilar/stringtopy by bors[bot] 3 years ago
- Merge #211 #214 211: Update astroid to 2.5.6 r=YourLocalBlake a=pyup-bot This PR updates [astroid](https://pypi.org/project/astroid) from **2.5.2** to **2.5.6**. <details> <summary>Changelog</... — committed to pykoala/koala by bors[bot] 3 years ago
- Merge #19 #20 19: Update sphinx_rtd_theme to 0.5.2 r=aragilar a=pyup-bot This PR updates [sphinx_rtd_theme](https://pypi.org/project/sphinx_rtd_theme) from **0.5.0** to **0.5.2**. *The bot wasn'... — committed to aragilar/pytest-info-collector by bors[bot] 3 years ago
- Merge #20 20: Update pytest to 6.2.4 r=aragilar a=pyup-bot This PR updates [pytest](https://pypi.org/project/pytest) from **6.1.1** to **6.2.4**. <details> <summary>Changelog</summary> ... — committed to aragilar/pytest-info-collector by bors[bot] 3 years ago
- Merge #20 #23 20: Update pytest to 6.2.4 r=aragilar a=pyup-bot This PR updates [pytest](https://pypi.org/project/pytest) from **6.1.1** to **6.2.4**. <details> <summary>Changelog</summary> ... — committed to aragilar/pytest-info-collector by bors[bot] 3 years ago
- Add workaround pytest See: https://github.com/pytest-dev/pytest/issues/8539 — committed to sergeyklay/gstore by sergeyklay 3 years ago
- Fix workaround pytest See: https://github.com/pytest-dev/pytest/issues/8539 — committed to sergeyklay/gstore by sergeyklay 3 years ago
- Use pytest>=6.2.4 See: https://github.com/pytest-dev/pytest/issues/8539 — committed to sergeyklay/gstore by sergeyklay 3 years ago
- Add workaround pytest See: https://github.com/pytest-dev/pytest/issues/8539 — committed to sergeyklay/gstore by sergeyklay 3 years ago
- Fix workaround pytest See: https://github.com/pytest-dev/pytest/issues/8539 — committed to sergeyklay/gstore by sergeyklay 3 years ago
- Use pytest>=6.2.4 See: https://github.com/pytest-dev/pytest/issues/8539 — committed to sergeyklay/gstore by sergeyklay 3 years ago
- Merge #7 #8 7: Pin sphinx_rtd_theme to latest version 0.5.2 r=aragilar a=pyup-bot This PR pins [sphinx_rtd_theme](https://pypi.org/project/sphinx_rtd_theme) to the latest release **0.5.2**. *The... — committed to aragilar/spaceplot by bors[bot] 3 years ago
- Merge #18 #20 18: Pin pytest to latest version 6.2.4 r=aragilar a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **6.2.4**. <details> <summary>Changelog<... — committed to aragilar/spaceplot by bors[bot] 3 years ago
- Merge #16 16: Pin pytest to latest version 6.2.4 r=aragilar a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **6.2.4**. <details> <summary>Changelog</sum... — committed to aragilar/venv_tools by bors[bot] 3 years ago
- api: pytest 6.2.5じゃないとPython 3.10でテストできないのでバージョン上げる https://github.com/pytest-dev/pytest/issues/8539 — committed to kmc-jp/GodUploader-graphql by utgwkk 3 years ago
upgrade to 6.2.4 to get the fix!
Good news, the GitHub Actions weirdness has been resolved and latest pytest is working with
3.10-dev(example build from today). 🎈What happened:
Something caused a premature Python-3.10.0b1.tgz to be released on the Python FTP servers (now removed): https://www.python.org/ftp/python/3.10.0/Python-3.10.0b1.tgz.
GitHub Actions’ automation integrated this into
3.10-dev. This has also been removed and3.10-devnow points to the latest 3.10 alpha, in advance of next week’s real 3.10 beta release.More details:
Due to the GitHub Actions weirdness (https://github.com/pytest-dev/pytest/pull/8540#issuecomment-822330273), is there a plan to release pytest with a fix before the real 3.10 beta (due 2021-05-03), or do you recommend we pin 3.10 to an alpha on GHA? Thank you!
Taking the freedom to pin this issue due to https://github.com/pytest-dev/pytest/pull/8540#issuecomment-822330273
I’ve renamed the issue a bit to be less confusing.
as first enhancement assertion rewrite should raise a
ImportErrorthat tells the file at leastI’m still experiencing this issue in Python
3.10.4and pytest7.1.2It’s great that Actions has fixed their end of this (🎉), but unless we release a new version of pytest with #8540 soon we’ll be broken again when the real 3.10beta1 is released 😅
I’m OK with a prerelease, but we actually haven’t nailed down if the next release will be 7.0 or 6.3. We have a discussion about this: https://github.com/orgs/pytest-dev/teams/contributors/discussions/2
beta1 is out. can we please get (at least a pre-release) with this fix out?