File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,11 +14,21 @@ def setUp(self):
1414 self .source_path = os .path .join (self .directory , '_test.py' )
1515 self .pyc_path = self .source_path + 'c'
1616 self .cache_path = imp .cache_from_source (self .source_path )
17+ self .cwd_drive = os .path .splitdrive (os .getcwd ())[0 ]
18+ # In these tests we compute relative paths. When using Windows, the
19+ # current working directory path and the 'self.source_path' might be
20+ # on different drives. Therefore we need to switch to the drive where
21+ # the temporary source file lives.
22+ drive = os .path .splitdrive (self .source_path )[0 ]
23+ if drive :
24+ os .chdir (drive )
1725 with open (self .source_path , 'w' ) as file :
1826 file .write ('x = 123\n ' )
1927
2028 def tearDown (self ):
2129 shutil .rmtree (self .directory )
30+ if self .cwd_drive :
31+ os .chdir (self .cwd_drive )
2232
2333 def test_absolute_path (self ):
2434 py_compile .compile (self .source_path , self .pyc_path )
You can’t perform that action at this time.
0 commit comments