Skip to content

line is not None assertion in reports.py failing in jaraco.test, since pytest 8.4, on Python 3.12 #14700

Description

@mgorny
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

When running the test suite of jaraco.test 5.7.0 from sdist (or git, but after removing .git directory) on Python 3.12.13, I'm hitting the following pytest assertion:

$ pytest -vv jaraco/test/git.py 
========================================================= test session starts =========================================================
platform linux -- Python 3.12.13, pytest-9.2.0.dev48+gefc013416, pluggy-1.6.0 -- /tmp/jaraco.test/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/jaraco.test
configfile: pytest.ini
plugins: jaraco.test-5.7.0, pytest_freezer-0.4.9
collected 2 items                                                                                                                     

jaraco/test/git.py::jaraco.test.git.ensure_checkout 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/main.py", line 330, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/main.py", line 384, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/logging.py", line 816, in pytest_runtestloop
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/terminal.py", line 708, in pytest_runtestloop
INTERNALERROR>     result = yield
INTERNALERROR>              ^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/main.py", line 408, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/warnings.py", line 90, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/assertion/__init__.py", line 205, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/unittest.py", line 612, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/faulthandler.py", line 102, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 118, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 139, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 254, in call_and_report
INTERNALERROR>     report: TestReport = ihook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/tmpdir.py", line 347, in pytest_runtest_makereport
INTERNALERROR>     rep = yield
INTERNALERROR>           ^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     teardown.throw(exception)
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/skipping.py", line 280, in pytest_runtest_makereport
INTERNALERROR>     rep = yield
INTERNALERROR>           ^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 385, in pytest_runtest_makereport
INTERNALERROR>     return TestReport.from_item_and_call(item, call)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/tmp/jaraco.test/.venv/lib/python3.12/site-packages/_pytest/reports.py", line 420, in from_item_and_call
INTERNALERROR>     assert line is not None
INTERNALERROR>            ^^^^^^^^^^^^^^^^
INTERNALERROR> AssertionError

======================================================== no tests ran in 0.02s ========================================================

From a quick check, downgrading down to pytest==8.3.5 makes tests work (the test is skipped), while 8.4.0 and newer all raise. I've tested up to git: pytest==9.2.0.dev48+gefc013416. This seems to happen only on Python 3.12, 3.13 and newer work.

$ uv pip list
Package            Version                Editable project location
------------------ ---------------------- -------------------------
annotated-doc      0.0.4
freezegun          1.5.5
iniconfig          2.3.0
jaraco-collections 5.2.1
jaraco-context     6.1.2
jaraco-functools   4.5.0
jaraco-test        5.7.0                  /tmp/jaraco.test
jaraco-text        4.3.0
markdown-it-py     4.2.0
mdurl              0.1.2
more-itertools     11.1.0
packaging          26.2
pluggy             1.6.0
pygments           2.20.0
pytest             9.2.0.dev48+gefc013416
pytest-freezer     0.4.9
python-dateutil    2.9.0.post0
rich               15.0.0
shellingham        1.5.4
six                1.17.0
typer              0.26.8
typer-slim         0.24.0

Gentoo Linux amd64.

I wasn't able to build a trivial reproducer — I suspect it has something to do with all that context magic done in that package.

To reproduce:

git clone https://github.com/jaraco/jaraco.test
cd jaraco.test
uv venv -p 3.12
uv pip install -e . pytest
rm -rf .git
pytest -vv jaraco/test/git.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions