def test_no_match_directories_outside_the_suite(
        self,
        pytester: Pytester,
        monkeypatch: pytest.MonkeyPatch,
    ) -> None:
        """`-k` should not match against directories containing the test suite (#7040)."""
        pytester.makefile(
            **{
                "suite/pytest": """[pytest]""",
            },
            ext=".ini",
        )
        pytester.makepyfile(
            **{
                "suite/ddd/tests/__init__.py": "",
                "suite/ddd/tests/test_foo.py": """
                def test_aaa(): pass
                def test_ddd(): pass
            """,
            }
        )
        monkeypatch.chdir(pytester.path / "suite")

        def get_collected_names(*args: str) -> list[str]:
            _, rec = pytester.inline_genitems(*args)
            calls = rec.getcalls("pytest_collection_finish")
            assert len(calls) == 1
            return [x.name for x in calls[0].session.items]

        # sanity check: collect both tests in normal runs
        assert get_collected_names() == ["test_aaa", "test_ddd"]

        # do not collect anything based on names outside the collection tree
        assert get_collected_names("-k", pytester._name) == []
`-k` should not match against directories containing the test suite (#7040).
testing/test_mark.py