MCPcopy
hub / github.com/pytest-dev/pytest / test_insert_missing_modules

Method test_insert_missing_modules

testing/test_pathlib.py:791–808  ·  view source on GitHub ↗
(
        self, monkeypatch: MonkeyPatch, tmp_path: Path
    )

Source from the content-addressed store, hash-verified

789 )
790
791 def test_insert_missing_modules(
792 self, monkeypatch: MonkeyPatch, tmp_path: Path
793 ) -> None:
794 monkeypatch.chdir(tmp_path)
795 # Use 'xxx' and 'xxy' as parent names as they are unlikely to exist and
796 # don't end up being imported.
797 modules = {"xxx.tests.foo": ModuleType("xxx.tests.foo")}
798 insert_missing_modules(modules, "xxx.tests.foo")
799 assert sorted(modules) == ["xxx", "xxx.tests", "xxx.tests.foo"]
800
801 mod = ModuleType("mod", doc="My Module")
802 modules = {"xxy": mod}
803 insert_missing_modules(modules, "xxy")
804 assert modules == {"xxy": mod}
805
806 modules = {}
807 insert_missing_modules(modules, "")
808 assert modules == {}
809
810 @pytest.mark.parametrize("b_is_package", [True, False])
811 @pytest.mark.parametrize("insert_modules", [True, False])

Callers

nothing calls this directly

Calls 2

insert_missing_modulesFunction · 0.90
chdirMethod · 0.45

Tested by

no test coverage detected