From c76c0702984c9fdc49b1b30fcaac452e63090130 Mon Sep 17 00:00:00 2001 From: Yuval Date: Fri, 31 May 2024 23:26:45 +0300 Subject: [PATCH 1/2] Fixed an issue with running the same test multiple times sequentially When pytest_runtest_protocol is called with item==nextitem multiple times, with a test that accepts some fixtures -> the second call forward raises an error. This is caused in WorkerInteractor when the same test appears twice in a row in the queue. So if this specific case occurs, ensure nextitem is called with None instead. --- src/xdist/remote.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xdist/remote.py b/src/xdist/remote.py index dd1f9883..40337ecc 100644 --- a/src/xdist/remote.py +++ b/src/xdist/remote.py @@ -183,7 +183,7 @@ def run_one_test(self) -> None: items = self.session.items item = items[self.item_index] - if self.nextitem_index is Marker.SHUTDOWN: + if self.nextitem_index is Marker.SHUTDOWN or self.item_index == self.nextitem_index: nextitem = None else: assert self.nextitem_index is not None From d024f95d3e25ee954e12ee828330be2f8da825d1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 20:28:34 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/xdist/remote.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xdist/remote.py b/src/xdist/remote.py index 40337ecc..98b5a9c6 100644 --- a/src/xdist/remote.py +++ b/src/xdist/remote.py @@ -183,7 +183,10 @@ def run_one_test(self) -> None: items = self.session.items item = items[self.item_index] - if self.nextitem_index is Marker.SHUTDOWN or self.item_index == self.nextitem_index: + if ( + self.nextitem_index is Marker.SHUTDOWN + or self.item_index == self.nextitem_index + ): nextitem = None else: assert self.nextitem_index is not None