diff options
author | Meador Inge <meadori@gmail.com> | 2011-11-26 17:30:21 (GMT) |
---|---|---|
committer | Meador Inge <meadori@gmail.com> | 2011-11-26 17:30:21 (GMT) |
commit | 710671a72277b0196611cdfbb11b3cd0c49a93de (patch) | |
tree | 8c7eee2cbb865f4c88f3f4eb9884e6cb0833b18f /Lib/test/test_py_compile.py | |
parent | 89749407af49c5f4dc41910608e65f4e7bbe4d87 (diff) | |
download | cpython-710671a72277b0196611cdfbb11b3cd0c49a93de.zip cpython-710671a72277b0196611cdfbb11b3cd0c49a93de.tar.gz cpython-710671a72277b0196611cdfbb11b3cd0c49a93de.tar.bz2 |
Issue #12618: fix py_compile unit tests to handle different drives on Windows
Diffstat (limited to 'Lib/test/test_py_compile.py')
-rw-r--r-- | Lib/test/test_py_compile.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py index 6e6dc48..b919da2 100644 --- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -13,11 +13,22 @@ 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.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 + # on different drives. Therefore we need to switch to the drive where + # the temporary source file lives. + 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') def tearDown(self): shutil.rmtree(self.directory) + if self.cwd_drive: + os.chdir(self.cwd_drive) def test_absolute_path(self): py_compile.compile(self.source_path, self.pyc_path) |