From 32a29138fc33c4e2b34dc4583ae4867add0a0048 Mon Sep 17 00:00:00 2001 From: Tom Boshoven Date: Wed, 11 Sep 2019 19:47:16 -0400 Subject: [PATCH 1/4] Fix issues related to running xdist with the terminal plugin disabled This fixes an issue where the pytest plugin manager returns None if a plugin is not loaded instead of raising an error. It also makes terminal optional in plugin code. --- src/xdist/dsession.py | 7 ++----- src/xdist/plugin.py | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/xdist/dsession.py b/src/xdist/dsession.py index 5e91057..04e9f13 100644 --- a/src/xdist/dsession.py +++ b/src/xdist/dsession.py @@ -49,11 +49,8 @@ class DSession(object): self._max_worker_restart = get_default_max_worker_restart(self.config) # summary message to print at the end of the session self._summary_report = None - try: - self.terminal = config.pluginmanager.getplugin("terminalreporter") - except KeyError: - self.terminal = None - else: + self.terminal = config.pluginmanager.getplugin("terminalreporter") + if self.terminal: self.trdist = TerminalDistReporter(config) config.pluginmanager.register(self.trdist, "terminaldistreporter") diff --git a/src/xdist/plugin.py b/src/xdist/plugin.py index 9f1f7dd..4a0488e 100644 --- a/src/xdist/plugin.py +++ b/src/xdist/plugin.py @@ -170,7 +170,8 @@ def pytest_configure(config): session = DSession(config) config.pluginmanager.register(session, "dsession") tr = config.pluginmanager.getplugin("terminalreporter") - tr.showfspath = False + if tr: + tr.showfspath = False if config.getoption("boxed"): config.option.forked = True From 0b0de014ecacd86583ac1846c63ea9be2e417d08 Mon Sep 17 00:00:00 2001 From: Tom Boshoven Date: Wed, 11 Sep 2019 19:56:17 -0400 Subject: [PATCH 2/4] Add changelog. --- changelog/467.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/467.bugfix.rst diff --git a/changelog/467.bugfix.rst b/changelog/467.bugfix.rst new file mode 100644 index 0000000..5345c02 --- /dev/null +++ b/changelog/467.bugfix.rst @@ -0,0 +1 @@ +Fix crash issues related to running xdist with the terminal plugin disabled. From 8cbbbe1a2a997eccd09cb6995af22488e877223c Mon Sep 17 00:00:00 2001 From: Tom Boshoven Date: Thu, 12 Sep 2019 10:32:20 -0400 Subject: [PATCH 3/4] Add another no:terminal fix and add a test. --- src/xdist/workermanage.py | 5 ++++- testing/acceptance_test.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/xdist/workermanage.py b/src/xdist/workermanage.py index 0947972..d95b481 100644 --- a/src/xdist/workermanage.py +++ b/src/xdist/workermanage.py @@ -112,7 +112,10 @@ class NodeManager(object): ignores += self.config.option.rsyncignore ignores += self.config.getini("rsyncignore") - return {"ignores": ignores, "verbose": self.config.option.verbose} + return { + "ignores": ignores, + "verbose": getattr(self.config.option, "verbose", False), + } def rsync(self, gateway, source, notify=None, verbose=False, ignores=None): """Perform rsync to remote hosts for node.""" diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index c7c739f..9476499 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1074,6 +1074,21 @@ def test_color_yes_collection_on_non_atty(testdir, request): assert "gw0 C / gw1 C" not in result.stdout.str() +def test_without_terminal_plugin(testdir, request): + """ + No output when terminal plugin is disabled + """ + testdir.makepyfile( + """ + def test_1(): + pass + """ + ) + result = testdir.runpytest("-p", "no:terminal", "-n2") + assert result.stdout.str() == "" + assert result.stderr.str() == "" + + def test_internal_error_with_maxfail(testdir): """ Internal error when using --maxfail option (#62, #65). From ddc52f1e1abc34277dbd2e5e1b83b7423b999c96 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 13 Sep 2019 09:17:28 -0300 Subject: [PATCH 4/4] Ensure pytest ends successfully in test_without_terminal_plugin --- testing/acceptance_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 9476499..e3a6f5b 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1087,6 +1087,7 @@ def test_without_terminal_plugin(testdir, request): result = testdir.runpytest("-p", "no:terminal", "-n2") assert result.stdout.str() == "" assert result.stderr.str() == "" + assert result.ret == 0 def test_internal_error_with_maxfail(testdir):