@@ -45,14 +45,9 @@ def test_spawn(self):
45
45
spawn ([exe ]) # should work without any error
46
46
47
47
def test_find_executable (self , tmp_path ):
48
- program_noeext = 'program'
49
- # Give the temporary program an ".exe" suffix for all.
50
- # It's needed on Windows and not harmful on other platforms.
51
- program = program_noeext + ".exe"
52
-
53
- program_path = tmp_path / program
54
- program_path .write_text ("" , encoding = 'utf-8' )
55
- program_path .chmod (stat .S_IXUSR )
48
+ program_path = self ._make_executable (tmp_path , '.exe' )
49
+ program = program_path .name
50
+ program_noeext = program_path .with_suffix ('' ).name
56
51
filename = str (program_path )
57
52
tmp_dir = path .Path (tmp_path )
58
53
@@ -121,6 +116,15 @@ def test_find_executable(self, tmp_path):
121
116
rv = find_executable (program )
122
117
assert rv == filename
123
118
119
+ @staticmethod
120
+ def _make_executable (tmp_path , ext ):
121
+ # Give the temporary program a suffix regardless of platform.
122
+ # It's needed on Windows and not harmful on others.
123
+ program = tmp_path .joinpath ('program' ).with_suffix (ext )
124
+ program .write_text ("" , encoding = 'utf-8' )
125
+ program .chmod (stat .S_IXUSR )
126
+ return program
127
+
124
128
def test_spawn_missing_exe (self ):
125
129
with pytest .raises (DistutilsExecError ) as ctx :
126
130
spawn (['does-not-exist' ])
0 commit comments