MCPcopy Index your code
hub / github.com/python/cpython / add_module

Method add_module

Lib/test/test__interpreters.py:858–866  ·  view source on GitHub ↗
(self, modname, text)

Source from the content-addressed store, hash-verified

856 self.id = _interpreters.create()
857
858 def add_module(self, modname, text):
859 import tempfile
860 tempdir = tempfile.mkdtemp()
861 self.addCleanup(lambda: os_helper.rmtree(tempdir))
862 _interpreters.run_string(self.id, dedent(f"""
863 import sys
864 sys.path.insert(0, {tempdir!r})
865 """))
866 return script_helper.make_script(tempdir, modname, text)
867
868 def run_script(self, text, *, fails=False):
869 r, w = os.pipe()

Callers 3

test_invalid_syntaxMethod · 0.95
using___main__Function · 0.45
temp_moduleFunction · 0.45

Calls 4

dedentFunction · 0.90
mkdtempMethod · 0.80
addCleanupMethod · 0.80
make_scriptMethod · 0.45

Tested by

no test coverage detected