| 265 | class PyCompileCLITestCase(unittest.TestCase): |
| 266 | |
| 267 | def setUp(self): |
| 268 | self.directory = tempfile.mkdtemp() |
| 269 | self.source_path = os.path.join(self.directory, '_test.py') |
| 270 | try: |
| 271 | self.cache_path = importlib.util.cache_from_source(self.source_path, |
| 272 | optimization='' if __debug__ else 1) |
| 273 | except NotImplementedError: |
| 274 | # py_compile.main() assumes legacy pyc path if there is no cache_tag |
| 275 | self.cache_path = self.source_path + 'c' |
| 276 | with open(self.source_path, 'w') as file: |
| 277 | file.write('x = 123\n') |
| 278 | |
| 279 | def tearDown(self): |
| 280 | os_helper.rmtree(self.directory) |