]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
logging: only test log.err when Twisted is new enough to let us ignore the generated...
authorBrian Warner <warner@allmydata.com>
Tue, 20 Nov 2007 01:37:00 +0000 (18:37 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 20 Nov 2007 01:37:00 +0000 (18:37 -0700)
src/allmydata/test/test_util.py

index eaaf636d3019fae9a77fb145a5510f776513de36..62f69c2a8e23802fbcc68bd73629157cb31f40c6 100644 (file)
@@ -409,13 +409,7 @@ class Log(unittest.TestCase):
         log.msg("sub message", parent=num)
         log.msg("numbered message", number=47)
 
-        f = failure.Failure(SampleError())
-        num2 = log.err(f)
-        log.err(f, parent=num2)
-        log.err(f, number=48)
-
         logs = self.catcher[:]
-        self.flushLoggedErrors(SampleError)
 
         self.failUnlessEqual(logs[0]['message'], ("this is a message",))
         self.failUnlessEqual(logs[0]['number'], num)
@@ -429,18 +423,30 @@ class Log(unittest.TestCase):
         self.failUnlessEqual(logs[2]['number'], 47)
         self.failUnlessEqual(logs[2]['parent'], None)
 
-        self.failUnlessEqual(logs[3]['message'], ())
-        self.failUnlessEqual(logs[3]['failure'], f)
-        self.failUnlessEqual(logs[3]['number'], num2)
-        self.failUnlessEqual(logs[3]['parent'], None)
+    def test_err(self):
+        if not hasattr(self, "flushLoggedErrors"):
+            raise unittest.SkipTest("need newer Twisted to test log.err")
 
-        self.failUnlessEqual(logs[4]['message'], ())
-        self.failUnlessEqual(logs[4]['failure'], f)
-        self.failUnlessEqual(logs[4]['number'], num2+1)
-        self.failUnlessEqual(logs[4]['parent'], num2)
+        f = failure.Failure(SampleError())
+        num2 = log.err(f)
+        log.err(f, parent=num2)
+        log.err(f, number=48)
+
+        logs = self.catcher[:]
+        self.flushLoggedErrors(SampleError)
 
-        self.failUnlessEqual(logs[5]['message'], ())
-        self.failUnlessEqual(logs[5]['failure'], f)
-        self.failUnlessEqual(logs[5]['number'], 48)
-        self.failUnlessEqual(logs[5]['parent'], None)
+        self.failUnlessEqual(logs[0]['message'], ())
+        self.failUnlessEqual(logs[0]['failure'], f)
+        self.failUnlessEqual(logs[0]['number'], num2)
+        self.failUnlessEqual(logs[0]['parent'], None)
+
+        self.failUnlessEqual(logs[1]['message'], ())
+        self.failUnlessEqual(logs[1]['failure'], f)
+        self.failUnlessEqual(logs[1]['number'], num2+1)
+        self.failUnlessEqual(logs[1]['parent'], num2)
+
+        self.failUnlessEqual(logs[2]['message'], ())
+        self.failUnlessEqual(logs[2]['failure'], f)
+        self.failUnlessEqual(logs[2]['number'], 48)
+        self.failUnlessEqual(logs[2]['parent'], None)