-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Improve verbose output by wrapping skip/xfail reasons with margin #10958
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Improved verbose output (``-vv``) of ``skip`` and ``xfail`` reasons by performing text wrapping while leaving a clear margin for progress output. | ||
|
||
Added :func:`TerminalReporter.wrap_write() <pytest.TerminalReporter.wrap_write>` as a helper for that. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -387,13 +387,13 @@ def test_10(): | |
pytest.xfail("It's 🕙 o'clock") | ||
|
||
@pytest.mark.skip( | ||
reason="cannot do foobar because baz is missing due to I don't know what" | ||
reason="1 cannot do foobar because baz is missing due to I don't know what" | ||
) | ||
def test_long_skip(): | ||
pass | ||
|
||
@pytest.mark.xfail( | ||
reason="cannot do foobar because baz is missing due to I don't know what" | ||
reason="2 cannot do foobar because baz is missing due to I don't know what" | ||
) | ||
def test_long_xfail(): | ||
print(1 / 0) | ||
|
@@ -417,8 +417,8 @@ def test_long_xfail(): | |
result.stdout.fnmatch_lines( | ||
common_output | ||
+ [ | ||
"test_verbose_skip_reason.py::test_long_skip SKIPPED (cannot *...) *", | ||
"test_verbose_skip_reason.py::test_long_xfail XFAIL (cannot *...) *", | ||
"test_verbose_skip_reason.py::test_long_skip SKIPPED (1 cannot *...) *", | ||
"test_verbose_skip_reason.py::test_long_xfail XFAIL (2 cannot *...) *", | ||
] | ||
) | ||
|
||
|
@@ -428,12 +428,14 @@ def test_long_xfail(): | |
+ [ | ||
( | ||
"test_verbose_skip_reason.py::test_long_skip SKIPPED" | ||
" (cannot do foobar because baz is missing due to I don't know what) *" | ||
" (1 cannot do foobar" | ||
), | ||
"because baz is missing due to I don't know what) *", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for taking a look.
The test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh right, sorry I missed that, thanks for the explanation. 👍 |
||
( | ||
"test_verbose_skip_reason.py::test_long_xfail XFAIL" | ||
" (cannot do foobar because baz is missing due to I don't know what) *" | ||
" (2 cannot do foobar" | ||
), | ||
"because baz is missing due to I don't know what) *", | ||
] | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure "wrap" is appropriated, given "wrap" in this contents is to preserve the text, but wrapping it around at certain width (for example 70). I think what we are doing here is actually truncating, so perhaps
truncate_write
or something would be more appropriate?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to rename to whatever, but in this case, the new method is only wrapping text. The truncated output you saw was unmodified behavior due to the test testing multiple outputs.
I'm not particularly satisfied with the name because I'm not sure that it feels sufficiently conventional. Perhaps
write_wrapped_text
or something similar would be better?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I misunderstood the output hence my misguided suggestion.
wrap_write
is fine, thanks! 👍