@@ -276,11 +276,10 @@ def test_embeddable(self) -> None:
276
276
except Exception :
277
277
pytest .skip ("Compiler could not be initialized" )
278
278
279
- try :
280
- with open ("embed_pil.c" , "w" , encoding = "utf-8" ) as fh :
281
- home = sys .prefix .replace ("\\ " , "\\ \\ " )
282
- fh .write (
283
- f"""
279
+ with open ("embed_pil.c" , "w" , encoding = "utf-8" ) as fh :
280
+ home = sys .prefix .replace ("\\ " , "\\ \\ " )
281
+ fh .write (
282
+ f"""
284
283
#include "Python.h"
285
284
286
285
int main(int argc, char* argv[])
@@ -302,19 +301,20 @@ def test_embeddable(self) -> None:
302
301
return 0;
303
302
}}
304
303
"""
305
- )
304
+ )
305
+
306
+ objects = compiler .compile (["embed_pil.c" ])
307
+ compiler .link_executable (objects , "embed_pil" )
306
308
307
- objects = compiler . compile ([ "embed_pil.c" ] )
308
- compiler . link_executable ( objects , "embed_pil" )
309
+ env = os . environ . copy ( )
310
+ env [ "PATH" ] = sys . prefix + ";" + env [ "PATH" ]
309
311
310
- env = os . environ . copy ()
311
- env [ "PATH" ] = sys . prefix + ";" + env [ "PATH" ]
312
+ # Do not display the Windows Error Reporting dialog
313
+ getattr ( ctypes , "windll" ). kernel32 . SetErrorMode ( 0x0002 )
312
314
313
- # Do not display the Windows Error Reporting dialog
314
- getattr (ctypes , "windll" ).kernel32 .SetErrorMode (0x0002 )
315
+ process = subprocess .Popen (["embed_pil.exe" ], env = env )
316
+ process .communicate ()
317
+ assert process .returncode == 0
315
318
316
- process = subprocess .Popen (["embed_pil.exe" ], env = env )
317
- process .communicate ()
318
- assert process .returncode == 0
319
- finally :
320
- os .remove ("embed_pil.c" )
319
+ def teardown_method (self ) -> None :
320
+ os .remove ("embed_pil.c" )
0 commit comments