Skip to content

Commit 5443e2c

Browse files
Fix tests.
1 parent 59e0e0f commit 5443e2c

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

Lib/test/test__xxinterpchannels.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,16 +1017,16 @@ def test_close_multiple_users(self):
10171017
_channels.recv({cid})
10181018
"""))
10191019
channels.close(cid)
1020-
with self.assertRaises(interpreters.RunFailedError) as cm:
1021-
interpreters.run_string(id1, dedent(f"""
1020+
1021+
excsnap = interpreters.run_string(id1, dedent(f"""
10221022
_channels.send({cid}, b'spam')
10231023
"""))
1024-
self.assertIn('ChannelClosedError', str(cm.exception))
1025-
with self.assertRaises(interpreters.RunFailedError) as cm:
1026-
interpreters.run_string(id2, dedent(f"""
1024+
self.assertIn('ChannelClosedError', excsnap.type)
1025+
1026+
excsnap = interpreters.run_string(id2, dedent(f"""
10271027
_channels.send({cid}, b'spam')
10281028
"""))
1029-
self.assertIn('ChannelClosedError', str(cm.exception))
1029+
self.assertIn('ChannelClosedError', excsnap.type)
10301030

10311031
def test_close_multiple_times(self):
10321032
cid = channels.create()

Lib/test/test_import/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,10 +1968,12 @@ def test_disallowed_reimport(self):
19681968
print(_testsinglephase)
19691969
''')
19701970
interpid = _interpreters.create()
1971-
with self.assertRaises(_interpreters.RunFailedError):
1972-
_interpreters.run_string(interpid, script)
1973-
with self.assertRaises(_interpreters.RunFailedError):
1974-
_interpreters.run_string(interpid, script)
1971+
1972+
excsnap = _interpreters.run_string(interpid, script)
1973+
self.assertIsNot(excsnap, None)
1974+
1975+
excsnap = _interpreters.run_string(interpid, script)
1976+
self.assertIsNot(excsnap, None)
19751977

19761978

19771979
class TestSinglePhaseSnapshot(ModuleSnapshot):

Lib/test/test_importlib/test_util.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -655,25 +655,19 @@ def test_magic_number(self):
655655
@unittest.skipIf(_interpreters is None, 'subinterpreters required')
656656
class IncompatibleExtensionModuleRestrictionsTests(unittest.TestCase):
657657

658-
ERROR = re.compile("^ImportError: module (.*) does not support loading in subinterpreters")
659-
660658
def run_with_own_gil(self, script):
661659
interpid = _interpreters.create(isolated=True)
662-
try:
663-
_interpreters.run_string(interpid, script)
664-
except _interpreters.RunFailedError as exc:
665-
if m := self.ERROR.match(str(exc)):
666-
modname, = m.groups()
667-
raise ImportError(modname)
660+
excsnap = _interpreters.run_string(interpid, script)
661+
if excsnap is not None:
662+
if excsnap.type == 'ImportError':
663+
raise ImportError(excsnap.msg)
668664

669665
def run_with_shared_gil(self, script):
670666
interpid = _interpreters.create(isolated=False)
671-
try:
672-
_interpreters.run_string(interpid, script)
673-
except _interpreters.RunFailedError as exc:
674-
if m := self.ERROR.match(str(exc)):
675-
modname, = m.groups()
676-
raise ImportError(modname)
667+
excsnap = _interpreters.run_string(interpid, script)
668+
if excsnap is not None:
669+
if excsnap.type == 'ImportError':
670+
raise ImportError(excsnap.msg)
677671

678672
@unittest.skipIf(_testsinglephase is None, "test requires _testsinglephase module")
679673
def test_single_phase_init_module(self):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy