MCPcopy Index your code
hub / github.com/python/cpython / ChannelCloseFixture

Class ChannelCloseFixture

Lib/test/test__interpchannels.py:1409–1519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1407
1408
1409class ChannelCloseFixture(namedtuple('ChannelCloseFixture',
1410 'end interp other extra creator')):
1411
1412 # Set this to True to avoid creating interpreters, e.g. when
1413 # scanning through test permutations without running them.
1414 QUICK = False
1415
1416 def __new__(cls, end, interp, other, extra, creator):
1417 assert end in ('send', 'recv')
1418 if cls.QUICK:
1419 known = {}
1420 else:
1421 interp = Interpreter.from_raw(interp)
1422 other = Interpreter.from_raw(other)
1423 extra = Interpreter.from_raw(extra)
1424 known = {
1425 interp.name: interp,
1426 other.name: other,
1427 extra.name: extra,
1428 }
1429 if not creator:
1430 creator = 'same'
1431 self = super().__new__(cls, end, interp, other, extra, creator)
1432 self._prepped = set()
1433 self._state = ChannelState()
1434 self._known = known
1435 return self
1436
1437 @property
1438 def state(self):
1439 return self._state
1440
1441 @property
1442 def cid(self):
1443 try:
1444 return self._cid
1445 except AttributeError:
1446 creator = self._get_interpreter(self.creator)
1447 self._cid = self._new_channel(creator)
1448 return self._cid
1449
1450 def get_interpreter(self, interp):
1451 interp = self._get_interpreter(interp)
1452 self._prep_interpreter(interp)
1453 return interp
1454
1455 def expect_closed_error(self, end=None):
1456 if end is None:
1457 end = self.end
1458 if end == 'recv' and self.state.closed == 'send':
1459 return False
1460 return bool(self.state.closed)
1461
1462 def prep_interpreter(self, interp):
1463 self._prep_interpreter(interp)
1464
1465 def record_action(self, action, result):
1466 self._state = result

Callers 1

iter_fixturesMethod · 0.85

Calls 1

namedtupleFunction · 0.90

Tested by 1

iter_fixturesMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…