File tree 4 files changed +30
-2
lines changed
4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change
1
+ Restore the tmpdir behaviour of symlinking the current test run.
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ Using ``Class`` in custom Collectors
68
68
.. deprecated :: 3.9
69
69
70
70
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
72
72
collection.
73
73
74
74
This issue should affect only advanced plugins who create new collection types, so if you see this warning
Original file line number Diff line number Diff line change @@ -100,6 +100,26 @@ def _max(iterable, default):
100
100
_max = max
101
101
102
102
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
+
103
123
def make_numbered_dir (root , prefix ):
104
124
"""create a directory with a increased number as suffix for the given prefix"""
105
125
for i in range (10 ):
@@ -112,6 +132,7 @@ def make_numbered_dir(root, prefix):
112
132
except Exception :
113
133
pass
114
134
else :
135
+ _force_symlink (root , prefix + "current" , new_path )
115
136
return new_path
116
137
else :
117
138
raise EnvironmentError (
Original file line number Diff line number Diff line change @@ -196,6 +196,12 @@ def test_make(self, tmp_path):
196
196
assert d .name .startswith (self .PREFIX )
197
197
assert d .name .endswith (str (i ))
198
198
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
+
199
205
def test_cleanup_lock_create (self , tmp_path ):
200
206
d = tmp_path .joinpath ("test" )
201
207
d .mkdir ()
@@ -244,7 +250,7 @@ def _do_cleanup(self, tmp_path):
244
250
245
251
def test_cleanup_keep (self , tmp_path ):
246
252
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 () )
248
254
print (a , b )
249
255
250
256
def test_cleanup_locked (self , tmp_path ):
You can’t perform that action at this time.
0 commit comments