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

Method testLogging

IPython/core/tests/test_ultratb.py:450–470  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

448 # skip in 3.8 for now
449 @skipif(sys.version_info > (3,8))
450 def testLogging(self):
451 message = "An unexpected error occurred while tokenizing input"
452 cell = 'raise ValueError("""a\nb""")'
453
454 stream = io.StringIO()
455 handler = logging.StreamHandler(stream)
456 logger = logging.getLogger()
457 loglevel = logger.level
458 logger.addHandler(handler)
459 self.addCleanup(lambda: logger.removeHandler(handler))
460 self.addCleanup(lambda: logger.setLevel(loglevel))
461
462 logger.setLevel(logging.INFO)
463 with tt.AssertNotPrints(message):
464 ip.run_cell(cell)
465 self.assertNotIn(message, stream.getvalue())
466
467 logger.setLevel(logging.DEBUG)
468 with tt.AssertNotPrints(message):
469 ip.run_cell(cell)
470 self.assertIn(message, stream.getvalue())

Callers

nothing calls this directly

Calls 1

run_cellMethod · 0.45

Tested by

no test coverage detected