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

Method assert_cache_path_exists

Lib/test/test_py_compile.py:79–98  ·  view source on GitHub ↗
(self, should_exist=True)

Source from the content-addressed store, hash-verified

77 os.chdir(self.cwd_drive)
78
79 def assert_cache_path_exists(self, should_exist=True):
80 if self.cache_path:
81 if should_exist:
82 self.assertTrue(os.path.exists(self.cache_path))
83 else:
84 self.assertFalse(os.path.exists(self.cache_path))
85 return
86 cache_dir = os.path.join(self.directory, '__pycache__')
87 if not os.path.isdir(cache_dir):
88 if should_exist:
89 self.fail('no __pycache__ directory exists')
90 return
91 for f in os.listdir(cache_dir):
92 if f.startswith('_test.') and f.endswith('.pyc'):
93 if should_exist:
94 return
95 self.fail(f'__pycache__/{f} was created')
96 else:
97 if should_exist:
98 self.fail('no __pycache__/_test.*.pyc file exists')
99
100 def test_absolute_path(self):
101 py_compile.compile(self.source_path, self.pyc_path)

Callers 5

test_absolute_pathMethod · 0.95
test_cache_pathMethod · 0.95
test_cwdMethod · 0.95
test_relative_pathMethod · 0.95

Calls 9

assertTrueMethod · 0.80
assertFalseMethod · 0.80
listdirMethod · 0.80
existsMethod · 0.45
joinMethod · 0.45
isdirMethod · 0.45
failMethod · 0.45
startswithMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected