pytest-dev / pytest-dev/pytest

short test summary info - empty cause sometimes

Open
#10,521 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: reporting
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

For some types of errors there doesn't seem to be a cause printed to terminal:

================================================================================================================================================== short test summary info ==================================================================================================================================================
FAILED xyz_test.py::TestXyzSuite::test_xyz[xyz]

Where normally there would be some description printed after that.

Trying to follow the code I end up in:
https://github.com/pytest-dev/pytest/blob/baada535a3e31ceb541a3e81319309a35bec934c/src/_pytest/terminal.py#L1310
which do:

        try:
             # Type ignored intentionally -- possible AttributeError expected.
             msg = rep.longrepr.reprcrash.message  # type: ignore[union-attr]
         except AttributeError:
             pass

I suspect the "pass" line above is when I don't get a cause printed?

Here I wonder why not call longrepr._getreprcrash() instead? From:
https://github.com/pytest-dev/pytest/blob/69f2855cc8896c67c499a250c2f08fcfd408f827/src/_pytest/_code/code.py#L605

And perhaps put the lines above in there instead?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/_pytest/terminal.py around the short test summary handling and compare it with _getreprcrash() in src/_pytest/_code/code.py. Reproduce an error whose short summary has no cause, then trace the longrepr representation path. Done means the summary includes the expected cause without breaking errors that lack a reprcrash message.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.