From dd6eac12a4e7394a30c504c5665e0fc5b45fc597 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 11 Dec 2018 12:19:34 -0200 Subject: [PATCH] Fix ExceptionInfo usage for pytest 4.1 Fix #384 --- changelog/384.bugfix.rst | 1 + xdist/workermanage.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/384.bugfix.rst diff --git a/changelog/384.bugfix.rst b/changelog/384.bugfix.rst new file mode 100644 index 0000000..2ea011e --- /dev/null +++ b/changelog/384.bugfix.rst @@ -0,0 +1 @@ +Add support for pytest 4.1. diff --git a/xdist/workermanage.py b/xdist/workermanage.py index c6f0010..418a66c 100644 --- a/xdist/workermanage.py +++ b/xdist/workermanage.py @@ -345,7 +345,11 @@ class WorkerController(object): except: # noqa from _pytest._code import ExceptionInfo - excinfo = ExceptionInfo() + # ExceptionInfo API changed in pytest 4.1 + if hasattr(ExceptionInfo, "from_current"): + excinfo = ExceptionInfo.from_current() + else: + excinfo = ExceptionInfo() print("!" * 20, excinfo) self.config.notify_exception(excinfo) self.shutdown()