From 67878775092dbe358198620332edd307f02a2cf6 Mon Sep 17 00:00:00 2001 From: Tim Sampson Date: Wed, 19 Apr 2023 16:46:47 +0300 Subject: [PATCH] terminal: include markers in `--collect-only` output Closes #1509 --- AUTHORS | 1 + changelog/1509.improvement.rst | 1 + src/_pytest/terminal.py | 8 +++++++- testing/test_cacheprovider.py | 12 ++++++------ 4 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 changelog/1509.improvement.rst diff --git a/AUTHORS b/AUTHORS index 353489b6c..052c15a2d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -387,6 +387,7 @@ Terje Runde Thomas Grainger Thomas Hisch Tim Hoffmann +Tim Sampson Tim Strazny TJ Bruno Tobias Diez diff --git a/changelog/1509.improvement.rst b/changelog/1509.improvement.rst new file mode 100644 index 000000000..60bac8482 --- /dev/null +++ b/changelog/1509.improvement.rst @@ -0,0 +1 @@ +A comma-separated list of markers for each test will be included in the output of `--collect-only` when called with `--verbosity=-1`. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index b91a97221..7fcffcd69 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -826,7 +826,13 @@ class TerminalReporter: self._tw.line("%s: %d" % (name, count)) else: for item in items: - self._tw.line(item.nodeid) + marks = { + m.name + for m in item.iter_markers() + if m.name not in ["usefixtures", "parametrize"] + } + marks_str = f" marks: {','.join(marks)}" + self._tw.line(f"{item.nodeid}{marks_str}") return stack: List[Node] = [] indent = "" diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 21c1957cf..d62f44d26 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -1154,9 +1154,9 @@ class TestNewFirst: result = pytester.runpytest("--nf", "--collect-only", "-q") result.stdout.fnmatch_lines( [ - "test_1/test_1.py::test_2", - "test_2/test_2.py::test_1", - "test_1/test_1.py::test_1", + "test_1/test_1.py::test_2 marks: ", + "test_2/test_2.py::test_1 marks: ", + "test_1/test_1.py::test_1 marks: ", ] ) @@ -1173,9 +1173,9 @@ class TestNewFirst: result.stdout.fnmatch_lines( [ "new_items: *test_1.py*test_1.py*test_2.py*", - "test_1/test_1.py::test_2", - "test_2/test_2.py::test_1", - "test_1/test_1.py::test_1", + "test_1/test_1.py::test_2 marks: ", + "test_2/test_2.py::test_1 marks: ", + "test_1/test_1.py::test_1 marks: ", ] )