def test_import_using_normal_mechanism_first(
        self, monkeypatch: MonkeyPatch, pytester: Pytester, ns_param: bool
    ) -> None:
        """
        Test import_path imports from the canonical location when possible first, only
        falling back to its normal flow when the module being imported is not reachable via sys.path (#11475).
        """
        core_py, test_path1, test_path2 = self.create_installed_doctests_and_tests_dir(
            pytester.path, monkeypatch
        )

        # core_py is reached from sys.path, so should be imported normally.
        mod = import_path(
            core_py,
            mode="importlib",
            root=pytester.path,
            consider_namespace_packages=ns_param,
        )
        assert mod.__name__ == "app.core"
        assert mod.__file__ and Path(mod.__file__) == core_py

        # Ensure we do not import the same module again (#11475).
        mod2 = import_path(
            core_py,
            mode="importlib",
            root=pytester.path,
            consider_namespace_packages=ns_param,
        )
        assert mod is mod2

        # tests are not reachable from sys.path, so they are imported as a standalone modules.
        # Instead of '.tests.a.test_core', we import as "_tests.a.test_core" because
        # importlib considers module names starting with '.' to be local imports.
        mod = import_path(
            test_path1,
            mode="importlib",
            root=pytester.path,
            consider_namespace_packages=ns_param,
        )
        assert mod.__name__ == "_tests.a.test_core"

        # Ensure we do not import the same module again (#11475).
        mod2 = import_path(
            test_path1,
            mode="importlib",
            root=pytester.path,
            consider_namespace_packages=ns_param,
        )
        assert mod is mod2

        mod = import_path(
            test_path2,
            mode="importlib",
            root=pytester.path,
            consider_namespace_packages=ns_param,
        )
        assert mod.__name__ == "_tests.b.test_core"

        # Ensure we do not import the same module again (#11475).
        mod2 = import_path(
            test_path2,
            mode="importlib",
            root=pytester.path,
            consider_namespace_packages=ns_param,
        )
        assert mod is mod2

        Test import_path imports from the canonical location when possible first, only
        falling back to its normal flow when the module being imported is not reachable via sys.path (#11475).
        
testing/test_pathlib.py