Skip to content

Commit

Permalink
Fix the test failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Jun 27, 2024
1 parent d3beea4 commit d78f655
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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 ---")
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d78f655

Please sign in to comment.