diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 2dc8eaac95d1f1..a8d0ebfa4b4c0d 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -93,6 +93,8 @@ def setUp(self): def tearDown(self): os.chdir(self.oldcwd) + ANY_FAILURE = object() + def run_embedded_interpreter(self, *args, env=None, timeout=None, returncode=0, input=None, cwd=None): @@ -117,7 +119,7 @@ def run_embedded_interpreter(self, *args, env=None, p.terminate() p.wait() raise - if returncode is None: + if returncode is self.ANY_FAILURE: returncode = 1 if p.returncode == 0 else p.returncode if p.returncode != returncode and support.verbose: print(f"--- {cmd} failed ---") @@ -234,23 +236,24 @@ def test_replace_main_tstate(self): self.run_embedded_interpreter( 'test_replace_main_tstate', # At the moment, this fails because main_tstate gets broken. - returncode=None, + returncode=self.ANY_FAILURE, ) with self.subTest(reuse=reuse, exec=True): - out, _ = self.run_embedded_interpreter( + out, rc = self.run_embedded_interpreter( 'test_replace_main_tstate', 'print("spam!")', - # At the moment, this actually succeeds on all platforms. - returncode=0, + # At the moment, this fails because main_tstate gets broken. + returncode=self.ANY_FAILURE, ) - self.assertEqual(out.strip(), 'spam!') + if rc == 0: + self.assertEqual(out.strip(), 'spam!') def test_fini_in_subthread(self): self.run_embedded_interpreter( 'test_fini_in_subthread', # At the moment, this actually succeeds on all platforms, # except for Windows (STATUS_ACCESS_VIOLATION). - returncode=None if MS_WINDOWS else 0, + returncode=self.ANY_FAILURE if MS_WINDOWS else 0, ) def test_fini_in_main_thread_with_other_tstate(self):