<#23426 pytest 9.1.0 breaks PEX runner: AttributeE...
# github-notifications
q
#23426 pytest 9.1.0 breaks PEX runner: AttributeError: module '_pytest.config' has no attribute '_console_main' Issue created by pmcguire-s44 Summary pytest 9.1.0 removed the private
_pytest.config._console_main
attribute, renaming it to the public
_pytest.config.console_main
. The Pants PEX-based pytest runner invokes pytest via its
console_scripts
entry point, which references
_pytest.config:_console_main
. This causes an
AttributeError
at test-run time with pytest ≥ 9.1. Error
Copy code
AttributeError: module '_pytest.config' has no attribute '_console_main'. Did you mean: 'console_main'?
Steps to reproduce 1. Use Pants 2.32.0 with a Python project that depends on
pytest>=9.1
. 2. Run
pants test ::
. Root cause pytest changed its console script entry point from
_pytest.config:_console_main
to
_pytest.config:console_main
in 9.1.0. The Pants PEX runner builds a PEX that hard-codes the old entry point name. Relevant pytest change: https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst Workaround Pin
pytest<9.1
in all project
pyproject.toml
files until Pants is updated to use the new entry point. Expected behavior Pants should invoke pytest via the public
console_main
entry point (or via
pytest.main()
) so that it works with pytest ≥ 9.1. Environment • Pants version: 2.32.0 • pytest version: 9.1.0 • Python: 3.13 pantsbuild/pants