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.
This commit is contained in:
Tom Boshoven
2019-09-11 19:47:16 -04:00
parent 9f9b707481
commit 32a29138fc
2 changed files with 4 additions and 6 deletions

View File

@@ -49,11 +49,8 @@ class DSession(object):
self._max_worker_restart = get_default_max_worker_restart(self.config) self._max_worker_restart = get_default_max_worker_restart(self.config)
# summary message to print at the end of the session # summary message to print at the end of the session
self._summary_report = None self._summary_report = None
try: self.terminal = config.pluginmanager.getplugin("terminalreporter")
self.terminal = config.pluginmanager.getplugin("terminalreporter") if self.terminal:
except KeyError:
self.terminal = None
else:
self.trdist = TerminalDistReporter(config) self.trdist = TerminalDistReporter(config)
config.pluginmanager.register(self.trdist, "terminaldistreporter") config.pluginmanager.register(self.trdist, "terminaldistreporter")

View File

@@ -170,7 +170,8 @@ def pytest_configure(config):
session = DSession(config) session = DSession(config)
config.pluginmanager.register(session, "dsession") config.pluginmanager.register(session, "dsession")
tr = config.pluginmanager.getplugin("terminalreporter") tr = config.pluginmanager.getplugin("terminalreporter")
tr.showfspath = False if tr:
tr.showfspath = False
if config.getoption("boxed"): if config.getoption("boxed"):
config.option.forked = True config.option.forked = True