Skip to content

Commit 7dc7f33

Browse files
committed
Change tests
1 parent 9944053 commit 7dc7f33

File tree

1 file changed

+7
-32
lines changed

1 file changed

+7
-32
lines changed

testing/test_collection.py

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -240,49 +240,24 @@ def test_testpaths_ini(self, testdir, monkeypatch):
240240
items, reprec = testdir.inline_genitems()
241241
assert [x.name for x in items] == ["test_%s" % dirname]
242242

243-
@pytest.mark.skipif(sys.platform == "win32", reason="no symlinks on Windows")
244-
def test_recursive_absolute_symlinks(self, testdir):
245-
"""
246-
dir
247-
├── link -> /absolute/path/to/dir
248-
└── test_recursive.py
249-
"""
243+
@pytest.mark.parametrize("absolute", [True, False])
244+
def test_recursive_symlinks(self, testdir, absolute):
245+
"""Make sure recursive symlinks won't cause multiple collection of the same file."""
250246
tmpdir = testdir.tmpdir
251247
directory = tmpdir.mkdir("dir")
252248
directory.ensure("test_recursive.py").write("def test_recursive(): pass")
253-
os.symlink(str(directory), "dir/link")
249+
symlink_or_skip(str(directory) if absolute else ".", "dir/link")
254250

255251
items, _ = testdir.inline_genitems()
256252
assert len(items) == 1
257253

258-
@pytest.mark.skipif(sys.platform == "win32", reason="no symlinks on Windows")
259-
def test_recursive_relative_symlinks(self, testdir):
260-
"""
261-
dir
262-
├── link -> .
263-
└── test_recursive.py
264-
"""
265-
tmpdir = testdir.tmpdir
266-
directory = tmpdir.mkdir("dir")
267-
directory.ensure("test_recursive.py").write("def test_recursive(): pass")
268-
os.symlink(".", "dir/link")
269-
270-
items, _ = testdir.inline_genitems()
271-
assert len(items) == 1
272-
273-
@pytest.mark.skipif(sys.platform == "win32", reason="no symlinks on Windows")
274254
def test_multiple_recursive_symlinks(self, testdir):
275-
"""
276-
dir
277-
├── link -> .
278-
├── link2 -> link
279-
└── test_recursive.py
280-
"""
255+
"""Symlink points to recursive symlink. Should be resolved to the very end."""
281256
tmpdir = testdir.tmpdir
282257
directory = tmpdir.mkdir("dir")
283258
directory.ensure("test_recursive.py").write("def test_recursive(): pass")
284-
os.symlink(".", "dir/link")
285-
os.symlink("link", "dir/link2")
259+
symlink_or_skip(".", "dir/link")
260+
symlink_or_skip("link", "dir/link2")
286261

287262
items, _ = testdir.inline_genitems()
288263
assert len(items) == 1

0 commit comments

Comments
 (0)