def test_ns_import_same_name_directory_12592(
    tmp_path: Path, pytester: Pytester
) -> None:
    """Regression for `--import-mode=importlib` with directory parent and child with same name (#12592)."""
    y_dir = tmp_path / "x/y/y"
    y_dir.mkdir(parents=True)
    test_y = tmp_path / "x/y/test_y.py"
    test_y.write_text("def test(): pass", encoding="UTF-8")

    result = pytester.runpytest("--import-mode=importlib", test_y)
    assert result.ret == ExitCode.OK
Regression for `--import-mode=importlib` with directory parent and child with same name (#12592).
testing/test_pathlib.py