def test_search_conftest_up_to_inifile(
    pytester: Pytester, confcutdir: str, passed: int, error: int
) -> None:
    """Test that conftest files are detected only up to an ini file, unless
    an explicit --confcutdir option is given.
    """
    root = pytester.path
    src = root.joinpath("src")
    src.mkdir()
    src.joinpath("pytest.ini").write_text("[pytest]", encoding="utf-8")
    src.joinpath("conftest.py").write_text(
        textwrap.dedent(
            """\
            import pytest
            @pytest.fixture
            def fix1(): pass
            """
        ),
        encoding="utf-8",
    )
    src.joinpath("test_foo.py").write_text(
        textwrap.dedent(
            """\
            def test_1(fix1):
                pass
            def test_2(out_of_reach):
                pass
            """
        ),
        encoding="utf-8",
    )
    root.joinpath("conftest.py").write_text(
        textwrap.dedent(
            """\
            import pytest
            @pytest.fixture
            def out_of_reach(): pass
            """
        ),
        encoding="utf-8",
    )

    args = [str(src)]
    if confcutdir:
        args = [f"--confcutdir={root.joinpath(confcutdir)}"]
    result = pytester.runpytest(*args)
    match = ""
    if passed:
        match += f"*{passed} passed*"
    if error:
        match += f"*{error} error*"
    result.stdout.fnmatch_lines(match)
Test that conftest files are detected only up to an ini file, unless
    an explicit --confcutdir option is given.
    
testing/test_conftest.py