Skip to content

gh-91289: Reformat the text output of unittest - #121704

Open
ziima wants to merge 6 commits into
python:mainfrom
ziima:gh-91289-unittest-text-output
Open

ziima wants to merge 6 commits into
python:mainfrom
ziima:gh-91289-unittest-text-output

Conversation

@ziima

@ziima ziima commented Jul 13, 2024 •

Copy link
Copy Markdown
Contributor

Fixed at EuroPython 24 sprints.

Based on the discussions at #91289 and EuroPython 24 sprints, I reformatted the text output of unittests to a single line for each test.

Example output:

This is an error docstring. (test_docstring.Foo.test_error) ... ERROR
test_docstring.Foo.test_error_no_doc ... ERROR
This is OK docstring. (test_docstring.Foo.test_ok) ... ok
test_docstring.Foo.test_ok_no_doc ... ok

======================================================================
ERROR: This is an error docstring. (test_docstring.Foo.test_error)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pokus_unittest/test_docstring.py", line 9, in test_error
    raise Exception('Gazpacho!')
Exception: Gazpacho!

======================================================================
ERROR: test_docstring.Foo.test_error_no_doc
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pokus_unittest/test_docstring.py", line 26, in test_error_no_doc
    raise Exception('Gazpacho!')
Exception: Gazpacho!

----------------------------------------------------------------------
Ran 4 tests in 0.004s

FAILED (errors=2)

The line contains docstring if conditions are met and removes the duplicate name of test method. It produces longer lines, but I think this is acceptable

Closes #91289

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhance unittest to show test name and docstring on one line

4 participants