From d8c6c229895d3d5032e2f1bbb0377c92dc4b42b6 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Mon, 12 Nov 2018 13:31:19 -0800 Subject: [PATCH 1/6] Don't show node setup when running quiet --- xdist/dsession.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xdist/dsession.py b/xdist/dsession.py index be3ba77..5b2a302 100644 --- a/xdist/dsession.py +++ b/xdist/dsession.py @@ -344,8 +344,11 @@ class TerminalDistReporter(object): self.rewrite(self.getstatus()) def getstatus(self): - parts = ["%s %s" % (spec.id, self._status[spec.id]) for spec in self._specs] - return " / ".join(parts) + if self.config.option.verbose >= 0: + parts = ["%s %s" % (spec.id, self._status[spec.id]) for spec in self._specs] + return " / ".join(parts) + else: + return "bringing up nodes..." def rewrite(self, line, newline=False): pline = line + " " * max(self._lastlen - len(line), 0) From b819657dac19fffc0b44cbf84cd18009836063b8 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Mon, 12 Nov 2018 13:37:10 -0800 Subject: [PATCH 2/6] Add changelog entry --- changelog/373.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/373.feature.rst diff --git a/changelog/373.feature.rst b/changelog/373.feature.rst new file mode 100644 index 0000000..64a8eb0 --- /dev/null +++ b/changelog/373.feature.rst @@ -0,0 +1 @@ +Node setup information is hidden when pytest is run in quiet mode to reduce noise on many-core machines. \ No newline at end of file From 5465d936f79237665ffaeb8a44bf2b4140eac73a Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Mon, 12 Nov 2018 14:05:07 -0800 Subject: [PATCH 3/6] Add newline --- changelog/373.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/373.feature.rst b/changelog/373.feature.rst index 64a8eb0..5a11da4 100644 --- a/changelog/373.feature.rst +++ b/changelog/373.feature.rst @@ -1 +1 @@ -Node setup information is hidden when pytest is run in quiet mode to reduce noise on many-core machines. \ No newline at end of file +Node setup information is hidden when pytest is run in quiet mode to reduce noise on many-core machines. From 566480fdd3981a22f6f8c379a4a1cf0d397f8e3a Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Thu, 29 Nov 2018 00:25:30 -0800 Subject: [PATCH 4/6] Add test and silence completely --- testing/acceptance_test.py | 12 ++++++++++++ xdist/dsession.py | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index be4c7d8..deeafaa 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -358,6 +358,18 @@ class TestDistEach: class TestTerminalReporting: + def test_quiet_no_output(self, testdir): + testdir.makepyfile( + """ + def test_ok(): + pass + """ + ) + result = testdir.runpytest("-q") + result.stdout.fnmatch_lines( + [".*[100%]*", "*1*passed*"] + ) + def test_pass_skip_fail(self, testdir): testdir.makepyfile( """ diff --git a/xdist/dsession.py b/xdist/dsession.py index 5b2a302..8bb559c 100644 --- a/xdist/dsession.py +++ b/xdist/dsession.py @@ -229,9 +229,10 @@ class DSession(object): if self.terminal and not self.sched.has_pending: self.trdist.ensure_show_status() self.terminal.write_line("") - self.terminal.write_line( - "scheduling tests via %s" % (self.sched.__class__.__name__) - ) + if self.config.option.verbose > 0: + self.terminal.write_line( + "scheduling tests via %s" % (self.sched.__class__.__name__) + ) self.sched.schedule() def worker_logstart(self, node, nodeid, location): From 49c09117ed510425a82a11a7a4ed207070358636 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Thu, 29 Nov 2018 00:55:33 -0800 Subject: [PATCH 5/6] Fix lint --- testing/acceptance_test.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index deeafaa..d7a1d7c 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -366,9 +366,7 @@ class TestTerminalReporting: """ ) result = testdir.runpytest("-q") - result.stdout.fnmatch_lines( - [".*[100%]*", "*1*passed*"] - ) + result.stdout.fnmatch_lines([".*[100%]*", "*1*passed*"]) def test_pass_skip_fail(self, testdir): testdir.makepyfile( From 3332c99e1ee1ef65f84e2c7e39c6b72ed2424aff Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 11 Dec 2018 14:34:39 -0200 Subject: [PATCH 6/6] Improve verbosity test --- testing/acceptance_test.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index d7a1d7c..e4bccaf 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -358,15 +358,29 @@ class TestDistEach: class TestTerminalReporting: - def test_quiet_no_output(self, testdir): + @pytest.mark.parametrize("verbosity", ["", "-q", "-v"]) + def test_output_verbosity(self, testdir, verbosity): testdir.makepyfile( """ def test_ok(): pass """ ) - result = testdir.runpytest("-q") - result.stdout.fnmatch_lines([".*[100%]*", "*1*passed*"]) + args = ["-n1"] + if verbosity: + args.append(verbosity) + result = testdir.runpytest(*args) + out = result.stdout.str() + if verbosity == "-v": + assert "scheduling tests" in out + assert "gw" in out + elif verbosity == "-q": + assert "scheduling tests" not in out + assert "gw" not in out + assert "bringing up nodes..." in out + else: + assert "scheduling tests" not in out + assert "gw" in out def test_pass_skip_fail(self, testdir): testdir.makepyfile(