Skip to content

Error location / crash entry missing from non-native tracebacks (due to generator / early setup?) #6657

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

Open
blueyed opened this issue Feb 2, 2020 · 0 comments · May be fixed by blueyed/pytest#266
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed

Comments

@blueyed
Copy link
Contributor

blueyed commented Feb 2, 2020

With the following:

diff --git i/src/_pytest/logging.py w/src/_pytest/logging.py
index df0da3daa..2e5d0cfc0 100644
--- i/src/_pytest/logging.py
+++ w/src/_pytest/logging.py
@@ -639,6 +639,7 @@ def _runtest_for_main(self, item, when):
             if self.print_logs:
                 # Add a captured log section to the report.
                 log = log_handler.stream.getvalue().strip()
+                assert 0, log
                 item.add_report_section(when, "log", log)

     @pytest.hookimpl(hookwrapper=True)

And running pytest testing/test_capture.py -k test_capture_with_live_logging you will get:

============== test session starts ===============
platform linux -- Python 3.8.1, pytest-5.3.3.dev50+gca8a1e47b, py-1.8.2.dev4+g9d3c8be7.d20200128, pluggy-0.13.2.dev5+g76838b1
…
collected 1 item

testing/test_capture.py EE                 [100%]

===================== ERRORS =====================
_ ERROR at setup of test_capture_with_live_logging[capfd] _
/usr/lib/python3.8/contextlib.py:120: in __exit__
    next(self.gen)
/usr/lib/python3.8/contextlib.py:120: in __exit__
    next(self.gen)
E   AssertionError
_ ERROR at teardown of test_capture_with_live_logging[capfd] _
/usr/lib/python3.8/contextlib.py:120: in __exit__
    next(self.gen)
/usr/lib/python3.8/contextlib.py:120: in __exit__
    next(self.gen)
E   AssertionError
============ short test summary info =============
ERROR testing/test_capture.py::test_capture_with_live_logging[capfd]
ERROR testing/test_capture.py::test_capture_with_live_logging[capfd]
=============== 2 errors in 0.10s ================

I.e. the location for the assertion error is wrong / not included.

With --tb=native:

===================== ERRORS =====================
_ ERROR at setup of test_capture_with_live_logging[capfd] _
Traceback (most recent call last):
  File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "…/Vcs/pytest/src/_pytest/logging.py", line 613, in _runtest_for
    yield
  File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "…/Vcs/pytest/src/_pytest/logging.py", line 642, in _runtest_for_main
    assert 0, log
AssertionError
_ ERROR at teardown of test_capture_with_live_logging[capfd] _
Traceback (most recent call last):
  File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "…/Vcs/pytest/src/_pytest/logging.py", line 613, in _runtest_for
    yield
  File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "…/Vcs/pytest/src/_pytest/logging.py", line 642, in _runtest_for_main
    assert 0, log
AssertionError
============ short test summary info =============
ERROR testing/test_capture.py::test_capture_with_live_logging[capfd]
ERROR testing/test_capture.py::test_capture_with_live_logging[capfd]

This is likely due to this happening during setup, and that pytest filters itself out of it, but the actual errors location should be included always probably?

@blueyed blueyed added type: bug problem that needs to be addressed topic: reporting related to terminal output and user-facing messages and errors labels Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant