Skip to content

Commit 8659069

Browse files
committed
Simplify xdist detection
1 parent 337005c commit 8659069

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

pytest_mpl/plugin.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -977,19 +977,12 @@ def pytest_sessionfinish(self, session):
977977
Save out the hash library at the end of the run.
978978
"""
979979
config = session.config
980-
try:
981-
import xdist
982-
is_xdist_controller = xdist.is_xdist_controller(session)
983-
is_xdist_worker = xdist.is_xdist_worker(session)
984-
except ImportError:
985-
is_xdist_controller = False
986-
is_xdist_worker = False
987-
except Exception as e:
988-
if "xdist" not in session.config.option:
989-
is_xdist_controller = False
990-
is_xdist_worker = False
991-
else:
992-
raise e
980+
is_xdist_worker = hasattr(config, "workerinput")
981+
is_xdist_controller = (
982+
config.pluginmanager.hasplugin("xdist")
983+
and not is_xdist_worker
984+
and getattr(config.option, "dist", "") != "no"
985+
)
993986

994987
if is_xdist_controller: # Merge results from workers
995988
uid = config.pytest_mpl_uid

0 commit comments

Comments
 (0)