def setUp(self): super().setUp() self.enter_context( treelog.set( treelog.TeeLog(treelog.StdoutLog(), treelog.LoggingLog()))) self.enter_context(_builtin_warnings.catch_warnings()) _builtin_warnings.simplefilter('error', warnings.NutilsWarning)
def output_tester(self): with self.assertLogs('nutils') as cm: yield treelog.LoggingLog() self.assertEqual(cm.output, [ 'Level 25:nutils:my message', 'INFO:nutils:test.dat', 'INFO:nutils:my context > iter 1 > a', 'INFO:nutils:my context > iter 2 > b', 'INFO:nutils:my context > iter 3 > c', 'ERROR:nutils:my context > multiple..\n ..lines', 'INFO:nutils:my context > generating', 'Level 25:nutils:my context > test.dat', 'WARNING:nutils:generate_test > test.dat', 'INFO:nutils:context step=0 > foo', 'INFO:nutils:context step=1 > bar', 'ERROR:nutils:same.dat', 'WARNING:nutils:warn' ])
def setUpContext(self, stack): stack.enter_context(treelog.set(treelog.LoggingLog()))
def setUp(self): super().setUp() self.enter_context( treelog.set( treelog.TeeLog(treelog.StdoutLog(), treelog.LoggingLog())))
def setUpContext(self, stack): stack.enter_context( treelog.set( treelog.TeeLog(treelog.StdoutLog(), treelog.LoggingLog())))
def test_replay_in_current(self): recordlog = treelog.RecordLog() recordlog.write('test', level=treelog.proto.Level.info) with self.assertSilent(), treelog.set( treelog.LoggingLog()), self.assertLogs('nutils'): recordlog.replay()