diff options
Diffstat (limited to 'Lib/test/test_py_compile.py')
-rw-r--r-- | Lib/test/test_py_compile.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py index b919da2221a..f3c1a6a44b6 100644 --- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -5,7 +5,7 @@ import shutil import tempfile import unittest -from test import test_support +from test import support, script_helper class PyCompileTests(unittest.TestCase): @@ -13,6 +13,7 @@ class PyCompileTests(unittest.TestCase): self.directory = tempfile.mkdtemp() self.source_path = os.path.join(self.directory, '_test.py') self.pyc_path = self.source_path + 'c' + self.cache_path = imp.cache_from_source(self.source_path) self.cwd_drive = os.path.splitdrive(os.getcwd())[0] # In these tests we compute relative paths. When using Windows, the # current working directory path and the 'self.source_path' might be @@ -21,7 +22,6 @@ class PyCompileTests(unittest.TestCase): drive = os.path.splitdrive(self.source_path)[0] if drive: os.chdir(drive) - with open(self.source_path, 'w') as file: file.write('x = 123\n') @@ -33,6 +33,11 @@ class PyCompileTests(unittest.TestCase): def test_absolute_path(self): py_compile.compile(self.source_path, self.pyc_path) self.assertTrue(os.path.exists(self.pyc_path)) + self.assertFalse(os.path.exists(self.cache_path)) + + def test_cache_path(self): + py_compile.compile(self.source_path) + self.assertTrue(os.path.exists(self.cache_path)) def test_cwd(self): cwd = os.getcwd() @@ -41,14 +46,16 @@ class PyCompileTests(unittest.TestCase): os.path.basename(self.pyc_path)) os.chdir(cwd) self.assertTrue(os.path.exists(self.pyc_path)) + self.assertFalse(os.path.exists(self.cache_path)) def test_relative_path(self): py_compile.compile(os.path.relpath(self.source_path), os.path.relpath(self.pyc_path)) self.assertTrue(os.path.exists(self.pyc_path)) + self.assertFalse(os.path.exists(self.cache_path)) def test_main(): - test_support.run_unittest(PyCompileTests) + support.run_unittest(PyCompileTests) if __name__ == "__main__": test_main() |