summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2011-11-26 17:39:49 (GMT)
committerMeador Inge <meadori@gmail.com>2011-11-26 17:39:49 (GMT)
commit59ff2c56402362702054fa06c2b360326941e940 (patch)
tree5d1fd22fa53b9417d07069c54b6b45c2a10c7c4b /Lib/test
parent6a5dcd4b2aa3f4c39749056750329cd69d849435 (diff)
parentfb36b3f6a0d57abeb6f953d9b4f72ddb4e3c4709 (diff)
downloadcpython-59ff2c56402362702054fa06c2b360326941e940.zip
cpython-59ff2c56402362702054fa06c2b360326941e940.tar.gz
cpython-59ff2c56402362702054fa06c2b360326941e940.tar.bz2
Issue #12618: fix py_compile unit tests to handle different drives on Windows
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_py_compile.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
index 7491587..8ad0897 100644
--- a/Lib/test/test_py_compile.py
+++ b/Lib/test/test_py_compile.py
@@ -14,11 +14,21 @@ class PyCompileTests(unittest.TestCase):
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
+ # 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)