Merge pull request #7982 from bluetech/symlink-collect
pathlib: fix symlinked directories not followed during collection
(cherry picked from commit a14a229d1b
)
Changed pytester -> testdir.
This commit is contained in:
parent
573860d71c
commit
8cf0bbdf75
|
@ -0,0 +1 @@
|
|||
Fixed symlinked directories not being followed during collection. Regressed in pytest 6.1.0.
|
|
@ -566,7 +566,7 @@ def visit(
|
|||
entries = sorted(os.scandir(path), key=lambda entry: entry.name)
|
||||
yield from entries
|
||||
for entry in entries:
|
||||
if entry.is_dir(follow_symlinks=False) and recurse(entry):
|
||||
if entry.is_dir() and recurse(entry):
|
||||
yield from visit(entry.path, recurse)
|
||||
|
||||
|
||||
|
|
|
@ -1178,6 +1178,15 @@ def test_collect_symlink_out_of_tree(testdir):
|
|||
assert result.ret == 0
|
||||
|
||||
|
||||
def test_collect_symlink_dir(testdir: Testdir) -> None:
|
||||
"""A symlinked directory is collected."""
|
||||
dir = testdir.mkdir("dir")
|
||||
dir.join("test_it.py").write("def test_it(): pass")
|
||||
symlink_or_skip(dir, testdir.tmpdir.join("symlink_dir"))
|
||||
result = testdir.runpytest()
|
||||
result.assert_outcomes(passed=2)
|
||||
|
||||
|
||||
def test_collectignore_via_conftest(testdir):
|
||||
"""collect_ignore in parent conftest skips importing child (issue #4592)."""
|
||||
tests = testdir.mkpydir("tests")
|
||||
|
|
Loading…
Reference in New Issue