Instrumented base.py to get more info from errors on CI
authorSteve Powell <steve@rabbitmq.com>
Thu, 28 Jun 2012 17:09:49 +0100
changeset 7431f61fe671d14
parent 740 18491dbb040d
child 745 0ae1080f4429
child 748 c672c4f3e43c
child 750 d6f718bc7d9c
Instrumented base.py to get more info from errors on CI
test/src/base.py
     1.1 --- a/test/src/base.py	Fri Jun 01 16:18:49 2012 +0100
     1.2 +++ b/test/src/base.py	Thu Jun 28 17:09:49 2012 +0100
     1.3 @@ -51,12 +51,27 @@
     1.4  
     1.5     def assertListener(self, errMsg, numMsgs=0, numErrs=0, numRcts=0, timeout=1):
     1.6          if numMsgs + numErrs + numRcts > 0:
     1.7 -            self.assertTrue(self.listener.await(timeout), errMsg + " (#awaiting)")
     1.8 +            self._assertTrue(self.listener.await(timeout), errMsg + " (#awaiting)")
     1.9          else:
    1.10 -            self.assertFalse(self.listener.await(timeout), errMsg + " (#awaiting)")
    1.11 -        self.assertEquals(numMsgs, len(self.listener.messages), errMsg + " (#messages)")
    1.12 -        self.assertEquals(numErrs, len(self.listener.errors), errMsg + " (#errors)")
    1.13 -        self.assertEquals(numRcts, len(self.listener.receipts), errMsg + " (#receipts)")
    1.14 +            self._assertFalse(self.listener.await(timeout), errMsg + " (#awaiting)")
    1.15 +        self._assertEquals(numMsgs, len(self.listener.messages), errMsg + " (#messages)")
    1.16 +        self._assertEquals(numErrs, len(self.listener.errors), errMsg + " (#errors)")
    1.17 +        self._assertEquals(numRcts, len(self.listener.receipts), errMsg + " (#receipts)")
    1.18 +
    1.19 +   def _assertTrue(self, bool, msg):
    1.20 +       if not bool:
    1.21 +           self.listener.print_state(msg, True)
    1.22 +           self.assertTrue(bool, msg)
    1.23 +
    1.24 +   def _assertFalse(self, bool, msg):
    1.25 +       if bool:
    1.26 +           self.listener.print_state(msg, True)
    1.27 +           self.assertFalse(bool, msg)
    1.28 +
    1.29 +   def _assertEquals(self, expected, actual, msg):
    1.30 +       if expected != actual:
    1.31 +           self.listener.print_state(msg, True)
    1.32 +           self.assertEquals(expected, actual, msg)
    1.33  
    1.34     def assertListenerAfter(self, verb, errMsg="", numMsgs=0, numErrs=0, numRcts=0, timeout=1):
    1.35          num = numMsgs + numErrs + numRcts
    1.36 @@ -106,12 +121,16 @@
    1.37      def await(self, timeout=10):
    1.38          return self.latch.await(timeout)
    1.39  
    1.40 -    def print_state(self, hdr=""):
    1.41 +    def print_state(self, hdr="", full=False):
    1.42          print hdr,
    1.43          print '#messages:', len(self.messages),
    1.44          print '#errors:', len(self.errors),
    1.45          print '#receipts:', len(self.receipts),
    1.46          print 'Remaining count:', self.latch.get_count()
    1.47 +        if full:
    1.48 +            if len(self.messages) != 0: print 'Messages:', self.messages
    1.49 +            if len(self.errors) != 0: print 'Messages:', self.errors
    1.50 +            if len(self.receipts) != 0: print 'Messages:', self.receipts
    1.51  
    1.52  class Latch(object):
    1.53