@@ -276,11 +276,10 @@ def test_embeddable(self) -> None:
276276 except Exception :
277277 pytest .skip ("Compiler could not be initialized" )
278278
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"""
284283#include "Python.h"
285284
286285int main(int argc, char* argv[])
@@ -302,19 +301,20 @@ def test_embeddable(self) -> None:
302301 return 0;
303302}}
304303 """
305- )
304+ )
305+
306+ objects = compiler .compile (["embed_pil.c" ])
307+ compiler .link_executable (objects , "embed_pil" )
306308
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" ]
309311
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 )
312314
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
315318
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