Skip to content

Commit d78f655

Browse files
Fix the test failures.
1 parent d3beea4 commit d78f655

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Lib/test/test_embed.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def setUp(self):
9393
def tearDown(self):
9494
os.chdir(self.oldcwd)
9595

96+
ANY_FAILURE = object()
97+
9698
def run_embedded_interpreter(self, *args, env=None,
9799
timeout=None, returncode=0, input=None,
98100
cwd=None):
@@ -117,7 +119,7 @@ def run_embedded_interpreter(self, *args, env=None,
117119
p.terminate()
118120
p.wait()
119121
raise
120-
if returncode is None:
122+
if returncode is self.ANY_FAILURE:
121123
returncode = 1 if p.returncode == 0 else p.returncode
122124
if p.returncode != returncode and support.verbose:
123125
print(f"--- {cmd} failed ---")
@@ -234,23 +236,24 @@ def test_replace_main_tstate(self):
234236
self.run_embedded_interpreter(
235237
'test_replace_main_tstate',
236238
# At the moment, this fails because main_tstate gets broken.
237-
returncode=None,
239+
returncode=self.ANY_FAILURE,
238240
)
239241
with self.subTest(reuse=reuse, exec=True):
240-
out, _ = self.run_embedded_interpreter(
242+
out, rc = self.run_embedded_interpreter(
241243
'test_replace_main_tstate',
242244
'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,
245247
)
246-
self.assertEqual(out.strip(), 'spam!')
248+
if rc == 0:
249+
self.assertEqual(out.strip(), 'spam!')
247250

248251
def test_fini_in_subthread(self):
249252
self.run_embedded_interpreter(
250253
'test_fini_in_subthread',
251254
# At the moment, this actually succeeds on all platforms,
252255
# except for Windows (STATUS_ACCESS_VIOLATION).
253-
returncode=None if MS_WINDOWS else 0,
256+
returncode=self.ANY_FAILURE if MS_WINDOWS else 0,
254257
)
255258

256259
def test_fini_in_main_thread_with_other_tstate(self):

0 commit comments

Comments
 (0)