Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.2.3 broke interaction with pytest-reportlog (INTERNALERROR) #173

Closed
bmerry opened this issue Jan 28, 2025 · 2 comments
Closed

Comments

@bmerry
Copy link

bmerry commented Jan 28, 2025

Pytest-check 2.2.3 seems to have introduced a change that causes an internal error when combined with pytest-reportlog. This seems like it might be related to #155.

Steps to reproduce:

  • pip install pytest==8.3.4 pytest-check==2.4.1 pytest-reportlog==0.4.0 (these are latest at time of writing)
  • Create a file testit.py with the content below.
  • Run pytest testit.py --report-log test.json

Test code:

from pytest_check import check

def test_stuff():
    with check:
        assert 1 == 2

Output:

======================================= test session starts ========================================
platform linux -- Python 3.12.3, pytest-8.3.4, pluggy-1.5.0
rootdir: /home/bmerry/work/bugs/pytest-check-internalerror
plugins: reportlog-0.4.0, check-2.4.1
collected 1 item                                                                                   

testit.py F
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/main.py", line 283, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/main.py", line 337, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/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 "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/logging.py", line 803, in pytest_runtestloop
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/terminal.py", line 673, in pytest_runtestloop
INTERNALERROR>     result = yield
INTERNALERROR>              ^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/main.py", line 362, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/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 "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/warnings.py", line 112, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/assertion/__init__.py", line 176, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/unittest.py", line 429, in pytest_runtest_protocol
INTERNALERROR>     res = yield
INTERNALERROR>           ^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/faulthandler.py", line 88, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/runner.py", line 113, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/runner.py", line 132, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/runner.py", line 246, in call_and_report
INTERNALERROR>     ihook.pytest_runtest_logreport(report=report)
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/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 "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pytest_reportlog/plugin.py", line 89, in pytest_runtest_logreport
INTERNALERROR>     data = self._config.hook.pytest_report_to_serializable(
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/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 "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/reports.py", line 462, in pytest_report_to_serializable
INTERNALERROR>     data = report._to_json()
INTERNALERROR>            ^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/reports.py", line 224, in _to_json
INTERNALERROR>     return _report_to_json(self)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/reports.py", line 543, in _report_to_json
INTERNALERROR>     d["longrepr"] = serialize_exception_longrepr(report)
INTERNALERROR>                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/reports.py", line 521, in serialize_exception_longrepr
INTERNALERROR>     "reprtraceback": serialize_repr_traceback(longrepr.reprtraceback),
INTERNALERROR>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/bmerry/.pyenv/versions/pytest-check-bug/lib/python3.12/site-packages/_pytest/reports.py", line 501, in serialize_repr_traceback
INTERNALERROR>     result = dataclasses.asdict(reprtraceback)
INTERNALERROR>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.12/dataclasses.py", line 1322, in asdict
INTERNALERROR>     return _asdict_inner(obj, dict_factory)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.12/dataclasses.py", line 1332, in _asdict_inner
INTERNALERROR>     f.name: _asdict_inner(getattr(obj, f.name), dict)
INTERNALERROR>             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.12/dataclasses.py", line 1332, in _asdict_inner
INTERNALERROR>     f.name: _asdict_inner(getattr(obj, f.name), dict)
INTERNALERROR>             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.12/dataclasses.py", line 1366, in _asdict_inner
INTERNALERROR>     return type(obj)(_asdict_inner(v, dict_factory) for v in obj)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.12/dataclasses.py", line 1366, in <genexpr>
INTERNALERROR>     return type(obj)(_asdict_inner(v, dict_factory) for v in obj)
INTERNALERROR>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.12/dataclasses.py", line 1379, in _asdict_inner
INTERNALERROR>     return copy.deepcopy(obj)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.12/copy.py", line 151, in deepcopy
INTERNALERROR>     rv = reductor(4)
INTERNALERROR>          ^^^^^^^^^^^
INTERNALERROR> TypeError: cannot pickle 'traceback' object

======================================== 1 failed in 0.01s =========================================

Output from pytest-check 2.2.2:

======================================= test session starts ========================================
platform linux -- Python 3.12.3, pytest-8.3.4, pluggy-1.5.0
rootdir: /home/bmerry/work/bugs/pytest-check-internalerror
plugins: reportlog-0.4.0, check-2.2.2
collected 1 item                                                                                   

testit.py F                                                                                  [100%]

============================================= FAILURES =============================================
____________________________________________ test_stuff ____________________________________________
FAILURE: assert 1 == 2
testit.py:5 in test_stuff() -> with check:
testit.py:6 in test_stuff -> assert 1 == 2
AssertionError: assert 1 == 2


------------------------------------------------------------
Failed Checks: 1
------------------------------- generated report log file: test.json -------------------------------
===================================== short test summary info ======================================
FAILED testit.py::test_stuff
======================================== 1 failed in 0.01s =========================================
bmerry added a commit to ska-sa/katgpucbf that referenced this issue Jan 28, 2025
Newer versions of pytest-check don't play nice with pytest-reportlog:
okken/pytest-check#173
@okken
Copy link
Owner

okken commented Feb 9, 2025

Maybe an issue with pytest-reportlog? I'm not sure.
I don't guarantee this plugin works with all other plugins.
However, if you have a fix for this, I'd consider a pull request

@okken okken closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2025
@bmerry
Copy link
Author

bmerry commented Feb 9, 2025

@okken would you accept a PR that adds an ini file option to disable the problematic feature? i.e. to override the logic in this if statement so that users of other plugins that serialize longrepr can disable it, not just xdist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants