Skip to content

Commit cb1aeec

Browse files
committed
fix test on iOS/Android
1 parent 0d2bf9c commit cb1aeec

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

‎Lib/test/test_interpreters/test_channels.py‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import importlib
21
import pickle
32
import threading
43
from textwrap import dedent
@@ -9,7 +8,7 @@
98
# Raise SkipTest if subinterpreters not supported.
109
_channels = import_helper.import_module('_interpchannels')
1110
from concurrent import interpreters
12-
from test.support import channels
11+
from test.support import channels, force_not_colorized
1312
from .utils import _run_output, TestBase
1413

1514

@@ -35,8 +34,14 @@ def test_highlevel_reloaded(self):
3534
importlib.reload(channels)
3635
"""));
3736

37+
@force_not_colorized
3838
def test_channel_id_types(self):
3939
# See https://github.com/python/cpython/issues/143376.
40+
code = """\
41+
import _interpchannels
42+
import re
43+
from concurrent import interpreters
44+
4045
class End:
4146
__slots__ = ()
4247
def __new__(cls, chan=None):
@@ -48,18 +53,19 @@ def _id(self):
4853
class Send(End): pass
4954
class Recv(End): pass
5055
51-
_ = importlib.reload(_channels)
52-
# ensure that the following tests do not have the registered bad types
53-
self.addCleanup(importlib.reload, _channels)
54-
_._register_end_types(Send, Recv)
55-
chan = _._channel_id(_.create(), _resolve=True)
56+
_interpchannels._register_end_types(Send, Recv)
57+
chan = _interpchannels._channel_id(_interpchannels.create(), _resolve=True)
5658
interp = interpreters.create()
57-
# The TypeError exception arises from our internal check,
58-
# but subinterpreters use a generic exception message instead
59-
# while retaining the original exception type.
60-
err = "does not support cross-interpreter data"
61-
with self.assertRaisesRegex(TypeError, err):
59+
try:
6260
interp.prepare_main(chan=Send(chan))
61+
finally:
62+
interp.close()
63+
"""
64+
65+
out, err = self.assert_python_failure("-c", code)
66+
self.assertEqual(out, '')
67+
errmsg = "TypeError: '_id' attribute must be an _interpchannels.ChannelID object, not object"
68+
self.assertIn(errmsg, err)
6369

6470

6571
class TestChannels(TestBase):

0 commit comments

Comments
 (0)