def test_log_messages_duration(self): """ Test duration report :return: """ obj = FinalStatus() obj.parameters = BetterDict() obj.log = logger_mock() obj.prepare() obj.start_time -= 120005 obj.post_process() self.assertEqual("Test duration: 1 day, 9:20:05\n", obj.log.info_buf.getvalue())
def test_log_messages_duration(self): """ Test duration report :return: """ obj = FinalStatus() obj.parameters = BetterDict() log_recorder = RecordingHandler() obj.log.addHandler(log_recorder) obj.prepare() obj.start_time -= 120005 obj.post_process() self.assertEqual("Test duration: 1 day, 9:20:05\n", log_recorder.info_buff.getvalue()) obj.log.removeHandler(log_recorder)
def test_log_messages_duration(self): """ Test duration report :return: """ obj = FinalStatus() obj.engine = EngineEmul() obj.parameters = BetterDict() self.sniff_log(obj.log) obj.prepare() obj.start_time -= 120005 obj.post_process() self.assertEqual("Test duration: 1 day, 9:20:05\n", self.log_recorder.info_buff.getvalue())
def test_log_messages_duration(self): """ Test duration report :return: """ obj = FinalStatus() obj.engine = EngineEmul() obj.parameters = BetterDict() self.sniff_log(obj.log) obj.prepare() obj.startup() obj.shutdown() obj.start_time -= 120005 obj.post_process() self.assertEqual("Test duration: 1 day, 9:20:05\n", self.log_recorder.info_buff.getvalue())
def test_func_report(self): obj = FinalStatus() obj.engine = EngineEmul() obj.parameters = BetterDict() log_recorder = RecordingHandler() obj.log.addHandler(log_recorder) obj.prepare() obj.aggregated_results(*self.__get_func_tree()) obj.post_process() info_log = log_recorder.info_buff.getvalue() self.assertIn("Total: 3 tests", info_log) self.assertIn("Test TestClass.case2", info_log) self.assertIn("stacktrace2", info_log) self.assertIn("Test TestClass.case3", info_log) self.assertIn("stacktrace3", info_log) obj.log.removeHandler(log_recorder)
def test_func_report(self): obj = FinalStatus() obj.engine = EngineEmul() obj.parameters = BetterDict() self.sniff_log(obj.log) obj.prepare() obj.aggregated_results(*self.__get_func_tree()) obj.post_process() info_log = self.log_recorder.info_buff.getvalue() warn_log = self.log_recorder.warn_buff.getvalue() self.assertIn("Total: 3 tests", info_log) self.assertIn("Test TestClass.case2 failed: something broke", warn_log) self.assertIn("stacktrace2", warn_log) self.assertIn("Test TestClass.case3 failed: something is badly broken", warn_log) self.assertIn("stacktrace3", warn_log)
def test_func_report_all_no_stacktrace(self): obj = FinalStatus() obj.engine = EngineEmul() obj.parameters = BetterDict.from_dict({"report-tests": "all", "print-stacktrace": False}) self.sniff_log(obj.log) obj.prepare() obj.startup() obj.shutdown() obj.aggregated_results(*self.__get_func_tree()) obj.post_process() info_log = self.log_recorder.info_buff.getvalue() self.assertIn("Total: 3 tests", info_log) self.assertIn("Test TestClass.case1 - PASSED", info_log) self.assertIn("Test TestClass.case2 - FAILED", info_log) self.assertIn("Test TestClass.case3 - BROKEN", info_log) self.assertNotIn("stacktrace2", info_log) self.assertNotIn("stacktrace3", info_log)
def test_func_report(self): obj = FinalStatus() obj.engine = EngineEmul() obj.parameters = BetterDict() self.sniff_log(obj.log) obj.prepare() obj.startup() obj.shutdown() obj.aggregated_results(*self.__get_func_tree()) obj.post_process() info_log = self.log_recorder.info_buff.getvalue() warn_log = self.log_recorder.warn_buff.getvalue() self.assertIn("Total: 3 tests", info_log) self.assertIn("Test TestClass.case2 failed: something broke", warn_log) self.assertIn("stacktrace2", warn_log) self.assertIn("Test TestClass.case3 failed: something is badly broken", warn_log) self.assertIn("stacktrace3", warn_log)
def test_func_report_all_no_stacktrace(self): obj = FinalStatus() obj.engine = EngineEmul() obj.parameters = BetterDict() log_recorder = RecordingHandler() obj.log.addHandler(log_recorder) obj.parameters.merge({"report-tests": "all", "print-stacktrace": False}) obj.prepare() obj.aggregated_results(*self.__get_func_tree()) obj.post_process() info_log = log_recorder.info_buff.getvalue() self.assertIn("Total: 3 tests", info_log) self.assertIn("Test TestClass.case1 - PASSED", info_log) self.assertIn("Test TestClass.case2 - FAILED", info_log) self.assertIn("Test TestClass.case3 - BROKEN", info_log) self.assertNotIn("stacktrace2", info_log) self.assertNotIn("stacktrace3", info_log) obj.log.removeHandler(log_recorder)