(rch, sch, unbound=None, presize=0)
| 384 | |
| 385 | def test_send_cleared_with_subinterpreter(self): |
| 386 | def common(rch, sch, unbound=None, presize=0): |
| 387 | if not unbound: |
| 388 | extraargs = '' |
| 389 | elif unbound is channels.UNBOUND: |
| 390 | extraargs = ', unbounditems=channels.UNBOUND' |
| 391 | elif unbound is channels.UNBOUND_ERROR: |
| 392 | extraargs = ', unbounditems=channels.UNBOUND_ERROR' |
| 393 | elif unbound is channels.UNBOUND_REMOVE: |
| 394 | extraargs = ', unbounditems=channels.UNBOUND_REMOVE' |
| 395 | else: |
| 396 | raise NotImplementedError(repr(unbound)) |
| 397 | interp = interpreters.create() |
| 398 | |
| 399 | _run_output(interp, dedent(f""" |
| 400 | from test.support import channels |
| 401 | sch = channels.SendChannel({sch.id}) |
| 402 | obj1 = b'spam' |
| 403 | obj2 = b'eggs' |
| 404 | sch.send_nowait(obj1{extraargs}) |
| 405 | sch.send_nowait(obj2{extraargs}) |
| 406 | """)) |
| 407 | self.assertEqual( |
| 408 | _channels.get_count(rch.id), |
| 409 | presize + 2, |
| 410 | ) |
| 411 | |
| 412 | if presize == 0: |
| 413 | obj1 = rch.recv() |
| 414 | self.assertEqual(obj1, b'spam') |
| 415 | self.assertEqual( |
| 416 | _channels.get_count(rch.id), |
| 417 | presize + 1, |
| 418 | ) |
| 419 | |
| 420 | return interp |
| 421 | |
| 422 | with self.subTest('default'): # UNBOUND |
| 423 | rch, sch = channels.create() |
nothing calls this directly
no test coverage detected