pytest2/testing
Pavel Březina 41ca4dd44e testresult: correctly apply verbose word markup and avoid crash
The following snippet would have resulted in crash on multiple places since
`_get_verbose_word` expects only string, not a tuple.

```python
    @pytest.hookimpl(tryfirst=True)
    def pytest_report_teststatus(report: pytest.CollectReport | pytest.TestReport, config: pytest.Config):
        if report.when == "call":
            return ("error", "A",  ("AVC", {"bold": True, "red": True}))

        return None
```

```
Traceback (most recent call last):
  File "/home/pbrezina/workspace/sssd/.venv/bin/pytest", line 8, in <module>
    sys.exit(console_main())
             ^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/config/__init__.py", line 207, in console_main
    code = main()
           ^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/config/__init__.py", line 179, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/main.py", line 333, in pytest_cmdline_main
    return wrap_session(config, _main)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/main.py", line 321, in wrap_session
    config.hook.pytest_sessionfinish(
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/logging.py", line 872, in pytest_sessionfinish
    return (yield)
            ^^^^^
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_callers.py", line 124, in _multicall
    teardown.send(result)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/terminal.py", line 899, in pytest_sessionfinish
    self.config.hook.pytest_terminal_summary(
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/home/pbrezina/workspace/sssd/.venv/lib64/python3.11/site-packages/pluggy/_callers.py", line 124, in _multicall
    teardown.send(result)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/terminal.py", line 923, in pytest_terminal_summary
    self.short_test_summary()
  File "/home/pbrezina/workspace/pytest/src/_pytest/terminal.py", line 1272, in short_test_summary
    action(lines)
  File "/home/pbrezina/workspace/pytest/src/_pytest/terminal.py", line 1205, in show_simple
    line = _get_line_with_reprcrash_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/terminal.py", line 1429, in _get_line_with_reprcrash_message
    word = tw.markup(verbose_word, **word_markup)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pbrezina/workspace/pytest/src/_pytest/_io/terminalwriter.py", line 114, in markup
    text = "".join(f"\x1b[{cod}m" for cod in esc) + text + "\x1b[0m"
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
TypeError: can only concatenate str (not "tuple") to str
```

Signed-off-by: Pavel Březina <pbrezina@redhat.com>
2024-07-01 13:23:53 +02:00
..
_py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
code RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
example_scripts RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
examples RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
freeze RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
io RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
logging RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
plugins_integration RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
python RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
acceptance_test.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
conftest.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
deprecated_test.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_argcomplete.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_assertion.py Merge pull request #12467 from RonnyPfannschmidt/ronny/new-annotations-try-2 2024-06-21 10:24:56 +02:00
test_assertrewrite.py refactor: simplify bound method representation (#12492) 2024-06-21 18:20:44 +02:00
test_cacheprovider.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_capture.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_collection.py Support venv detection on Windows with mingw Python (#12545) 2024-06-29 00:30:51 +03:00
test_compat.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_config.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_conftest.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_debugging.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_doctest.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_entry_points.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_error_diffs.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_faulthandler.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_findpaths.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_helpconfig.py Merge pull request #12467 from RonnyPfannschmidt/ronny/new-annotations-try-2 2024-06-21 10:24:56 +02:00
test_junitxml.py junitxml: add timezone to testsuite timestamp (#12491) 2024-06-27 09:41:02 -03:00
test_legacypath.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_link_resolve.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_main.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_mark.py chore: remove obsolete `TODO`s 2024-06-25 09:18:18 +02:00
test_mark_expression.py chore: remove obsolete `TODO`s 2024-06-25 09:18:18 +02:00
test_meta.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_monkeypatch.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_nodes.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_parseopt.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_pastebin.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_pathlib.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_pluginmanager.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_pytester.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_python_path.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_recwarn.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_reports.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_runner.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_runner_xunit.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_scope.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_session.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_setuponly.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_setupplan.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_skipping.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_stash.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_stepwise.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_terminal.py testresult: correctly apply verbose word markup and avoid crash 2024-07-01 13:23:53 +02:00
test_threadexception.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_tmpdir.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_unittest.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_unraisableexception.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_warning_types.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
test_warnings.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00
typing_checks.py RFC: from __future__ import annotations + migrate 2024-06-20 11:03:03 +02:00