def test_importmode_importlib_with_pickle_separate_modules(
        self, tmp_path: Path, ns_param: bool
    ) -> None:
        """
        Ensure that importlib mode works can load pickles that look similar but are
        defined in separate modules.
        """
        fn1 = tmp_path.joinpath("_src/m1/tests/test.py")
        fn1.parent.mkdir(parents=True)
        fn1.write_text(
            dedent(
                """
                import dataclasses
                import pickle

                @dataclasses.dataclass
                class Data:
                    x: int = 42
                """
            ),
            encoding="utf-8",
        )

        fn2 = tmp_path.joinpath("_src/m2/tests/test.py")
        fn2.parent.mkdir(parents=True)
        fn2.write_text(
            dedent(
                """
                import dataclasses
                import pickle

                @dataclasses.dataclass
                class Data:
                    x: str = ""
                """
            ),
            encoding="utf-8",
        )

        import pickle

        def round_trip(obj):
            s = pickle.dumps(obj)
            return pickle.loads(s)

        module = import_path(
            fn1, mode="importlib", root=tmp_path, consider_namespace_packages=ns_param
        )
        Data1 = getattr(module, "Data")

        module = import_path(
            fn2, mode="importlib", root=tmp_path, consider_namespace_packages=ns_param
        )
        Data2 = getattr(module, "Data")

        assert round_trip(Data1(20)) == Data1(20)
        assert round_trip(Data2("hello")) == Data2("hello")
        assert Data1.__module__ == "_src.m1.tests.test"
        assert Data2.__module__ == "_src.m2.tests.test"

        Ensure that importlib mode works can load pickles that look similar but are
        defined in separate modules.
        
testing/test_pathlib.py