adopted suggested changes, made testcase
This commit is contained in:
parent
2061e2968c
commit
14bf4974b5
|
@ -1 +0,0 @@
|
|||
Added support for verbosity setting in the short test summary info, so that when -vv is enabled, longer text will be printed out.
|
|
@ -0,0 +1 @@
|
|||
Text is no longer truncated in the ``short test summary info`` section when ``-vv`` is given.
|
|
@ -1408,14 +1408,11 @@ def _get_line_with_reprcrash_message(
|
|||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
if not running_on_ci():
|
||||
if isinstance(config, Config) and config.option.verbose >= 2:
|
||||
available_width = 500
|
||||
else:
|
||||
available_width = tw.fullwidth - line_width
|
||||
msg = _format_trimmed(" - {}", msg, available_width)
|
||||
else:
|
||||
if running_on_ci() or config.option.verbose >= 2:
|
||||
msg = f" - {msg}"
|
||||
else:
|
||||
available_width = tw.fullwidth - line_width
|
||||
msg = _format_trimmed(" - {}", msg, available_width)
|
||||
if msg is not None:
|
||||
line += msg
|
||||
|
||||
|
|
|
@ -2443,6 +2443,75 @@ def test_line_with_reprcrash(monkeypatch: MonkeyPatch) -> None:
|
|||
check("🉐🉐🉐🉐🉐\n2nd line", 80, "FAILED nodeid::🉐::withunicode - 🉐🉐🉐🉐🉐")
|
||||
|
||||
|
||||
def test_short_summary_with_verbose(monkeypatch: MonkeyPatch) -> None:
|
||||
mocked_verbose_word = "FAILED"
|
||||
|
||||
mocked_pos = "some::nodeid"
|
||||
|
||||
def mock_running_on_ci():
|
||||
return False
|
||||
|
||||
def mock_get_pos(*args):
|
||||
return mocked_pos
|
||||
|
||||
monkeypatch.setattr(_pytest.terminal, "_get_node_id_with_markup", mock_get_pos)
|
||||
monkeypatch.setattr(_pytest.terminal, "running_on_ci", mock_running_on_ci)
|
||||
|
||||
class Namespace:
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update(kwargs)
|
||||
|
||||
class config:
|
||||
def __init__(self):
|
||||
object.__setattr__(self, "option", Namespace(verbose=2))
|
||||
|
||||
class rep:
|
||||
def _get_verbose_word(self, *args):
|
||||
return mocked_verbose_word
|
||||
|
||||
class longrepr:
|
||||
class reprcrash:
|
||||
pass
|
||||
|
||||
def check(msg, width, expected):
|
||||
class DummyTerminalWriter:
|
||||
fullwidth = width
|
||||
|
||||
def markup(self, word: str, **markup: str):
|
||||
return word
|
||||
|
||||
__tracebackhide__ = True
|
||||
if msg:
|
||||
rep.longrepr.reprcrash.message = msg # type: ignore
|
||||
actual = _get_line_with_reprcrash_message(
|
||||
config(), # type: ignore[arg-type]
|
||||
rep(), # type: ignore[arg-type]
|
||||
DummyTerminalWriter(), # type: ignore[arg-type]
|
||||
{},
|
||||
)
|
||||
|
||||
assert actual == expected
|
||||
|
||||
# AttributeError with message
|
||||
check(None, 80, "FAILED some::nodeid")
|
||||
|
||||
check("msg", 80, "FAILED some::nodeid - msg")
|
||||
check("msg", 3, "FAILED some::nodeid - msg")
|
||||
|
||||
check("some longer msg", 10, "FAILED some::nodeid - some longer msg")
|
||||
|
||||
check("some\nmessage", 25, "FAILED some::nodeid - some\nmessage")
|
||||
check("some\nmessage", 80, "FAILED some::nodeid - some\nmessage")
|
||||
|
||||
# Test unicode safety.
|
||||
check("🉐🉐🉐🉐🉐\n2nd line", 29, "FAILED some::nodeid - 🉐🉐🉐🉐🉐\n2nd line")
|
||||
|
||||
# NOTE: constructed, not sure if this is supported.
|
||||
mocked_pos = "nodeid::🉐::withunicode"
|
||||
check("🉐🉐🉐🉐🉐\n2nd line", 29, "FAILED nodeid::🉐::withunicode - 🉐🉐🉐🉐🉐\n2nd line")
|
||||
check("🉐🉐🉐🉐🉐\n2nd line", 80, "FAILED nodeid::🉐::withunicode - 🉐🉐🉐🉐🉐\n2nd line")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"seconds, expected",
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue