Skip to content

Commit a83ee19

Browse files
committed
Merge remote-tracking branch 'upstream/master' into RonnyPfannschmidt/bump-setuptools
2 parents 4f4c91c + e6b01b4 commit a83ee19

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

changelog/4179.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restore the tmpdir behaviour of symlinking the current test run.

doc/en/deprecations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Using ``Class`` in custom Collectors
6868
.. deprecated:: 3.9
6969

7070
Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector``
71-
subclasses has been deprecated. Users instead should use ``pytest_collect_make_item`` to customize node types during
71+
subclasses has been deprecated. Users instead should use ``pytest_pycollect_makeitem`` to customize node types during
7272
collection.
7373

7474
This issue should affect only advanced plugins who create new collection types, so if you see this warning

src/_pytest/pathlib.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,26 @@ def _max(iterable, default):
100100
_max = max
101101

102102

103+
def _force_symlink(root, target, link_to):
104+
"""helper to create the current symlink
105+
106+
its full of race conditions that are reasonably ok to ignore
107+
for the contex of best effort linking to the latest testrun
108+
109+
the presumption being thatin case of much parallelism
110+
the inaccuracy is going to be acceptable
111+
"""
112+
current_symlink = root.joinpath(target)
113+
try:
114+
current_symlink.unlink()
115+
except OSError:
116+
pass
117+
try:
118+
current_symlink.symlink_to(link_to)
119+
except Exception:
120+
pass
121+
122+
103123
def make_numbered_dir(root, prefix):
104124
"""create a directory with a increased number as suffix for the given prefix"""
105125
for i in range(10):
@@ -112,6 +132,7 @@ def make_numbered_dir(root, prefix):
112132
except Exception:
113133
pass
114134
else:
135+
_force_symlink(root, prefix + "current", new_path)
115136
return new_path
116137
else:
117138
raise EnvironmentError(

testing/test_tmpdir.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ def test_make(self, tmp_path):
196196
assert d.name.startswith(self.PREFIX)
197197
assert d.name.endswith(str(i))
198198

199+
symlink = tmp_path.joinpath(self.PREFIX + "current")
200+
if symlink.exists():
201+
# unix
202+
assert symlink.is_symlink()
203+
assert symlink.resolve() == d.resolve()
204+
199205
def test_cleanup_lock_create(self, tmp_path):
200206
d = tmp_path.joinpath("test")
201207
d.mkdir()
@@ -244,7 +250,7 @@ def _do_cleanup(self, tmp_path):
244250

245251
def test_cleanup_keep(self, tmp_path):
246252
self._do_cleanup(tmp_path)
247-
a, b = tmp_path.iterdir()
253+
a, b = (x for x in tmp_path.iterdir() if not x.is_symlink())
248254
print(a, b)
249255

250256
def test_cleanup_locked(self, tmp_path):

0 commit comments

Comments
 (0)