示例#1
0
 def testException(self):
     handler = DummyLogHandler()
     runner = LogRunner('mock_module', 'LoggingScraper', log_handler=handler, fake_error=True, catch_errors=True)
     self.assertEqual(None, runner.run())
     self.assertEqual(1, len(handler.logs))
     self.assertEqual('ERROR', handler.logs[0][0])
     self.assertTrue(handler.logs[0][1].startswith('Traceback (most recent call last):'))
     self.assertEqual('okscraper.cli.runner(LogRunner)', handler.logs[0][2])
示例#2
0
 def testOnlyErrors(self):
     handler = DummyLogHandler()
     runner = LogRunner('mock_module', 'LoggingScraper', log_handler=handler, log_verbosity=0, test_logs=[
         {'level': logging.ERROR, 'msg': 'ERROR!'},
     ])
     self.assertEqual('ok_LoggingScraper', runner.run())
     self.assertEqual([
         ('ERROR', 'ERROR!', 'mock_module.scrapers(LoggingScraper)'),
     ], handler.logs)