Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-32604: Clean up test.support.interpreters. #20926

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add TestSendRecv tests for different interpreters.
  • Loading branch information
ericsnowcurrently committed Jun 16, 2020
commit 09d572a123cb7136601a02e8643c5a835d14ca09
48 changes: 48 additions & 0 deletions Lib/test/test_interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,30 @@ def test_send_recv_same_interpreter(self):
assert obj is not orig, 'expected: obj is not orig'
"""))

@unittest.skip('broken (see BPO-...)')
def test_send_recv_different_interpreters(self):
r1, s1 = interpreters.create_channel()
r2, s2 = interpreters.create_channel()
orig1 = b'spam'
s1.send_nowait(orig1)
out = _run_output(
interpreters.create(),
dedent(f"""
obj1 = r.recv()
assert obj1 == b'spam', 'expected: obj1 == orig1'
# When going to another interpreter we get a copy.
assert id(obj1) != {id(orig1)}, 'expected: obj1 is not orig1'
orig2 = b'eggs'
print(id(orig2))
s.send_nowait(orig2)
"""),
channels=dict(r=r1, s=s2),
)
obj2 = r2.recv()

self.assertEqual(obj2, b'eggs')
self.assertNotEqual(id(obj2), int(out))

def test_send_recv_different_threads(self):
r, s = interpreters.create_channel()

Expand Down Expand Up @@ -531,3 +555,27 @@ def test_send_recv_nowait_same_interpreter(self):
# When going back to the same interpreter we get the same object.
assert obj is not orig, 'expected: obj is not orig'
"""))

@unittest.skip('broken (see BPO-...)')
def test_send_recv_nowait_different_interpreters(self):
r1, s1 = interpreters.create_channel()
r2, s2 = interpreters.create_channel()
orig1 = b'spam'
s1.send_nowait(orig1)
out = _run_output(
interpreters.create(),
dedent(f"""
obj1 = r.recv_nowait()
assert obj1 == b'spam', 'expected: obj1 == orig1'
# When going to another interpreter we get a copy.
assert id(obj1) != {id(orig1)}, 'expected: obj1 is not orig1'
orig2 = b'eggs'
print(id(orig2))
s.send_nowait(orig2)
"""),
channels=dict(r=r1, s=s2),
)
obj2 = r2.recv_nowait()

self.assertEqual(obj2, b'eggs')
self.assertNotEqual(id(obj2), int(out))