Skip to content

testing/test_collection.py::test_do_not_collect_symlink_siblings fails on Windows #13771

@macdjord

Description

@macdjord

The test testing/test_collection.py::test_do_not_collect_symlink_siblings from PyTest's own test suite is failing:

(env) C:\Users\jordan.macdonald\source\macdjord\pytest.git>tox -e py311
.pkg: _optional_hooks> python C:\Users\jordan.macdonald\source\macdjord\pytest.git\env\Lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_sdist> python C:\Users\jordan.macdonald\source\macdjord\pytest.git\env\Lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_editable> python C:\Users\jordan.macdonald\source\macdjord\pytest.git\env\Lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta
.pkg: build_sdist> python C:\Users\jordan.macdonald\source\macdjord\pytest.git\env\Lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta
py311: install_package> python -I -m pip install --force-reinstall --no-deps C:\Users\jordan.macdonald\source\macdjord\pytest.git\.tox\.tmp\package\11\pytest-8.5.0.dev141+g184f5f1df.d20250930.tar.gz
py311: commands[0]> pytest
=========================================================================================================== test session starts ============================================================================================================
platform win32 -- Python 3.11.2, pytest-8.5.0.dev141+g184f5f1df.d20250930, pluggy-1.6.0
cachedir: .tox\py311\.pytest_cache
rootdir: C:\Users\jordan.macdonald\source\macdjord\pytest.git
configfile: pyproject.toml
testpaths: testing
plugins: hypothesis-6.140.2
collected 3932 items

testing\_py\test_local.py .................................................................ss.s......ss......................x.....X.ssssssssss........................s.........ssssssssssssssssssssssssssssx...                     [  4%]
[...]
testing\test_warnings.py ..........                                                                                                                                                                                                   [100%]

================================================================================================================= FAILURES =================================================================================================================
___________________________________________________________________________________________________ test_do_not_collect_symlink_siblings ___________________________________________________________________________________________________

pytester = <Pytester WindowsPath('C:/Users/jordan.macdonald/AppData/Local/Temp/pytest-of-unknown/pytest-15/test_do_not_collect_symlink_siblings0')>
tmp_path = WindowsPath('C:/Users/jordan.macdonald/AppData/Local/Temp/pytest-of-unknown/pytest-15/test_do_not_collect_symlink_si0'), request = <FixtureRequest for <Function test_do_not_collect_symlink_siblings>>

    def test_do_not_collect_symlink_siblings(
        pytester: Pytester, tmp_path: Path, request: pytest.FixtureRequest
    ) -> None:
        """
        Regression test for #12039: Do not collect from directories that are symlinks to other directories in the same path.

        The check for short paths under Windows via os.path.samefile, introduced in #11936, also finds the symlinked
        directory created by tmp_path/tmpdir.
        """
        # Use tmp_path because it creates a symlink with the name "current" next to the directory it creates.
        symlink_path = tmp_path.parent / (tmp_path.name[:-1] + "current")
>       assert symlink_path.is_symlink() is True
E       AssertionError: assert False is True
E        +  where False = is_symlink()
E        +    where is_symlink = WindowsPath('C:/Users/jordan.macdonald/AppData/Local/Temp/pytest-of-unknown/pytest-15/test_do_not_collect_symlink_sicurrent').is_symlink

C:\Users\jordan.macdonald\source\macdjord\pytest.git\testing\test_collection.py:1874: AssertionError

Note

I had to mark testing/test_collection.py::test_collect_short_file_windows to be skipped in order to get the tests to finish, but otherwise I have changed nothing from main.

Versions

OS: Windows 10

jordan.macdonald@VOTMTL01L028 MINGW64 ~/source/macdjord/pytest.git (main)
$ pip list
Package       Version
------------- -------
cachetools    6.2.0
cfgv          3.4.0
chardet       5.2.0
colorama      0.4.6
distlib       0.4.0
filelock      3.19.1
identify      2.6.14
nodeenv       1.9.1
packaging     25.0
pip           25.2
platformdirs  4.4.0
pluggy        1.6.0
pre_commit    4.3.0
pyproject-api 1.9.1
PyYAML        6.0.3
setuptools    80.3.1
tox           4.30.2
virtualenv    20.34.0
(env) 
jordan.macdonald@VOTMTL01L028 MINGW64 ~/source/macdjord/pytest.git (main)
$ git log -1
commit 184f5f1dfe3b8c987304b05bbacc2da86d8ad7d3 (HEAD -> main, origin/main, origin/HEAD, add_ci_opts)
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Mon Sep 29 21:18:25 2025 +0000

    [pre-commit.ci] pre-commit autoupdate (#13765)
    
    updates:
    - [github.com/astral-sh/ruff-pre-commit: v0.13.1 → v0.13.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.13.1...v0.13.2)
    - [github.com/woodruffw/zizmor-pre-commit: v1.13.0 → v1.14.2](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.13.0...v1.14.2)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(env) 
jordan.macdonald@VOTMTL01L028 MINGW64 ~/source/macdjord/pytest.git (main)
$ which python 
/c/Users/jordan.macdonald/source/macdjord/pytest.git/env/Scripts/python
(env) 
jordan.macdonald@VOTMTL01L028 MINGW64 ~/source/macdjord/pytest.git (main)
$ python --version
Python 3.11.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions