From e8c220b9bd31924aa94f0410d3a6f0c50e9ab18d Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Mon, 15 Oct 2018 19:29:39 +0200 Subject: [PATCH] Increase required verbosity level for debug output To show the subclassed file in legacy test suits in the runtest output you have to set the verbosity level to at least "-vv" now. Closes #3211 --- changelog/4159.feature.rst | 3 +++ src/_pytest/terminal.py | 4 +++- testing/acceptance_test.py | 4 ++-- testing/test_terminal.py | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 changelog/4159.feature.rst diff --git a/changelog/4159.feature.rst b/changelog/4159.feature.rst new file mode 100644 index 000000000..28ca7462e --- /dev/null +++ b/changelog/4159.feature.rst @@ -0,0 +1,3 @@ +For test-suites containing test classes, the information about the subclassed +module is now output only if a higher verbosity level is specified (at least +"-vv"). diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index f4dbbe61a..8deb330cc 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -676,7 +676,9 @@ class TerminalReporter(object): if fspath: res = mkrel(nodeid).replace("::()", "") # parens-normalization - if nodeid.split("::")[0] != fspath.replace("\\", nodes.SEP): + if self.verbosity >= 2 and nodeid.split("::")[0] != fspath.replace( + "\\", nodes.SEP + ): res += " <- " + self.startdir.bestrelpath(fspath) else: res = "[location]" diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 2a6c75740..3dd56bf87 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -760,8 +760,8 @@ class TestInvocationVariants(object): if hasattr(py.path.local, "mksymlinkto"): result.stdout.fnmatch_lines( [ - "lib/foo/bar/test_bar.py::test_bar <- local/lib/foo/bar/test_bar.py PASSED*", - "lib/foo/bar/test_bar.py::test_other <- local/lib/foo/bar/test_bar.py PASSED*", + "lib/foo/bar/test_bar.py::test_bar PASSED*", + "lib/foo/bar/test_bar.py::test_other PASSED*", "*2 passed*", ] ) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 7651f3ab3..af2dc2f00 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -154,7 +154,7 @@ class TestTerminal(object): ) result = testdir.runpytest(p2) result.stdout.fnmatch_lines(["*test_p2.py .*", "*1 passed*"]) - result = testdir.runpytest("-v", p2) + result = testdir.runpytest("-vv", p2) result.stdout.fnmatch_lines( ["*test_p2.py::TestMore::test_p1* <- *test_p1.py*PASSED*"] ) @@ -170,7 +170,7 @@ class TestTerminal(object): """ ) ) - result = testdir.runpytest("-v") + result = testdir.runpytest("-vv") assert result.ret == 0 result.stdout.fnmatch_lines(["*a123/test_hello123.py*PASS*"]) assert " <- " not in result.stdout.str()