def test_collect_symlink_file_arg(pytester: Pytester) -> None:
    """Collect a direct symlink works even if it does not match python_files (#4325)."""
    real = pytester.makepyfile(
        real="""
        def test_nodeid(request):
            assert request.node.nodeid == "symlink.py::test_nodeid"
        """
    )
    symlink = pytester.path.joinpath("symlink.py")
    symlink_or_skip(real, symlink)
    result = pytester.runpytest("-v", symlink)
    result.stdout.fnmatch_lines(["symlink.py::test_nodeid PASSED*", "*1 passed in*"])
    assert result.ret == 0
Collect a direct symlink works even if it does not match python_files (#4325).
testing/test_collection.py