@@ -93,6 +93,8 @@ def setUp(self):
93
93
def tearDown (self ):
94
94
os .chdir (self .oldcwd )
95
95
96
+ ANY_FAILURE = object ()
97
+
96
98
def run_embedded_interpreter (self , * args , env = None ,
97
99
timeout = None , returncode = 0 , input = None ,
98
100
cwd = None ):
@@ -117,7 +119,7 @@ def run_embedded_interpreter(self, *args, env=None,
117
119
p .terminate ()
118
120
p .wait ()
119
121
raise
120
- if returncode is None :
122
+ if returncode is self . ANY_FAILURE :
121
123
returncode = 1 if p .returncode == 0 else p .returncode
122
124
if p .returncode != returncode and support .verbose :
123
125
print (f"--- { cmd } failed ---" )
@@ -234,23 +236,24 @@ def test_replace_main_tstate(self):
234
236
self .run_embedded_interpreter (
235
237
'test_replace_main_tstate' ,
236
238
# At the moment, this fails because main_tstate gets broken.
237
- returncode = None ,
239
+ returncode = self . ANY_FAILURE ,
238
240
)
239
241
with self .subTest (reuse = reuse , exec = True ):
240
- out , _ = self .run_embedded_interpreter (
242
+ out , rc = self .run_embedded_interpreter (
241
243
'test_replace_main_tstate' ,
242
244
'print("spam!")' ,
243
- # At the moment, this actually succeeds on all platforms .
244
- returncode = 0 ,
245
+ # At the moment, this fails because main_tstate gets broken .
246
+ returncode = self . ANY_FAILURE ,
245
247
)
246
- self .assertEqual (out .strip (), 'spam!' )
248
+ if rc == 0 :
249
+ self .assertEqual (out .strip (), 'spam!' )
247
250
248
251
def test_fini_in_subthread (self ):
249
252
self .run_embedded_interpreter (
250
253
'test_fini_in_subthread' ,
251
254
# At the moment, this actually succeeds on all platforms,
252
255
# except for Windows (STATUS_ACCESS_VIOLATION).
253
- returncode = None if MS_WINDOWS else 0 ,
256
+ returncode = self . ANY_FAILURE if MS_WINDOWS else 0 ,
254
257
)
255
258
256
259
def test_fini_in_main_thread_with_other_tstate (self ):
0 commit comments