From d473bf13e71ccf1cef754c49e30be3c3961fb86c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 3 Mar 2024 09:21:08 -0300 Subject: [PATCH] Improve test --- testing/test_collection.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/testing/test_collection.py b/testing/test_collection.py index 09df197e3..1491ec859 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1844,9 +1844,16 @@ def test_do_not_collect_symlink_siblings( directory created by tmp_path/tmpdir. """ # Use tmp_path because it creates a symlink with the name "current" next to the directory it creates. - assert tmp_path.parent.joinpath(f"{request.node.name}current").is_symlink() is True + symlink_path = tmp_path.parent / (tmp_path.name[:-1] + "current") + assert symlink_path.is_symlink() is True + # Create test file. tmp_path.joinpath("test_foo.py").write_text("def test(): pass", encoding="UTF-8") - result = pytester.runpytest_subprocess(tmp_path, "-sv") + # Ensure we collect it only once if we pass the tmp_path. + result = pytester.runpytest(tmp_path, "-sv") + result.assert_outcomes(passed=1) + + # Ensure we collect it only once if we pass the symlinked directory. + result = pytester.runpytest(symlink_path, "-sv") result.assert_outcomes(passed=1)