@@ -1117,9 +1117,15 @@ def test_cm_is_reentrant(self):
11171117
11181118
11191119class TestChdir (unittest .TestCase ):
1120+ def make_relative_path (self , * parts ):
1121+ return os .path .join (
1122+ os .path .dirname (os .path .realpath (__file__ )),
1123+ * parts ,
1124+ )
1125+
11201126 def test_simple (self ):
11211127 old_cwd = os .getcwd ()
1122- target = os . path . join ( os . path . dirname ( __file__ ), 'data' )
1128+ target = self . make_relative_path ( 'data' )
11231129 self .assertNotEqual (old_cwd , target )
11241130
11251131 with chdir (target ):
@@ -1128,8 +1134,8 @@ def test_simple(self):
11281134
11291135 def test_reentrant (self ):
11301136 old_cwd = os .getcwd ()
1131- target1 = os . path . join ( os . path . dirname ( __file__ ), 'data' )
1132- target2 = os . path . join ( os . path . dirname ( __file__ ), 'ziptestdata' )
1137+ target1 = self . make_relative_path ( 'data' )
1138+ target2 = self . make_relative_path ( 'ziptestdata' )
11331139 self .assertNotIn (old_cwd , (target1 , target2 ))
11341140 chdir1 , chdir2 = chdir (target1 ), chdir (target2 )
11351141
@@ -1145,7 +1151,7 @@ def test_reentrant(self):
11451151
11461152 def test_exception (self ):
11471153 old_cwd = os .getcwd ()
1148- target = os . path . join ( os . path . dirname ( __file__ ), 'data' )
1154+ target = self . make_relative_path ( 'data' )
11491155 self .assertNotEqual (old_cwd , target )
11501156
11511157 try :
0 commit comments