From 13b4f176abc53dca4b08f4ae4051ae4c3854ca5e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 28 Aug 2013 11:23:57 +1000 Subject: [PATCH 1/3] TST: improve datedetector error reporting --- testcases/datedetectortestcase.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/testcases/datedetectortestcase.py b/testcases/datedetectortestcase.py index 218abba9..a18c87aa 100644 --- a/testcases/datedetectortestcase.py +++ b/testcases/datedetectortestcase.py @@ -87,9 +87,11 @@ class DateDetectorTest(unittest.TestCase): log = sdate + "[sshd] error: PAM: Authentication failure" # exclude - # yoh: on [:6] see in above test - self.assertEqual(self.__datedetector.getTime(log)[:6], date[:6]) - self.assertEqual(self.__datedetector.getUnixTime(log), dateUnix) + #[ yoh: on [:6] see in above test + logtime = self.__datedetector.getTime(log) + self.assertIsNotNone(logtime, "getTime retrieved nothing: failure for %s" % sdate) + self.assertEqual(logtime[:6], date[:6], "getTime comparison failure for %s" % sdate) + self.assertEqual(self.__datedetector.getUnixTime(log), dateUnix, "getUnixTime failure for %s" % sdate) def testStableSortTemplate(self): old_names = [x.getName() for x in self.__datedetector.getTemplates()] From f2a60daea136c2e8c6ce33522822a8feca737779 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 28 Aug 2013 12:55:21 +1000 Subject: [PATCH 2/3] TST/BF: assertIsNotNone replaced with assertNotEqual for python 2.4 compatibility --- testcases/datedetectortestcase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testcases/datedetectortestcase.py b/testcases/datedetectortestcase.py index a18c87aa..457b90e9 100644 --- a/testcases/datedetectortestcase.py +++ b/testcases/datedetectortestcase.py @@ -89,7 +89,7 @@ class DateDetectorTest(unittest.TestCase): #[ yoh: on [:6] see in above test logtime = self.__datedetector.getTime(log) - self.assertIsNotNone(logtime, "getTime retrieved nothing: failure for %s" % sdate) + self.assertNotEqual(logtime, None, "getTime retrieved nothing: failure for %s" % sdate) self.assertEqual(logtime[:6], date[:6], "getTime comparison failure for %s" % sdate) self.assertEqual(self.__datedetector.getUnixTime(log), dateUnix, "getUnixTime failure for %s" % sdate) From 2acaef9d890a05f6ecdb669ebaa3fcf9d59220d0 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 29 Aug 2013 09:17:13 +1000 Subject: [PATCH 3/3] TST: more detail in assertion --- testcases/datedetectortestcase.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testcases/datedetectortestcase.py b/testcases/datedetectortestcase.py index 457b90e9..bc6a3865 100644 --- a/testcases/datedetectortestcase.py +++ b/testcases/datedetectortestcase.py @@ -87,11 +87,11 @@ class DateDetectorTest(unittest.TestCase): log = sdate + "[sshd] error: PAM: Authentication failure" # exclude - #[ yoh: on [:6] see in above test + # yoh: on [:6] see in above test logtime = self.__datedetector.getTime(log) self.assertNotEqual(logtime, None, "getTime retrieved nothing: failure for %s" % sdate) - self.assertEqual(logtime[:6], date[:6], "getTime comparison failure for %s" % sdate) - self.assertEqual(self.__datedetector.getUnixTime(log), dateUnix, "getUnixTime failure for %s" % sdate) + self.assertEqual(logtime[:6], date[:6], "getTime comparison failure for %s: \"%s\" is not \"%s\"" % (sdate, logtime[:6], date[:6])) + self.assertEqual(self.__datedetector.getUnixTime(log), dateUnix, "getUnixTime failure for %s: \"%s\" is not \"%s\"" % (sdate, logtime[:6], date[:6])) def testStableSortTemplate(self): old_names = [x.getName() for x in self.__datedetector.getTemplates()]