Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'getoption' to get the basetemp value instead of private details #519

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/518.bugfix
@@ -0,0 +1 @@
Fix support of the `--basetemp` pytest option for pytest 5.4.0 and up.
6 changes: 3 additions & 3 deletions src/xdist/workermanage.py
Expand Up @@ -252,9 +252,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 = self.config.getoption("basetemp")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only fixes half of the problem, pytest will undo the removal of _tmpdirhandler until we come up with a good full solution

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, did I miss the issue which contained those information? What is the other half?

Thanks for the quick response!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, found it: #510. I'll close this unless I get more guidance for the other part of the solution.

if basetemp is not None:
option_dict["basetemp"] = str(os.path.join(basetemp, name))
self.config.hook.pytest_configure_node(node=self)

remote_module = self.config.hook.pytest_xdist_getremotemodule()
Expand Down
16 changes: 16 additions & 0 deletions testing/acceptance_test.py
Expand Up @@ -128,6 +128,22 @@ def test_send(tmpdir):
assert result.ret == 0
result.stdout.fnmatch_lines(["*1 passed*"])

def test_basetemp_in_subprocesses_when_specified(self, testdir):
basetemp = testdir.tmpdir.join("one-level-down")
basetemp.mkdir()

p1 = testdir.makepyfile(
"""
def test_send(tmpdir):
import py
assert tmpdir.relto(py.path.local(%r)), tmpdir
"""
% str(basetemp)
)
result = testdir.runpytest_subprocess(p1, "-n1", "--basetemp", basetemp)
assert result.ret == 0
result.stdout.fnmatch_lines(["*1 passed*"])

def test_dist_ini_specified(self, testdir):
p1 = testdir.makepyfile(
"""
Expand Down