Skip to content

Commit 5bc8eb0

Browse files
committed
Fix passing --basetemp to subprocesses with pytest 5.4
Fixes #510. Ref: pytest-dev/pytest#6767 Also uses `--basetemp` with `-p no:tmpdir` as a good side effect (ref: #22).
1 parent bea6f66 commit 5bc8eb0

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

changelog/510.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix passing `--basetemp` to subprocesses with pytest 5.4.

src/xdist/workermanage.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from __future__ import print_function
2+
23
import fnmatch
34
import os
45
import re
56
import sys
67

8+
import execnet
79
import py
810
import pytest
9-
import execnet
11+
from _pytest.tmpdir import TempPathFactory
1012

1113
import xdist.remote
1214

@@ -252,9 +254,9 @@ def setup(self):
252254
args = make_reltoroot(self.nodemanager.roots, args)
253255
if spec.popen:
254256
name = "popen-%s" % self.gateway.id
255-
if hasattr(self.config, "_tmpdirhandler"):
256-
basetemp = self.config._tmpdirhandler.getbasetemp()
257-
option_dict["basetemp"] = str(basetemp.join(name))
257+
basetemp = TempPathFactory.from_config(self.config).getbasetemp()
258+
option_dict["basetemp"] = str(basetemp.joinpath(name))
259+
258260
self.config.hook.pytest_configure_node(node=self)
259261

260262
remote_module = self.config.hook.pytest_xdist_getremotemodule()

testing/acceptance_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,11 @@ def test_tmpdir_disabled(testdir):
766766
"""
767767
p1 = testdir.makepyfile(
768768
"""
769-
def test_ok():
770-
pass
771-
"""
769+
def test_ok(request):
770+
assert request.config.option.basetemp == {!r}
771+
""".format(
772+
str(testdir.tmpdir.dirpath() / "basetemp" / "popen-gw0")
773+
)
772774
)
773775
result = testdir.runpytest(p1, "-n1", "-p", "no:tmpdir")
774776
assert result.ret == 0

0 commit comments

Comments
 (0)