Skip to content

Commit

Permalink
Fix passing --basetemp to subprocesses with pytest 5.4
Browse files Browse the repository at this point in the history
Fixes pytest-dev#510.
Ref: pytest-dev/pytest#6767

Also uses `--basetemp` with `-p no:tmpdir` as a good side effect
(ref: pytest-dev#22).
  • Loading branch information
blueyed committed Mar 31, 2020
1 parent bea6f66 commit 5bc8eb0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog/510.bugfix.rst
@@ -0,0 +1 @@
Fix passing `--basetemp` to subprocesses with pytest 5.4.
10 changes: 6 additions & 4 deletions src/xdist/workermanage.py
@@ -1,12 +1,14 @@
from __future__ import print_function

import fnmatch
import os
import re
import sys

import execnet
import py
import pytest
import execnet
from _pytest.tmpdir import TempPathFactory

import xdist.remote

Expand Down Expand Up @@ -252,9 +254,9 @@ def setup(self):
args = make_reltoroot(self.nodemanager.roots, args)
if spec.popen:
name = "popen-%s" % self.gateway.id
if hasattr(self.config, "_tmpdirhandler"):
basetemp = self.config._tmpdirhandler.getbasetemp()
option_dict["basetemp"] = str(basetemp.join(name))
basetemp = TempPathFactory.from_config(self.config).getbasetemp()
option_dict["basetemp"] = str(basetemp.joinpath(name))

self.config.hook.pytest_configure_node(node=self)

remote_module = self.config.hook.pytest_xdist_getremotemodule()
Expand Down
8 changes: 5 additions & 3 deletions testing/acceptance_test.py
Expand Up @@ -766,9 +766,11 @@ def test_tmpdir_disabled(testdir):
"""
p1 = testdir.makepyfile(
"""
def test_ok():
pass
"""
def test_ok(request):
assert request.config.option.basetemp == {!r}
""".format(
str(testdir.tmpdir.dirpath() / "basetemp" / "popen-gw0")
)
)
result = testdir.runpytest(p1, "-n1", "-p", "no:tmpdir")
assert result.ret == 0
Expand Down

0 comments on commit 5bc8eb0

Please sign in to comment.