Merge remote-tracking branch 'upstream/master' into RonnyPfannschmidt/bump-setuptools

This commit is contained in:
Bruno Oliveira 2018-10-17 19:05:52 -03:00
commit a83ee197c6
4 changed files with 30 additions and 2 deletions

View File

@ -0,0 +1 @@
Restore the tmpdir behaviour of symlinking the current test run.

View File

@ -68,7 +68,7 @@ Using ``Class`` in custom Collectors
.. deprecated:: 3.9
Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector``
subclasses has been deprecated. Users instead should use ``pytest_collect_make_item`` to customize node types during
subclasses has been deprecated. Users instead should use ``pytest_pycollect_makeitem`` to customize node types during
collection.
This issue should affect only advanced plugins who create new collection types, so if you see this warning

View File

@ -100,6 +100,26 @@ else:
_max = max
def _force_symlink(root, target, link_to):
"""helper to create the current symlink
its full of race conditions that are reasonably ok to ignore
for the contex of best effort linking to the latest testrun
the presumption being thatin case of much parallelism
the inaccuracy is going to be acceptable
"""
current_symlink = root.joinpath(target)
try:
current_symlink.unlink()
except OSError:
pass
try:
current_symlink.symlink_to(link_to)
except Exception:
pass
def make_numbered_dir(root, prefix):
"""create a directory with a increased number as suffix for the given prefix"""
for i in range(10):
@ -112,6 +132,7 @@ def make_numbered_dir(root, prefix):
except Exception:
pass
else:
_force_symlink(root, prefix + "current", new_path)
return new_path
else:
raise EnvironmentError(

View File

@ -196,6 +196,12 @@ class TestNumberedDir(object):
assert d.name.startswith(self.PREFIX)
assert d.name.endswith(str(i))
symlink = tmp_path.joinpath(self.PREFIX + "current")
if symlink.exists():
# unix
assert symlink.is_symlink()
assert symlink.resolve() == d.resolve()
def test_cleanup_lock_create(self, tmp_path):
d = tmp_path.joinpath("test")
d.mkdir()
@ -244,7 +250,7 @@ class TestNumberedDir(object):
def test_cleanup_keep(self, tmp_path):
self._do_cleanup(tmp_path)
a, b = tmp_path.iterdir()
a, b = (x for x in tmp_path.iterdir() if not x.is_symlink())
print(a, b)
def test_cleanup_locked(self, tmp_path):