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

Method rewrite_file

Lib/test/test_importlib/test_pkg_import.py:41–49  ·  view source on GitHub ↗
(self, contents)

Source from the content-addressed store, hash-verified

39 self.remove_modules()
40
41 def rewrite_file(self, contents):
42 try:
43 compiled_path = cache_from_source(self.module_path)
44 if os.path.exists(compiled_path):
45 os.remove(compiled_path)
46 except NotImplementedError:
47 pass
48 with open(self.module_path, 'w', encoding='utf-8') as f:
49 f.write(contents)
50
51 def test_package_import__semantics(self):
52

Callers 1

Calls 5

cache_from_sourceFunction · 0.85
openFunction · 0.50
existsMethod · 0.45
removeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected