MCPcopy Index your code
hub / github.com/ipython/ipython / __exit__

Method __exit__

IPython/testing/tools.py:336–353  ·  view source on GitHub ↗
(self, etype: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType])

Source from the content-addressed store, hash-verified

334 setattr(sys, self.channel, self.buffer if self.suppress else self.tee)
335
336 def __exit__(self, etype: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]):
337 __tracebackhide__ = True
338
339 try:
340 if value is not None:
341 # If an error was raised, don't check anything else
342 return False
343 self.tee.flush()
344 setattr(sys, self.channel, self.orig_stream)
345 printed = self.buffer.getvalue()
346 for s in self.s:
347 if isinstance(s, _re_type):
348 assert s.search(printed), notprinted_msg.format(s.pattern, self.channel, printed)
349 else:
350 assert s in printed, notprinted_msg.format(s, self.channel, printed)
351 return False
352 finally:
353 self.tee.close()
354
355printed_msg = """Found {0!r} in printed output (on {1}):
356-------

Callers

nothing calls this directly

Calls 4

flushMethod · 0.45
searchMethod · 0.45
formatMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected