Author: mjordan
Date: Sun Jan 11 20:20:41 2015
New Revision: 6240
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=6240
Log:
channels/pjsip/keep_alive: Fix total_seconds error on Python 2.6
Python 2.6 timedelta objects do not implement a total_seconds method. Nuts.
This patch implements its equivalent so that the test can run on build agents
with pre-2.7 versions of Python.
Modified:
asterisk/trunk/tests/channels/pjsip/keep_alive/keep_alive.py
Modified: asterisk/trunk/tests/channels/pjsip/keep_alive/keep_alive.py
URL:
http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/keep_alive/keep_alive.py?view=diff&rev=6240&r1=6239&r2=6240
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/keep_alive/keep_alive.py (original)
+++ asterisk/trunk/tests/channels/pjsip/keep_alive/keep_alive.py Sun Jan 11
20:20:41 2015
@@ -67,6 +67,19 @@
self.test_object.stop_reactor()
+def total_seconds(td):
+ """Since Python 2.6 doesn't contain total_seconds, we implement its
+ equivalent here.
+
+ Keyword Arguments:
+ td -- the timedelta object
+
+ Returns:
+ The total number of seconds in the timedelta object
+ """
+ return float(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6)
/ 10**6
+
+
class KeepAliveReceiver(object):
"""A pluggable module for verifying the keep_alive_interval option"""
@@ -103,7 +116,7 @@
self.test_object.set_passed(False)
return result
- deltas = [round((j[0] - i[0]).total_seconds()) for i, j in
+ deltas = [round(total_seconds(j[0] - i[0])) for i, j in
zip(received_packets[:-1], received_packets[1:])]
if not all([d == 2 for d in deltas]):
LOGGER.warn('Failed to get expected deltas between keep-alives')
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
svn-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/svn-commits