MCPcopy Create free account
hub / github.com/ipython/ipython / __exit__

Method __exit__

IPython/testing/tools.py:364–379  ·  view source on GitHub ↗
(self, etype, value, traceback)

Source from the content-addressed store, hash-verified

362 setattr(sys, self.channel, self.buffer if self.suppress else self.tee)
363
364 def __exit__(self, etype, value, traceback):
365 try:
366 if value is not None:
367 # If an error was raised, don't check anything else
368 return False
369 self.tee.flush()
370 setattr(sys, self.channel, self.orig_stream)
371 printed = self.buffer.getvalue()
372 for s in self.s:
373 if isinstance(s, _re_type):
374 assert s.search(printed), notprinted_msg.format(s.pattern, self.channel, printed)
375 else:
376 assert s in printed, notprinted_msg.format(s, self.channel, printed)
377 return False
378 finally:
379 self.tee.close()
380
381printed_msg = """Found {0!r} in printed output (on {1}):
382-------

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