[asterisk-commits] kmoore: testsuite/asterisk/trunk r3160 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 27 11:00:04 CDT 2012


Author: kmoore
Date: Tue Mar 27 10:59:59 2012
New Revision: 3160

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3160
Log:
Cleanup in SimpleTestCase

Use "logger" instead of "LOGGER" and convert to using the built-in origination
failure handler.

Modified:
    asterisk/trunk/lib/python/asterisk/SimpleTestCase.py

Modified: asterisk/trunk/lib/python/asterisk/SimpleTestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/SimpleTestCase.py?view=diff&rev=3160&r1=3159&r2=3160
==============================================================================
--- asterisk/trunk/lib/python/asterisk/SimpleTestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/SimpleTestCase.py Tue Mar 27 10:59:59 2012
@@ -13,7 +13,7 @@
 sys.path.append("lib/python")
 from TestCase import TestCase
 
-LOGGER = logging.getLogger(__name__)
+logger = logging.getLogger(__name__)
 
 class SimpleTestCase(TestCase):
     '''The base class for extremely simple tests requiring only a spawned call
@@ -28,19 +28,11 @@
         self.create_asterisk()
 
     def ami_connect(self, ami):
-        LOGGER.info("Initiating call to local/100 at test on Echo() for simple test")
+        logger.info("Initiating call to local/100 at test on Echo() for simple test")
 
         ami.registerEvent('UserEvent', self.__event_cb)
         ami.registerEvent('Newchannel', self.__channel_cb)
-        df = ami.originate("local/100 at test", application="Echo")
-
-        def handle_failure(reason):
-            LOGGER.info("error sending originate:")
-            LOGGER.info(reason.getTraceback())
-            self.stop_reactor()
-            return reason
-
-        df.addErrback(handle_failure)
+        ami.originate("local/100 at test", application="Echo").addErrback(handleOriginationFailure)
 
     def __channel_cb(self, ami, event):
         if not self.hangup_chan:
@@ -51,13 +43,13 @@
             self.event_count += 1
             if self.event_count == self.expected_events:
                 self.passed = True
-                LOGGER.info("Test ending, hanging up channel")
+                logger.info("Test ending, hanging up channel")
                 self.ami[0].hangup(self.hangup_chan).addCallbacks(
                     self.hangup)
 
     def hangup(self, result):
         '''Now that the channels are hung up, the test can be ended'''
-        LOGGER.info("Hangup complete, stopping reactor")
+        logger.info("Hangup complete, stopping reactor")
         self.stop_reactor()
 
     def verify_event(self, event):




More information about the asterisk-commits mailing list