Skip to content

Pytest 7.0.0 new internal error #9637

@software-dov

Description

@software-dov

Just encountered this in CI for the Proto Plus repository: https://github.com/googleapis/proto-plus-python/runs/5097769407?check_suite_focus=true

Was able to reproduce locally

gnox > Running session unit-3.9
nox > Creating virtual environment (virtualenv) using python3.9 in .nox/unit-3-9
nox > python -m pip install coverage pytest pytest-cov pytz
nox > python -m pip install -e '.[testing]' -c /home/$USER/code/proto-plus-python/testing/constraints-3.9.txt
nox > py.test -W=error --quiet --cov=proto --cov-config=.coveragerc --cov-report=term --cov-report=html tests/
...................INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/main.py", line 268, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/main.py", line 322, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_callers.py", line 55, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/main.py", line 347, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/runner.py", line 113, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/runner.py", line 132, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/runner.py", line 223, in call_and_report
INTERNALERROR>     report: TestReport = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_callers.py", line 55, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/skipping.py", line 265, in pytest_runtest_makereport
INTERNALERROR>     rep = outcome.get_result()
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/runner.py", line 367, in pytest_runtest_makereport
INTERNALERROR>     return TestReport.from_item_and_call(item, call)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/reports.py", line 344, in from_item_and_call
INTERNALERROR>     longrepr = item.repr_failure(excinfo)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/python.py", line 1752, in repr_failure
INTERNALERROR>     return self._repr_failure_py(excinfo, style=style)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/nodes.py", line 447, in _repr_failure_py
INTERNALERROR>     self._prunetraceback(excinfo)
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/python.py", line 1725, in _prunetraceback
INTERNALERROR>     code = _pytest._code.Code.from_function(get_real_func(self.obj))
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/_code/code.py", line 70, in from_function
INTERNALERROR>     return cls(getrawcode(obj))
INTERNALERROR>   File "/home/$USER/code/proto-plus-python/.nox/unit-3-9/lib/python3.9/site-packages/_pytest/_code/source.py", line 139, in getrawcode
INTERNALERROR>     raise TypeError(f"could not get code object for {obj!r}")
INTERNALERROR> TypeError: could not get code object for <staticmethod object at 0x7fee78355970>

19 passed in 0.61s
nox > Command py.test -W=error --quiet --cov=proto --cov-config=.coveragerc --cov-report=term --cov-report=html tests/ failed with exit code 3
nox > Session unit-3.9 failed.

Differential diagnosis shows that everything is fine on pytest 6.2.5 but deterministically fails on 7.0.0
Python version used for manual reproduction is 3.9.7, but the failing CI linked above indicates that other versions hit this issue too.
CI tasks and local OS are all on Ubuntu-latest AMD64.

Output of pip list:

> pip list
Package    Version
---------- -------
attrs      21.4.0
coverage   6.3.1
iniconfig  1.1.1
packaging  21.3
pip        21.3.1
pluggy     1.0.0
py         1.11.0
pyparsing  3.0.7
pytest     7.0.0
pytest-cov 3.0.0
pytz       2021.3
setuptools 60.5.0
tomli      2.0.0
wheel      0.37.1

Will try to make a minimum viable reproduction in a bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions