[Asterisk-code-review] testsuite: Python 3 compatibility inital commit (testsuite[development/16/python3])
Michael Bradeen
asteriskteam at digium.com
Mon Mar 14 13:40:36 CDT 2022
Michael Bradeen has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/18199 )
Change subject: testsuite: Python 3 compatibility inital commit
......................................................................
testsuite: Python 3 compatibility inital commit
Multiple changes for compatibility. Requires latest version of all
pre-requisites and assumes a change in starpy to replace the now
protected data field async with asyncrn.
Changes also to print, replaced old library references, broke up
sub-parameters, etc.
Change-Id: Ic7a1d72b174df59107370fcb03fae9dc4cdfc9d3
---
M contrib/scripts/cel-to-yaml.py
M contrib/scripts/rlmi_demo.py
M lib/python/asterisk/matcher_listener.py
M lib/python/asterisk/pluggable_modules.py
M lib/python/asterisk/realtime_test_module.py
M lib/python/asterisk/syncami.py
M lib/python/asterisk/test_case.py
M lib/python/asterisk/test_runner.py
M lib/python/protocols/ipstack.py
M lib/python/protocols/layer4/tcp.py
M tests/agi/nominal/run-test
M tests/apps/chanspy/chanspy_w_mixmonitor/run-test
M tests/apps/directory/directory_attendant_exit/run-test
M tests/apps/directory/directory_context_operator_exit/run-test
M tests/apps/directory/directory_operator_exit/run-test
M tests/apps/voicemail/check_voicemail_options_change_password/voicemailpwcheck.py
M tests/blind-transfer-parkingtimeout/run-test
M tests/bridge/bridge_action/bridge_action.py
M tests/channels/SIP/noload_res_srtp/run-test
M tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
M tests/channels/SIP/refer_replaces_to_self/run-test
M tests/channels/SIP/secure_bridge_media/run-test
M tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test
M tests/channels/SIP/sip_one_legged_transfer_v6/run-test
M tests/channels/SIP/sip_srtp/srtp_call/run-test
M tests/channels/SIP/tcpauthtimeout/timeout_should_happen/timeout.py
M tests/channels/pjsip/resolver/naptr/explicit_transport_configured/dns_zones/example.com
M tests/channels/pjsip/resolver/naptr/order/dns_zones/example.com
M tests/channels/pjsip/resolver/naptr/preference/dns_zones/example.com
M tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com
M tests/channels/pjsip/resolver/naptr/restricted_transport/dns_zones/example.com
M tests/channels/pjsip/resolver/naptr/transport_tcp/dns_zones/example.com
M tests/channels/pjsip/resolver/naptr/transport_udp/dns_zones/example.com
M tests/channels/pjsip/resolver/naptr/transport_unspecified/dns_zones/example.com
M tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py
M tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
M tests/channels/pjsip/rtp/rtp_keepalive/direct_media/rtp.py
M tests/codecs/audio_analyzer.py
M tests/fastagi/channel-status/run-test
M tests/fastagi/connect/run-test
M tests/fastagi/database/run-test
M tests/fastagi/record-file/run-test
M tests/fastagi/stream-file/run-test
M tests/fastagi/wait-for-digit/run-test
M tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py
M tests/fax/sip/gateway_g711_t38/run-test
M tests/fax/sip/gateway_mix1/run-test
M tests/fax/sip/gateway_mix3/run-test
M tests/fax/sip/gateway_mix4/run-test
M tests/fax/sip/gateway_native_t38/run-test
M tests/fax/sip/gateway_no_t38/run-test
M tests/fax/sip/gateway_t38_g711/run-test
M tests/fax/sip/gateway_timeout1/run-test
M tests/fax/sip/gateway_timeout2/run-test
M tests/fax/sip/gateway_timeout3/run-test
M tests/fax/sip/gateway_timeout4/run-test
M tests/fax/sip/gateway_timeout5/run-test
M tests/funcs/func_srv/run-test
M tests/hep/hep_capture_node.py
M tests/manager/userevent/event.py
M tests/masquerade/run-test
M tests/rtp/strict_rtp/strict_rtp_seqno/strict_rtp.py
M tests/rtp/strict_rtp/strict_rtp_yes/strict_rtp.py
63 files changed, 397 insertions(+), 384 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/99/18199/1
diff --git a/contrib/scripts/cel-to-yaml.py b/contrib/scripts/cel-to-yaml.py
index f91aa0e..67c6c70 100755
--- a/contrib/scripts/cel-to-yaml.py
+++ b/contrib/scripts/cel-to-yaml.py
@@ -48,7 +48,7 @@
result.append(blob)
raw_yaml = yaml.dump(result)
raw_yaml = raw_yaml.replace(',', '\n').replace('}', '').replace('{', '')
- print raw_yaml
+ print(raw_yaml)
return 0
diff --git a/contrib/scripts/rlmi_demo.py b/contrib/scripts/rlmi_demo.py
index 3e9daf9..14f00f3 100755
--- a/contrib/scripts/rlmi_demo.py
+++ b/contrib/scripts/rlmi_demo.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-"""Demonstration of parsing and printing RLMI XML document.
+"""Demonstration of parsing and print(ing RLMI XML document.
This script is meant to demonstrate how, given an RLMI XML document, one can use
the pyxb-generated rlmi module to parse the XML document into easy-to peruse
@@ -23,46 +23,46 @@
list_elem = rlmi.CreateFromDocument(xml)
# The outermost XML element in an RLMI document is the 'list' element.
-print 'list'
+print( 'list'
# pyxb performs type-checking and type conversion of elements that it comes
# across in XML documents. In this case, the list element's version attribute is
# an integer, and the fullState attribute is a boolean. This is why the str()
# function is necessary in order to convert to string for the concatenation.
-print '\t' + str(list_elem.version)
-print '\t' + str(list_elem.fullState)
-print '\t' + list_elem.uri
+print('\t' + str(list_elem.version))
+print('\t' + str(list_elem.fullState))
+print('\t' + list_elem.uri)
# A list element may have zero or more name elements in it. This is a
# user-visible name for the list. The main reason why more than one name may
# exist for a list would be because it is expressed in multiple languages.
# Asterisk RLMI lists will have only a single name.
for name in list_elem.name:
- print '\tname'
+ print('\tname')
# Parsed XML documents have their attributes accessed as members on an
# object.
- print '\t\t' + name.lang
+ print('\t\t' + name.lang)
# The content of XML elements is accessed through the value() member.
- print '\t\t' + name.value()
+ print('\t\t' + name.value())
# A list element may have zero or more resource elements in it. The resources
# represent the resources that make up the list (duh).
for resource in list_elem.resource:
- print '\tresource'
- print '\t\t' + resource.uri
+ print('\tresource')
+ print('\t\t' + resource.uri)
# Resources may have names associated with them, just like the list does.
# Asterisk will use the name of the list from the configuration file here.
for name in resource.name:
- print '\t\tname'
- print '\t\t\t' + name.value()
+ print('\t\tname')()
+ print('\t\t\t' + name.value())
# Resources may have zero or more instance elements on them. The reason that
# more than one instance element may exist for a resource is that a resource
# may correspond to a single subscription that forks, resulting in multiple
# instances of the resource being represented. In Asterisk's case, there
# will be a single instance per resource.
for instance in resource.instance:
- print '\t\tinstance'
- print '\t\t\t' + instance.id
- print '\t\t\t' + instance.state
+ print('\t\tinstance')
+ print('\t\t\t' + instance.id)
+ print('\t\t\t' + instance.state)
# If an instance has a cid, it indicates that there is a body element
# in the multipart body that corresponds to the instance. The cid
# corresponds to the Content-ID header in that body part.
if instance.cid:
- print '\t\t\t' + instance.cid
+ print('\t\t\t' + instance.cid)
diff --git a/lib/python/asterisk/matcher_listener.py b/lib/python/asterisk/matcher_listener.py
index cd2ca5a..18ed16d 100644
--- a/lib/python/asterisk/matcher_listener.py
+++ b/lib/python/asterisk/matcher_listener.py
@@ -72,5 +72,6 @@
msg -- The message received via the udp
"""
- if not any(f for f in self.filter_msgs if re.match(f, msg)):
+ msgstring = msg.decode('utf8')
+ if not any(f for f in self.filter_msgs if re.match(f, msgstring)):
self.check(msg)
diff --git a/lib/python/asterisk/pluggable_modules.py b/lib/python/asterisk/pluggable_modules.py
index 22da37e..a696123 100644
--- a/lib/python/asterisk/pluggable_modules.py
+++ b/lib/python/asterisk/pluggable_modules.py
@@ -50,7 +50,7 @@
'scenario-name': None,
'id': '0',
'account': None,
- 'async': 'False',
+ 'asyncrn': 'False',
'event': None,
'timeout': None,
'codecs': None,
@@ -124,7 +124,7 @@
timeout=self.config['timeout'],
account=self.config['account'],
codecs=self.config['codecs'],
- async=self.config['async'])
+ asyncrn=self.config['asyncrn'])
else:
defer = self.ami.originate(channel=self.config['channel'],
application=self.config['application'],
@@ -132,7 +132,7 @@
timeout=self.config['timeout'],
account=self.config['account'],
codecs=self.config['codecs'],
- async=self.config['async'])
+ asyncrn=self.config['asyncrn'])
defer.addErrback(self.failure)
def scenario_started(self, result):
diff --git a/lib/python/asterisk/realtime_test_module.py b/lib/python/asterisk/realtime_test_module.py
index da97422..bffdf46 100644
--- a/lib/python/asterisk/realtime_test_module.py
+++ b/lib/python/asterisk/realtime_test_module.py
@@ -6,9 +6,10 @@
This program is free software, distributed under the terms of
the GNU General Public License Version 2.
"""
+from encodings import utf_8
import logging
import sys
-import cgi
+import html
import re
from twisted.internet import reactor
@@ -101,7 +102,7 @@
:returns: List of rows that match the given input.
:raises: Keyerror if a table does not exist with name table_name
"""
- return self._filter_rows(self.tables[table_name], where)
+ return self._filter_rows(self.tables[table_name.decode("utf-8")], where)
def update_rows(self, table_name, where, update):
"""Update row data in a table.
@@ -192,7 +193,8 @@
these resources represents an operation to perform on the table.
"""
try:
- return getattr(THIS_MODULE, "_" + name + "Resource")(
+ attr_str = "_" + str(name, 'utf_8') + "Resource"
+ return getattr(THIS_MODULE, attr_str)(
self.table_name, self.rt_data
)
except AttributeError as ex:
@@ -260,7 +262,7 @@
Example input: {'foo': 'cat, 'bar': 'dog', 'baz: 'donkey'}
Example output: 'foo=cat&bar=dog&baz=donkey'
"""
- string = '&'.join(['{0}={1}'.format(cgi.escape(key), cgi.escape(val))
+ string = '&'.join(['{0}={1}'.format(html.escape(key), html.escape(val))
for key, val in row.items()])
LOGGER.debug("Returning response %s" % string)
return string
@@ -449,7 +451,11 @@
LOGGER.debug("Asked to render GET in the static resource")
# Forego a more complicated unpack since the file is the only thing we
# care about
- where = {'filename': request.args['file'][0], 'commented': '0'}
+ where = {'filename': (request.args[b'file'][0]).decode("utf-8"), 'commented': '0'}
+ LOGGER.info("where string:")
+ LOGGER.info(where)
+ LOGGER.info(self.rt_data.retrieve_rows(self.table_name, where))
+ LOGGER.info(self.encode_multi_row(self.rt_data.retrieve_rows(self.table_name, where)))
try:
return self.encode_multi_row(
self.rt_data.retrieve_rows(self.table_name, where)
diff --git a/lib/python/asterisk/syncami.py b/lib/python/asterisk/syncami.py
index 917e9e4..f9d2e4c 100644
--- a/lib/python/asterisk/syncami.py
+++ b/lib/python/asterisk/syncami.py
@@ -15,7 +15,7 @@
# python 3 import
from urllib.parse import urlencode
-from StringIO import StringIO
+from io import StringIO
from email.parser import HeaderParser
try:
from httplib import *
diff --git a/lib/python/asterisk/test_case.py b/lib/python/asterisk/test_case.py
index c4cde27..6cdbd55 100644
--- a/lib/python/asterisk/test_case.py
+++ b/lib/python/asterisk/test_case.py
@@ -860,8 +860,8 @@
msg = "Originating call to %s" % call_details['channel']
if 'account' not in call_details:
call_details['account'] = None
- if 'async' not in call_details:
- call_details['async'] = False
+ if 'asyncrn' not in call_details:
+ call_details['asyncrn'] = False
if 'channelid' not in call_details:
call_details['channelid'] = None
if 'otherchannelid' not in call_details:
@@ -873,7 +873,7 @@
application=call_details['application'],
variable=call_details['variable'],
account=call_details['account'],
- async=call_details['async'],
+ asyncrn=call_details['asyncrn'],
channelid=call_details['channelid'],
otherchannelid=call_details['otherchannelid'])
else:
@@ -887,7 +887,7 @@
priority=call_details['priority'],
variable=call_details['variable'],
account=call_details['account'],
- async=call_details['async'],
+ asyncrn=call_details['asyncrn'],
channelid=call_details['channelid'],
otherchannelid=call_details['otherchannelid'])
if self._ignore_originate_failures:
diff --git a/lib/python/asterisk/test_runner.py b/lib/python/asterisk/test_runner.py
index 588a6bb..942181e 100644
--- a/lib/python/asterisk/test_runner.py
+++ b/lib/python/asterisk/test_runner.py
@@ -11,11 +11,11 @@
"""
import sys
-import imp
import logging
import logging.config
import os
import yaml
+from importlib.machinery import SourceFileLoader
try:
from yaml import CSafeLoader as MyLoader
@@ -86,7 +86,7 @@
else:
mod = sys.modules.setdefault(
fullname,
- imp.load_source(fullname, self._get_filename(fullname)))
+ SourceFileLoader(fullname, self._get_filename(fullname)).load_module())
return mod
diff --git a/lib/python/protocols/ipstack.py b/lib/python/protocols/ipstack.py
index cd63fce..74d3f22 100644
--- a/lib/python/protocols/ipstack.py
+++ b/lib/python/protocols/ipstack.py
@@ -6,14 +6,17 @@
"""
from binascii import unhexlify
#import six
-from construct import Struct, HexDump, Switch, Pass, Computed, Hex, Bytes, setGlobalPrintFullStrings
+#from construct import Struct, HexDump, Switch, Pass, Computed, Hex, Bytes, setGlobalPrintFullStrings
+#from construct import Struct, HexDump, Switch, Pass, Computed, Hex, Bytes, setglobalfullprinting
+from construct import Struct, HexDump, Switch, Pass, Computed, Hex, Bytes
from protocols.layer2.ethernet import ethernet_header
from protocols.layer3.ipv4 import ipv4_header
from protocols.layer3.ipv6 import ipv6_header
from protocols.layer4.tcp import tcp_header
from protocols.layer4.udp import udp_header
-setGlobalPrintFullStrings(True)
+#setglobalfullprinting(True)
+#setGlobalPrintFullStrings(True)
layer4_tcp = "layer4_tcp" / Struct(
"layer" / Computed(4),
diff --git a/lib/python/protocols/layer4/tcp.py b/lib/python/protocols/layer4/tcp.py
index b2d3162..d13dfcb 100644
--- a/lib/python/protocols/layer4/tcp.py
+++ b/lib/python/protocols/layer4/tcp.py
@@ -6,8 +6,6 @@
from construct import *
from construct.core import *
-setGlobalPrintFullStrings(True)
-
tcp_header = "tcp_header" / BitStruct(
"source" / Bytewise(Int16ub),
"destination" / Bytewise(Int16ub),
diff --git a/tests/agi/nominal/run-test b/tests/agi/nominal/run-test
index a78fda4..3a1cb44 100755
--- a/tests/agi/nominal/run-test
+++ b/tests/agi/nominal/run-test
@@ -72,7 +72,7 @@
Checks to see if the AGI script was completed as expected.
"""
if event['userevent'] != 'AgiCompleted':
- print event['userevent']
+ print(event['userevent'])
return
self.call_count += 1
diff --git a/tests/apps/chanspy/chanspy_w_mixmonitor/run-test b/tests/apps/chanspy/chanspy_w_mixmonitor/run-test
index 612a3ab..930e665 100755
--- a/tests/apps/chanspy/chanspy_w_mixmonitor/run-test
+++ b/tests/apps/chanspy/chanspy_w_mixmonitor/run-test
@@ -99,8 +99,8 @@
name The name to call the instance
"""
LOGGER.info("%s Calling into Playback" % name)
- pjsua.stdin.write("m\n")
- pjsua.stdin.write("sip:play_exten at 127.0.0.1:5060\n")
+ pjsua.stdin.write(b"m\n")
+ pjsua.stdin.write(b"sip:play_exten at 127.0.0.1:5060\n")
def hangup_pjsua(self, pjsua, name):
"""Hangup some PJSUA instance
@@ -110,7 +110,7 @@
name The name to call the instance
"""
LOGGER.info("Hanging up %s" % name)
- pjsua.stdin.write("h\n")
+ pjsua.stdin.write(b"h\n")
def start_processes(self):
"""Start up the PJSUA processes"""
diff --git a/tests/apps/directory/directory_attendant_exit/run-test b/tests/apps/directory/directory_attendant_exit/run-test
index 1721880..91eebcc 100755
--- a/tests/apps/directory/directory_attendant_exit/run-test
+++ b/tests/apps/directory/directory_attendant_exit/run-test
@@ -26,13 +26,13 @@
ami.registerEvent('UserEvent', self.user_event)
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
df = ami.originate("sip/ast2/1234", "senddtmf", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -45,11 +45,11 @@
if event['result'] == "pass":
self.passed = True
- print "app_directory successfully exited"
+ print("app_directory successfully exited")
else:
- print "app_directory did not successfully exit:"
- print "result: %s" % (event['result'],)
- print "error: %s" % (event['error'],)
+ print("app_directory did not successfully exit:")
+ print("result: %s" % (event['result'],))
+ print("error: %s" % (event['error'],))
self.stop_reactor()
diff --git a/tests/apps/directory/directory_context_operator_exit/run-test b/tests/apps/directory/directory_context_operator_exit/run-test
index 1721880..91eebcc 100755
--- a/tests/apps/directory/directory_context_operator_exit/run-test
+++ b/tests/apps/directory/directory_context_operator_exit/run-test
@@ -26,13 +26,13 @@
ami.registerEvent('UserEvent', self.user_event)
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
df = ami.originate("sip/ast2/1234", "senddtmf", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -45,11 +45,11 @@
if event['result'] == "pass":
self.passed = True
- print "app_directory successfully exited"
+ print("app_directory successfully exited")
else:
- print "app_directory did not successfully exit:"
- print "result: %s" % (event['result'],)
- print "error: %s" % (event['error'],)
+ print("app_directory did not successfully exit:")
+ print("result: %s" % (event['result'],))
+ print("error: %s" % (event['error'],))
self.stop_reactor()
diff --git a/tests/apps/directory/directory_operator_exit/run-test b/tests/apps/directory/directory_operator_exit/run-test
index 1721880..91eebcc 100755
--- a/tests/apps/directory/directory_operator_exit/run-test
+++ b/tests/apps/directory/directory_operator_exit/run-test
@@ -26,13 +26,13 @@
ami.registerEvent('UserEvent', self.user_event)
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
df = ami.originate("sip/ast2/1234", "senddtmf", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -45,11 +45,11 @@
if event['result'] == "pass":
self.passed = True
- print "app_directory successfully exited"
+ print("app_directory successfully exited")
else:
- print "app_directory did not successfully exit:"
- print "result: %s" % (event['result'],)
- print "error: %s" % (event['error'],)
+ print("app_directory did not successfully exit:")
+ print("result: %s" % (event['result'],))
+ print("error: %s" % (event['error'],))
self.stop_reactor()
diff --git a/tests/apps/voicemail/check_voicemail_options_change_password/voicemailpwcheck.py b/tests/apps/voicemail/check_voicemail_options_change_password/voicemailpwcheck.py
index d7a66d4..452255c 100755
--- a/tests/apps/voicemail/check_voicemail_options_change_password/voicemailpwcheck.py
+++ b/tests/apps/voicemail/check_voicemail_options_change_password/voicemailpwcheck.py
@@ -46,20 +46,20 @@
# Enforce a password length of at least 6 characters
if len(new_pw) < REQUIRED_LENGTH:
- print "INVALID: Password is too short (%d) - must be at least %d" % \
- (len(new_pw), REQUIRED_LENGTH)
+ print("INVALID: Password is too short (%d) - must be at least %d" % \
+ (len(new_pw), REQUIRED_LENGTH))
sys.exit(0)
for regex, error in REGEX_BLACKLIST:
if re.search(regex, new_pw):
- print "INVALID: %s" % error
+ print("INVALID: %s" % error)
sys.exit(0)
for pw in PW_BLACKLIST:
if new_pw.find(pw) != -1:
- print "INVALID: %s is forbidden in a password" % pw
+ print("INVALID: %s is forbidden in a password" % pw)
sys.exit(0)
-print "VALID"
+print("VALID")
sys.exit(0)
diff --git a/tests/blind-transfer-parkingtimeout/run-test b/tests/blind-transfer-parkingtimeout/run-test
index 5a22a21..2f64832 100755
--- a/tests/blind-transfer-parkingtimeout/run-test
+++ b/tests/blind-transfer-parkingtimeout/run-test
@@ -66,7 +66,7 @@
"'core show globals' in log for more detailed failure results.")
if reactor.running:
- print "Stopping Reactor ..."
+ print("Stopping Reactor ...")
reactor.stop()
# This is a blind transfer test with parkingtimeout.
@@ -89,7 +89,7 @@
self.ast2.stop()
def log_last_step(self, step):
- print step
+ print(step)
self.last_step = step
def run(self):
diff --git a/tests/bridge/bridge_action/bridge_action.py b/tests/bridge/bridge_action/bridge_action.py
index 3682ae5..4ed2409 100644
--- a/tests/bridge/bridge_action/bridge_action.py
+++ b/tests/bridge/bridge_action/bridge_action.py
@@ -53,7 +53,7 @@
context='default',
exten='waiting_area',
priority=1,
- async=True).addErrback(self.test_object.
+ asyncrn=True).addErrback(self.test_object.
handle_originate_failure)
def _new_channel_handler(self, ami, event):
@@ -71,7 +71,7 @@
context='default',
exten='waiting_area',
priority=1,
- async=True).addErrback(self.test_object.
+ asyncrn=True).addErrback(self.test_object.
handle_originate_failure)
def _stop_handler(self, result):
diff --git a/tests/channels/SIP/noload_res_srtp/run-test b/tests/channels/SIP/noload_res_srtp/run-test
index f9f3646..9dc7608 100755
--- a/tests/channels/SIP/noload_res_srtp/run-test
+++ b/tests/channels/SIP/noload_res_srtp/run-test
@@ -34,14 +34,14 @@
def run(self):
TestCase.run(self)
- print "Initiating test call"
+ print("Initiating test call")
self.ast[0].cli_originate(
"SIP/2000/2000 extension 1000 at siptest1")
# This is called by each Asterisk instance if the call gets connected.
def fastagi_connect(self, agi):
def get_test_result(val):
- print "Connection result '%s'" % val
+ print("Connection result '%s'" % val)
if val.split("-")[0] == "SIP/2000":
# Outgoing call on Ast1
self.connected_chan1 = True
@@ -53,10 +53,10 @@
if val.split("=")[1] == "":
self.connected_no_srtp2 = True
else:
- print "Don't know which side is connected."
+ print("Don't know which side is connected.")
if self.connected_chan1 and self.connected_no_srtp1 and self.connected_chan2 and self.connected_no_srtp2:
- print "Test passed"
+ print("Test passed")
for a in self.agis:
a.finish()
self.agis = []
@@ -74,10 +74,10 @@
TestCase.stop_asterisk(self)
# Determine if the test passed
- print "self.connected_chan1: %s" % (self.connected_chan1)
- print "self.connected_no_srtp1:%s" % (self.connected_no_srtp1)
- print "self.connected_chan2: %s" % (self.connected_chan2)
- print "self.connected_no_srtp2:%s" % (self.connected_no_srtp2)
+ print("self.connected_chan1: %s" % (self.connected_chan1))
+ print("self.connected_no_srtp1:%s" % (self.connected_no_srtp1))
+ print("self.connected_chan2: %s" % (self.connected_chan2))
+ print("self.connected_no_srtp2:%s" % (self.connected_no_srtp2))
def main():
test = SIPCallTest()
diff --git a/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test b/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
index 3272245..0f94750 100755
--- a/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
+++ b/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
@@ -40,24 +40,23 @@
# Once the AMI Factory connects to Asterisk, this function fires.
def ami_connect(self, ami):
- print "AMI - connected"
+ print("AMI - connected")
# Register for the AMI event we are interested in.
self.ami[ami.id].registerEvent("VarSet", self.ami_test_varset)
- print "Initiating test call"
+ print("Initiating test call")
self.ast[0].cli_originate("SIP/2000/2000 extension 1000 at siptest1")
# This is called whenever an AMI VarSet event occurs on Ast1.
def ami_test_varset(self, ami, event):
- print "Received VarSet event from AMI"
- #print event
+ print("Received VarSet event from AMI")
if not event.has_key("variable") or not event.has_key("value"):
# These entries should always be in the VarSet event.
- print "Event is missing 'variable' or 'value' entry"
+ print("Event is missing 'variable' or 'value' entry")
return
- print " Value of event[variable] = %s" % (event["variable"])
- print " Value of event[value] = %s" % (event["value"])
+ print(" Value of event[variable] = %s" % (event["variable"]))
+ print(" Value of event[value] = %s" % (event["value"]))
if event["variable"].startswith("~HASH~SIP_CAUSE~"):
cause_code = event["value"].split(" ")[1]
if cause_code == "488":
@@ -70,7 +69,7 @@
# This is called by each Asterisk instance if the call gets connected.
def fastagi_connect(self, agi):
def get_test_result(val):
- print "Connection result '%s'" % val
+ print("Connection result '%s'" % val)
if val.split("-")[0] == "SIP/2000":
# Outgoing call on Ast1
self.connected_chan1 = True
@@ -82,7 +81,7 @@
if val.split("=")[1] == "1":
self.connected_srtp2 = True
else:
- print "Don't know which side is connected."
+ print("Don't know which side is connected.")
# Hold the AGI connection until the reactor times out
# so the other side has a chance to get its test result.
@@ -95,13 +94,13 @@
TestCase.stop_asterisk(self)
# Determine if the test passed
- print "self.connected_chan1:%s" % (self.connected_chan1)
- print "self.connected_srtp1:%s" % (self.connected_srtp1)
- print "self.not_acceptable1:%s" % (self.not_acceptable1)
- print "self.connected_chan2:%s" % (self.connected_chan2)
- print "self.connected_srtp2:%s" % (self.connected_srtp2)
+ print("self.connected_chan1:%s" % (self.connected_chan1))
+ print("self.connected_srtp1:%s" % (self.connected_srtp1))
+ print("self.not_acceptable1:%s" % (self.not_acceptable1))
+ print("self.connected_chan2:%s" % (self.connected_chan2))
+ print("self.connected_srtp2:%s" % (self.connected_srtp2))
if not self.connected_chan1 and not self.connected_srtp1 and self.not_acceptable1 and not self.connected_chan2 and not self.connected_srtp2:
- print "Test passed"
+ print("Test passed")
self.passed = True
def main():
diff --git a/tests/channels/SIP/refer_replaces_to_self/run-test b/tests/channels/SIP/refer_replaces_to_self/run-test
index 2fb31f6..97fc149 100755
--- a/tests/channels/SIP/refer_replaces_to_self/run-test
+++ b/tests/channels/SIP/refer_replaces_to_self/run-test
@@ -19,7 +19,7 @@
testdir = "tests/%s" % workingdir
def log_cb(level, str, len=len(str(str))):
- print str,
+ print(str,)
class TestAccountCallback(pj.AccountCallback):
@@ -60,28 +60,28 @@
if call_sem:
call_sem.release()
-
+
class ReplaceSelfTest:
def __init__(self):
reactor.callWhenRunning(self.run)
- print "Creating Asterisk instance ..."
+ print("Creating Asterisk instance ...")
self.ast1 = Asterisk(base=workingdir)
self.ast1.install_configs("%s/configs" % (testdir))
def stop_reactor(self):
- print "Stopping Reactor ..."
+ print("Stopping Reactor ...")
if reactor.running:
reactor.stop()
def start_asterisk(self):
- print "Starting Asterisk instance ..."
+ print("Starting Asterisk instance ...")
self.ast1.start()
def stop_asterisk(self):
- print "Stopping Asterisk instance ..."
+ print("Stopping Asterisk instance ...")
self.ast1.stop()
def run(self):
@@ -126,7 +126,7 @@
self.stop_reactor()
except pj.Error, e:
- print "Exception: " + str(e)
+ print("Exception: " + str(e))
self.stop_reactor()
def main():
@@ -136,10 +136,10 @@
global passed
if passed:
- print "PASSED"
+ print("PASSED")
return 0
- print "FAILED"
+ print("FAILED")
return 1
diff --git a/tests/channels/SIP/secure_bridge_media/run-test b/tests/channels/SIP/secure_bridge_media/run-test
index c61fa6d..c84f1ab 100755
--- a/tests/channels/SIP/secure_bridge_media/run-test
+++ b/tests/channels/SIP/secure_bridge_media/run-test
@@ -33,13 +33,13 @@
def run(self):
TestCase.run(self)
- print "Initiating test call"
+ print("Initiating test call")
self.ast[0].cli_originate("Local/1000 at siptest1 application playback tt-monkeys")
# This is called by each Asterisk instance if the call gets connected.
def fastagi_connect(self, agi):
def get_test_result(val):
- print "Connection result '%s'" % val
+ print("Connection result '%s'" % val)
if val.split("-")[0] == "Local/1000 at siptest1":
# Outgoing call on Ast1
self.connected_chan1 = True
@@ -51,13 +51,13 @@
if val.split("=")[1] == "1":
self.connected_srtp2 = True
else:
- print "Don't know which side is connected."
+ print("Don't know which side is connected.")
# Drop the AGI connection
agi.finish()
if self.connected_chan2 and self.connected_srtp2:
- print "Test passed"
+ print("Test passed")
self.passed = True
self.stop_reactor()
diff --git a/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test b/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test
index 5f3a398..f40e194 100755
--- a/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test
+++ b/tests/channels/SIP/sip_blind_transfer/caller_refer_only/run-test
@@ -121,17 +121,17 @@
def a_call_b(self):
logger.debug("Phone A Calling Phone B (%s)" % BlindTransfer.phone_b_uri)
- self.pja.stdin.write("m\n")
- self.pja.stdin.write("%s\n" % BlindTransfer.phone_b_uri)
+ self.pja.stdin.write(b"m\n")
+ self.pja.stdin.write(b"%s\n" % BlindTransfer.phone_b_uri)
def a_transfer_b_to_c(self):
logger.debug("Phone A Transferring Phone B to Phone C (%s)" % BlindTransfer.phone_c_uri)
- self.pja.stdin.write("x\n")
- self.pja.stdin.write("%s\n" % BlindTransfer.phone_c_uri)
+ self.pja.stdin.write(b"x\n")
+ self.pja.stdin.write(b"%s\n" % BlindTransfer.phone_c_uri)
def hangup_channel_c(self):
logger.debug("Hanging up Phone C")
- self.pjc.stdin.write("h\n")
+ self.pjc.stdin.write(b"h\n")
def start_processes(self):
logger.debug("Starting Processes")
diff --git a/tests/channels/SIP/sip_one_legged_transfer_v6/run-test b/tests/channels/SIP/sip_one_legged_transfer_v6/run-test
index 387f1fb..0829fc7 100755
--- a/tests/channels/SIP/sip_one_legged_transfer_v6/run-test
+++ b/tests/channels/SIP/sip_one_legged_transfer_v6/run-test
@@ -38,12 +38,12 @@
self.stopProcesses()
if self.passed == True:
- print 'SIP Attended Transfer Test Passed!'
+ print('SIP Attended Transfer Test Passed!')
else:
- print 'SIP Attended Transfer Test Failed'
+ print('SIP Attended Transfer Test Failed')
if reactor.running:
- print "Stopping Reactor ..."
+ print("Stopping Reactor ...")
reactor.stop()
def amiOnConnect(self, ami):
@@ -60,14 +60,14 @@
self.ami_factory.login('127.0.0.1', 5038).addCallbacks(self.amiOnConnect, self.amiLoginError)
def checkBridgeResult(self, result):
- print 'Result', result
+ print('Result', result)
if "bridgedchannel" not in result[0]:
- print "bridgedchannel was not a valid key."
+ print("bridgedchannel was not a valid key.")
elif result[0]['bridgedchannel'] == 'SIP/end_b-00000001':
self.passed = True
if "link" not in result[0]:
- print "'link' was not a valid key."
+ print("'link' was not a valid key.")
elif result[0]['link'] == 'SIP/end_b-00000001': # check link for older versions of asterisk
self.passed = True
@@ -78,7 +78,7 @@
def checkBridgeError(self, reason):
- print reason.getTraceback()
+ print(reason.getTraceback())
self.logLastStep("Checking Bridge failed. Channel did not exist.")
reactor.callLater(1, self.readResult)
@@ -126,7 +126,7 @@
def logLastStep(self, step):
- print step
+ print(step)
self.lastStep = step
def run(self):
diff --git a/tests/channels/SIP/sip_srtp/srtp_call/run-test b/tests/channels/SIP/sip_srtp/srtp_call/run-test
index ee9c2fc..5013ee8 100755
--- a/tests/channels/SIP/sip_srtp/srtp_call/run-test
+++ b/tests/channels/SIP/sip_srtp/srtp_call/run-test
@@ -34,13 +34,13 @@
def run(self):
TestCase.run(self)
- print "Initiating test call"
+ print("Initiating test call")
self.ast[0].cli_originate("SIP/2000/2000 extension 1000 at siptest1")
# This is called by each Asterisk instance if the call gets connected.
def fastagi_connect(self, agi):
def get_test_result(val):
- print "Connection result '%s'" % val
+ print("Connection result '%s'" % val)
if val.split("-")[0] == "SIP/2000":
# Outgoing call on Ast1
self.connected_chan1 = True
@@ -52,10 +52,10 @@
if val.split("=")[1] == "1":
self.connected_srtp2 = True
else:
- print "Don't know which side is connected."
+ print("Don't know which side is connected.")
if self.connected_chan1 and self.connected_srtp1 and self.connected_chan2 and self.connected_srtp2:
- print "Test passed"
+ print("Test passed")
for a in self.agis:
a.finish()
self.agis = []
diff --git a/tests/channels/SIP/tcpauthtimeout/timeout_should_happen/timeout.py b/tests/channels/SIP/tcpauthtimeout/timeout_should_happen/timeout.py
index 4545136..dee2c92 100644
--- a/tests/channels/SIP/tcpauthtimeout/timeout_should_happen/timeout.py
+++ b/tests/channels/SIP/tcpauthtimeout/timeout_should_happen/timeout.py
@@ -23,12 +23,12 @@
data in all cases.
'''
TCP_MESSAGES = [
- [],
- ['hi, this is your tester standby'],
- ['INVITE sip:service at 127.0.0.1:5060 SIP/2.0\r\n'],
- ['hi, this is your tester standby',
- 'hi, this is your tester, again... standby',
- 'guess who?! yup, your tester... standby\r\n']
+ [b""],
+ [b"hi, this is your tester standby"],
+ [b"INVITE sip:service at 127.0.0.1:5060 SIP/2.0\r\n"],
+ [b"hi, this is your tester standby",
+ b"hi, this is your tester, again... standby",
+ b"guess who?! yup, your tester... standby\r\n"]
]
diff --git a/tests/channels/pjsip/resolver/naptr/explicit_transport_configured/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/explicit_transport_configured/dns_zones/example.com
index 7c734e3..cc8e864 100644
--- a/tests/channels/pjsip/resolver/naptr/explicit_transport_configured/dns_zones/example.com
+++ b/tests/channels/pjsip/resolver/naptr/explicit_transport_configured/dns_zones/example.com
@@ -25,7 +25,7 @@
minimum = "1H"
),
- NAPTR('naptr.example.com', 0, 1, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+ NAPTR('naptr.example.com', 0, 1, b"S", b"SIP+D2U", b"", '_sip._udp.example.com'),
SRV('_sip._udp.example.com', 0, 1, 5061, 'main.example.com'),
A('main.example.com', '127.0.0.1'),
AAAA('main.example.com', '::1'),
diff --git a/tests/channels/pjsip/resolver/naptr/order/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/order/dns_zones/example.com
index de1cc60..5ee452f 100644
--- a/tests/channels/pjsip/resolver/naptr/order/dns_zones/example.com
+++ b/tests/channels/pjsip/resolver/naptr/order/dns_zones/example.com
@@ -25,8 +25,8 @@
minimum = "1H"
),
- NAPTR('example.com', 50, 50, 'S', 'SIP+D2T', '', '_sip._tcp.example.com'),
- NAPTR('example.com', 90, 40, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+ NAPTR('example.com', 50, 50, b"S", b"SIP+D2T", b"", '_sip._tcp.example.com'),
+ NAPTR('example.com', 90, 40, b"S", b"SIP+D2U", b"", '_sip._udp.example.com'),
SRV('_sip._tcp.example.com', 0, 1, 5061, 'pbx.example.com'),
SRV('_sip._udp.example.com', 0, 1, 5061, 'pbx.example.com'),
A('pbx.example.com', '127.0.0.1'),
diff --git a/tests/channels/pjsip/resolver/naptr/preference/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/preference/dns_zones/example.com
index 7e563df..dc2631a 100644
--- a/tests/channels/pjsip/resolver/naptr/preference/dns_zones/example.com
+++ b/tests/channels/pjsip/resolver/naptr/preference/dns_zones/example.com
@@ -25,8 +25,8 @@
minimum = "1H"
),
- NAPTR('example.com', 50, 50, 'S', 'SIP+D2T', '', '_sip._tcp.example.com'),
- NAPTR('example.com', 50, 90, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+ NAPTR('example.com', 50, 50, b"S", b"SIP+D2T", b"", '_sip._tcp.example.com'),
+ NAPTR('example.com', 50, 90, b"S", b"SIP+D2U", b"", '_sip._udp.example.com'),
SRV('_sip._tcp.example.com', 0, 1, 5061, 'pbx.example.com'),
SRV('_sip._udp.example.com', 0, 1, 5061, 'pbx.example.com'),
A('pbx.example.com', '127.0.0.1'),
diff --git a/tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com
index aabb875..0389aac 100644
--- a/tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com
+++ b/tests/channels/pjsip/resolver/naptr/preference_failover/dns_zones/example.com
@@ -25,8 +25,8 @@
minimum = "1H"
),
- NAPTR('example.com', 50, 50, 'S', 'SIP+D2T', '', '_sip._tcp.example.com'),
- NAPTR('example.com', 50, 90, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+ NAPTR('example.com', 50, 50, b"S", b"SIP+D2T", b"", '_sip._tcp.example.com'),
+ NAPTR('example.com', 50, 90, b"S", b"SIP+D2U", b"", '_sip._udp.example.com'),
SRV('_sip._udp.example.com', 0, 1, 5061, 'pbx.example.com'),
A('pbx.example.com', '127.0.0.1'),
]
diff --git a/tests/channels/pjsip/resolver/naptr/restricted_transport/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/restricted_transport/dns_zones/example.com
index 7e563df..dc2631a 100644
--- a/tests/channels/pjsip/resolver/naptr/restricted_transport/dns_zones/example.com
+++ b/tests/channels/pjsip/resolver/naptr/restricted_transport/dns_zones/example.com
@@ -25,8 +25,8 @@
minimum = "1H"
),
- NAPTR('example.com', 50, 50, 'S', 'SIP+D2T', '', '_sip._tcp.example.com'),
- NAPTR('example.com', 50, 90, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+ NAPTR('example.com', 50, 50, b"S", b"SIP+D2T", b"", '_sip._tcp.example.com'),
+ NAPTR('example.com', 50, 90, b"S", b"SIP+D2U", b"", '_sip._udp.example.com'),
SRV('_sip._tcp.example.com', 0, 1, 5061, 'pbx.example.com'),
SRV('_sip._udp.example.com', 0, 1, 5061, 'pbx.example.com'),
A('pbx.example.com', '127.0.0.1'),
diff --git a/tests/channels/pjsip/resolver/naptr/transport_tcp/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/transport_tcp/dns_zones/example.com
index c0baf68..c96b88c 100644
--- a/tests/channels/pjsip/resolver/naptr/transport_tcp/dns_zones/example.com
+++ b/tests/channels/pjsip/resolver/naptr/transport_tcp/dns_zones/example.com
@@ -25,8 +25,8 @@
minimum = "1H"
),
- NAPTR('naptr.example.com', 0, 1, 'S', 'SIP+D2T', '', '_sip._tcp.example.com'),
- NAPTR('naptr.example.com', 0, 2, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+ NAPTR('naptr.example.com', 0, 1, b"S", b"SIP+D2T", b"", '_sip._tcp.example.com'),
+ NAPTR('naptr.example.com', 0, 2, b"S", b"SIP+D2U", b"", '_sip._udp.example.com'),
SRV('_sip._tcp.example.com', 0, 1, 5061, 'pbx.example.com'),
SRV('_sip._udp.example.com', 0, 1, 5061, 'pbx.example.com'),
A('pbx.example.com', '127.0.0.1'),
diff --git a/tests/channels/pjsip/resolver/naptr/transport_udp/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/transport_udp/dns_zones/example.com
index c0baf68..c96b88c 100644
--- a/tests/channels/pjsip/resolver/naptr/transport_udp/dns_zones/example.com
+++ b/tests/channels/pjsip/resolver/naptr/transport_udp/dns_zones/example.com
@@ -25,8 +25,8 @@
minimum = "1H"
),
- NAPTR('naptr.example.com', 0, 1, 'S', 'SIP+D2T', '', '_sip._tcp.example.com'),
- NAPTR('naptr.example.com', 0, 2, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+ NAPTR('naptr.example.com', 0, 1, b"S", b"SIP+D2T", b"", '_sip._tcp.example.com'),
+ NAPTR('naptr.example.com', 0, 2, b"S", b"SIP+D2U", b"", '_sip._udp.example.com'),
SRV('_sip._tcp.example.com', 0, 1, 5061, 'pbx.example.com'),
SRV('_sip._udp.example.com', 0, 1, 5061, 'pbx.example.com'),
A('pbx.example.com', '127.0.0.1'),
diff --git a/tests/channels/pjsip/resolver/naptr/transport_unspecified/dns_zones/example.com b/tests/channels/pjsip/resolver/naptr/transport_unspecified/dns_zones/example.com
index c0baf68..6a16279 100644
--- a/tests/channels/pjsip/resolver/naptr/transport_unspecified/dns_zones/example.com
+++ b/tests/channels/pjsip/resolver/naptr/transport_unspecified/dns_zones/example.com
@@ -25,9 +25,10 @@
minimum = "1H"
),
- NAPTR('naptr.example.com', 0, 1, 'S', 'SIP+D2T', '', '_sip._tcp.example.com'),
- NAPTR('naptr.example.com', 0, 2, 'S', 'SIP+D2U', '', '_sip._udp.example.com'),
+ A('pbx.example.com', '127.0.0.1'),
SRV('_sip._tcp.example.com', 0, 1, 5061, 'pbx.example.com'),
SRV('_sip._udp.example.com', 0, 1, 5061, 'pbx.example.com'),
- A('pbx.example.com', '127.0.0.1'),
+ NAPTR('naptr.example.com', 0, 1, b"S", b"SIP+D2T", b"", '_sip._tcp.example.com'),
+ NAPTR('naptr.example.com', 0, 2, b"S", b"SIP+D2U", b"", '_sip._udp.example.com'),
+
]
diff --git a/tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py
index 2c79e5c..abf2949 100644
--- a/tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py
+++ b/tests/channels/pjsip/rtp/bind_rtp_to_media_address/rtp.py
@@ -18,9 +18,10 @@
def __init__(self, test_object):
self.test_object = test_object
- def datagramReceived(self, data, (host, port)):
+ def datagramReceived(self, data, addr):
+ (host, port) = addr
if self.packet_count == 0 and host != "127.0.0.3":
- LOGGER.error("Received RTP from wrong ip address: %s %s" % (host,port))
+ LOGGER.error("Received RTP from wrong ip address: %s %s" % host,port)
self.test_object.set_passed(False)
self.packet_count += 1
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py b/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
index 633971d..f069ea1 100644
--- a/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
@@ -25,7 +25,7 @@
self.test_object = test_object
self.test_object.register_stop_observer(self.asterisk_stopped)
- def datagramReceived(self, data, (host, port)):
+ def datagramReceived(self, data, addr):
rtp_header = RTPPacket.rtp_header.parse(data)
LOGGER.debug("Parsed RTP packet is {0}".format(rtp_header))
if rtp_header.payload_type == 13:
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/direct_media/rtp.py b/tests/channels/pjsip/rtp/rtp_keepalive/direct_media/rtp.py
index bd4eff3..5f54078 100644
--- a/tests/channels/pjsip/rtp/rtp_keepalive/direct_media/rtp.py
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/direct_media/rtp.py
@@ -16,7 +16,7 @@
def __init__(self, test_object):
self.test_object = test_object
- def datagramReceived(self, data, (host, port)):
+ def datagramReceived(self, data, addr):
LOGGER.error("Received RTP from Asterisk unexpectedly")
self.test_object.set_passed(False)
self.test_object.stop_reactor()
diff --git a/tests/codecs/audio_analyzer.py b/tests/codecs/audio_analyzer.py
index 9c01928..630e31e 100644
--- a/tests/codecs/audio_analyzer.py
+++ b/tests/codecs/audio_analyzer.py
@@ -185,7 +185,7 @@
'channel': 'PJSIP/audio',
'application': 'Record',
'data': self.output_file + ',,,k',
- 'async': 'True'
+ 'asyncrn': 'True'
}]
super(Analyzer, self).__init__(test_path, test_config)
diff --git a/tests/fastagi/channel-status/run-test b/tests/fastagi/channel-status/run-test
index 7271905..aa95353 100755
--- a/tests/fastagi/channel-status/run-test
+++ b/tests/fastagi/channel-status/run-test
@@ -24,10 +24,10 @@
self.create_fastagi_factory()
def on_answer_failure(self, reason):
- print 'Could not answer the call:', reason.getTraceback()
+ print('Could not answer the call:', reason.getTraceback())
def on_failure(self, reason):
- print 'Could not run deferred:', reason.getTraceback()
+ print('Could not run deferred:', reason.getTraceback())
def on_answer(self, status):
self.fastagi_connect(self.agi)
@@ -36,10 +36,10 @@
return agi.channelStatus(agi.variables['agi_channel'])
def finish_test(self, status):
- print "status is", status
+ print("status is", status)
self.test_status[status] = (self.test == status)
if self.test == 4:
- print "Answering call"
+ print("Answering call")
self.test = 6
self.agi.answer().addCallback(self.on_answer).addErrback(
self.on_answer_failure)
@@ -51,9 +51,9 @@
def fastagi_connect(self, agi):
self.agi = agi
if self.test == 4:
- print "Connection established. Testing for channel status code 4."
+ print("Connection established. Testing for channel status code 4.")
elif self.test == 6:
- print "Testing for channel status code 6."
+ print("Testing for channel status code 6.")
return self.get_deferred(agi).addCallback(
self.finish_test).addErrback(self.on_failure)
@@ -63,15 +63,15 @@
self.agi.finish()
self.stop_reactor()
if self.test_status[4] is True and self.test_status[6] is True:
- print "Success"
+ print("Success")
else:
- print "Failed"
+ print("Failed")
def launch_test(self):
- print "Originating call to begin test."
+ print("Originating call to begin test.")
self.ast[0].cli_originate("Local/no_answer at agitest extension echo at agitest")
- # Read result before timeout
+ # Read result before timeout
def result_changed(self):
if self.test_status[6] is not None:
self.read_result()
diff --git a/tests/fastagi/connect/run-test b/tests/fastagi/connect/run-test
index 491c96a..d2c7f60 100755
--- a/tests/fastagi/connect/run-test
+++ b/tests/fastagi/connect/run-test
@@ -22,13 +22,13 @@
self.create_fastagi_factory()
def fastagi_connect(self, agi):
- print "Connection established."
+ print("Connection established.")
self.passed = True
self.result_changed()
return agi.finish()
def launch_test(self):
- print "Originating call to begin test."
+ print("Originating call to begin test.")
self.ast[0].cli_originate("Local/501 at agitest extension echo at agitest")
def result_changed(self):
diff --git a/tests/fastagi/database/run-test b/tests/fastagi/database/run-test
index 7df64f4..3d98f4e 100755
--- a/tests/fastagi/database/run-test
+++ b/tests/fastagi/database/run-test
@@ -25,55 +25,55 @@
self.create_fastagi_factory()
def on_del_failure(self, reason):
- print 'Could not delete the data from the database.'
- print reason.getTraceback()
+ print('Could not delete the data from the database.')
+ print(reason.getTraceback())
self.passed["Del"] = False
self.result_changed()
def on_set_failure(self, reason):
- print 'Could not set a new value.'
- print reason.getTraceback()
+ print('Could not set a new value.')
+ print(reason.getTraceback())
self.passed["Set"] = False
def on_get_failure(self, reason):
- print 'Could not get the data from the database.'
- print reason.getTraceback()
+ print('Could not get the data from the database.')
+ print(reason.getTraceback())
self.passed["Get"] = False
# We expect this to get called when we try to select
# the key we've just deleted from the database.
def on_get3_failure(self, reason):
- print "%s is no longer a valid key." % self.key
+ print("%s is no longer a valid key." % self.key)
self.passed["Del"] = True
self.result_changed()
def on_put_failure(self, reason):
- print 'Could not put the data into the database.'
- print reason.getTraceback()
+ print('Could not put the data into the database.')
+ print(reason.getTraceback())
self.passed["Put"] = False
self.result_changed()
def get_result_from_put(self, result):
self.passed["Put"] = True
# 2. Retrieve that key from the database
- print "Retrieving key from the database."
+ print("Retrieving key from the database.")
self.agi.databaseGet("secret", self.key).addCallback(
self.get_result_from_get).addErrback(self.on_get_failure)
# 2. Retrieve that key from the database
def get_result_from_get(self, result):
- print 'Value of %s is "%s"' % (self.key, result)
+ print('Value of %s is "%s"' % (self.key, result))
if result == "juststarted":
self.passed["Get"] = True
else:
# If the call to databaseGet() succeeds but the value is wrong,
# the previous call to databasePut() failed.
self.passed["Put"] = False
- print "Call to DATABASE GET succeeded, but value is wrong."
- print 'Expected value of "juststarted" but got "%s"' % result
+ print("Call to DATABASE GET succeeded, but value is wrong.")
+ print('Expected value of "juststarted" but got "%s"' % result)
# 3. Update the value of the key in the database
- print "Updating value of key."
+ print("Updating value of key.")
self.agi.databaseSet("secret", self.key, "halfwaydone").addCallback(
self.get_result_from_set).addErrback(self.on_set_failure)
@@ -84,25 +84,25 @@
# This should never happen.
else:
self.passed["Set"] = False
- print "Something went horribly wrong."
+ print("Something went horribly wrong.")
# 4. Test for new value
- print "Checking new value of key."
+ print("Checking new value of key.")
self.agi.databaseGet("secret",self.key).addCallback(
self.get_result_from_get2
).addErrback(self.on_get_failure)
# 4. Test for new value
def get_result_from_get2(self, result):
- print 'Value of %s is "%s"' % (self.key, result)
+ print('Value of %s is "%s"' % (self.key, result))
if result != "halfwaydone":
self.passed["Set"] = False
- print "Call to DATABASE SET succeeded, \
- but value did not get updated."
- print 'Expected value of "halfwaydone" but got "%s"' % result
+ print("Call to DATABASE SET succeeded, \
+ but value did not get updated.")
+ print('Expected value of "halfwaydone" but got "%s"' % result)
# 5. Delete that key from the database
- print "Deleting key from database."
+ print("Deleting key from database.")
self.agi.databaseDel("secret",self.key).addCallback(
self.get_result_from_del).addErrback(self.on_del_failure)
@@ -113,17 +113,17 @@
# This should never happen.
else:
self.passed["Del"] = False
- print "Something went horribly wrong."
+ print("Something went horribly wrong.")
# 6. Test that key was deleted.
- print "Checking that key was deleted."
+ print("Checking that key was deleted.")
self.agi.databaseGet("secret",self.key).addCallback(
self.get_result_from_get3).addErrback(self.on_get3_failure)
# 6. Test that key was deleted.
# This should never be called if databaseDel() succeeded.
def get_result_from_get3(self, result):
- print "Value of %s is %s" % (self.key, result)
+ print("Value of %s is %s" % (self.key, result))
if result is not None:
self.passed["Del"] = False
# This should never happen.
@@ -141,13 +141,13 @@
# 6. Test that key was deleted.
def fastagi_connect(self, agi):
self.agi = agi
- print "Inserting key into database."
+ print("Inserting key into database.")
return agi.databaseSet("secret", self.key, "juststarted").addCallback(
self.get_result_from_put).addErrback(self.on_put_failure)
def launch_test(self):
- print "Originating call to begin test."
+ print("Originating call to begin test.")
self.ast[0].cli_originate("Local/506 at agitest extension echo at agitest")
# Read result before timeout
diff --git a/tests/fastagi/record-file/run-test b/tests/fastagi/record-file/run-test
index b649001..197754a 100755
--- a/tests/fastagi/record-file/run-test
+++ b/tests/fastagi/record-file/run-test
@@ -39,11 +39,11 @@
def on_record_failure(self, reason):
if os.path.exists(self.audio_file):
- print "file exists"
- print "file size is", os.path.getsize(self.audio_file)
+ print("file exists")
+ print("file size is", os.path.getsize(self.audio_file))
self.results[self.test] = False
- print 'Could not record file:', reason.getTraceback()
+ print('Could not record file:', reason.getTraceback())
if self.test is "DTMF":
self.test = "HANGUP"
reactor.callLater(0, self.launch_test)
@@ -56,23 +56,23 @@
except:
digit = None
- print "Recording terminated by %s (%s) after %s bytes." \
- % (result[1], digit, result[2])
+ print("Recording terminated by %s (%s) after %s bytes." \
+ % (result[1], digit, result[2]))
if os.path.exists(self.audio_file):
file_size = os.path.getsize(self.audio_file)
if file_size == 0:
- print "The file was created, but it is empty."
+ print("The file was created, but it is empty.")
self.results[self.test] = False
elif result[2] == file_size:
- print "Data was recorded, and data length matches what was", \
- "reported during the %s test." % self.test
+ print("Data was recorded, and data length matches what was", \
+ "reported during the %s test." % self.test)
self.results[self.test] = True
else:
- print "Some data was recorded, but the data length does not", \
- "match what was reported during the %s test." % self.test
+ print("Some data was recorded, but the data length does not", \
+ "match what was reported during the %s test." % self.test)
self.results[self.test] = False
else:
- print "The file doesn't exist."
+ print("The file doesn't exist.")
self.results[self.test] = False
self.agi.finish()
@@ -99,8 +99,8 @@
if os.path.exists(self.audio_file):
os.unlink(self.audio_file)
- print "Originating call to begin test which terminates recording",\
- "with", self.test
+ print("Originating call to begin test which terminates recording",\
+ "with", self.test)
if self.test is "DTMF":
self.ast[0].cli_originate("Local/508 at agitest extension 1 at record-file")
elif self.test is "HANGUP":
diff --git a/tests/fastagi/stream-file/run-test b/tests/fastagi/stream-file/run-test
index d74befe..f31f2e9 100755
--- a/tests/fastagi/stream-file/run-test
+++ b/tests/fastagi/stream-file/run-test
@@ -31,13 +31,13 @@
# This gets invoked by the dialplan when the call is answered
# send STREAM FILE command and wait for results
def fastagi_connect(self, agi):
- print "Connection established."
+ print("Connection established.")
self.agi = agi
return agi.streamFile("beep", "").addCallback(
self.finish_test)
def launch_test(self):
- print "Originating call to begin test."
+ print("Originating call to begin test.")
self.ast[0].cli_originate("Local/505 at agitest extension echo at agitest")
def run(self):
diff --git a/tests/fastagi/wait-for-digit/run-test b/tests/fastagi/wait-for-digit/run-test
index 047b627..6a56673 100755
--- a/tests/fastagi/wait-for-digit/run-test
+++ b/tests/fastagi/wait-for-digit/run-test
@@ -32,16 +32,16 @@
self.ast1.install_configs("%s/configs/ast1" % (testdir))
def on_failure(self, reason):
- print 'Could not run WAIT FOR DIGIT: ', reason.getTraceback()
+ print('Could not run WAIT FOR DIGIT: ', reason.getTraceback())
self.agi.finish()
# result is (str digits, bool timeout)
def finish_test(self, result):
self.passed = True
if result == 3212:
- print "Got the input we expected."
+ print("Got the input we expected.")
else:
- print "Got '%s' which wasn't what we expected." % result
+ print("Got '%s' which wasn't what we expected." % result)
self.passed = False
self.result_changed()
@@ -50,7 +50,7 @@
# send WAIT FOR DIGIT command and wait for results
def do_test(self, agi):
self.agi = agi
- print "Connection established."
+ print("Connection established.")
return agi.waitForDigit(60, 'silence/10', '1234567890*#ABCD', 4, '#').addCallback(
self.finish_test).addErrback(self.on_failure)
@@ -58,13 +58,13 @@
self.stop_reactor()
if self.passed is True:
- print "Success"
+ print("Success")
else:
- print "Failed"
+ print("Failed")
def stop_reactor(self):
def __finish_stop(result):
- print "Stopping Reactor ..."
+ print("Stopping Reactor ...")
if reactor.running:
reactor.stop()
return result
@@ -73,7 +73,7 @@
df.addCallback(__finish_stop)
def launch_test(self):
- print "Originating call to begin test."
+ print("Originating call to begin test.")
self.ast1.cli_originate("Local/basic_agi at agitest extension play_dtmf at agitest")
# Read result before timeout
@@ -87,7 +87,7 @@
reactor.callLater(self.timeout, self.stop_reactor)
return result
- print "Starting Asterisk"
+ print("Starting Asterisk")
df = self.ast1.start()
df.addCallback(__finish_start_ops)
diff --git a/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py b/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py
index 3cd087a..d51bcbb 100755
--- a/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py
+++ b/tests/fax/pjsip/t38_fast_reject/check_reinvite_rtt.py
@@ -9,7 +9,7 @@
reader = csv.DictReader(csvfile, delimiter=';')
for row in reader:
if 'ResponseTimereinvite(P)' not in row:
- print "column not found! make sure scenario is correct!\n"
+ print("column not found! make sure scenario is correct!\n")
exit(-1)
parts = regex.match(row['ResponseTimereinvite(P)'])
hours = int(parts.group(1))
@@ -17,7 +17,7 @@
seconds = (minutes * 60) + int(parts.group(3))
milliseconds = (seconds * 1000) + int(parts.group(4))
if (milliseconds > 500):
- print "Slow 488 Rejection detected (" + str(milliseconds) + " ms)!\n"
+ print("Slow 488 Rejection detected (" + str(milliseconds) + " ms)!\n")
exit(-2)
csvfile.close()
diff --git a/tests/fax/sip/gateway_g711_t38/run-test b/tests/fax/sip/gateway_g711_t38/run-test
index 8dec923..7c3a38e 100755
--- a/tests/fax/sip/gateway_g711_t38/run-test
+++ b/tests/fax/sip/gateway_g711_t38/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-g711/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "gateway error:"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("gateway error:")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_mix1/run-test b/tests/fax/sip/gateway_mix1/run-test
index 8dec923..7c3a38e 100755
--- a/tests/fax/sip/gateway_mix1/run-test
+++ b/tests/fax/sip/gateway_mix1/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-g711/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "gateway error:"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("gateway error:")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_mix3/run-test b/tests/fax/sip/gateway_mix3/run-test
index a02325e..f226a68 100755
--- a/tests/fax/sip/gateway_mix3/run-test
+++ b/tests/fax/sip/gateway_mix3/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-t38/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "gateway error:"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("gateway error:")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_mix4/run-test b/tests/fax/sip/gateway_mix4/run-test
index 8dec923..7c3a38e 100755
--- a/tests/fax/sip/gateway_mix4/run-test
+++ b/tests/fax/sip/gateway_mix4/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-g711/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "gateway error:"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("gateway error:")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_native_t38/run-test b/tests/fax/sip/gateway_native_t38/run-test
index 1592c70..071a3d9 100755
--- a/tests/fax/sip/gateway_native_t38/run-test
+++ b/tests/fax/sip/gateway_native_t38/run-test
@@ -23,7 +23,7 @@
def __init__(self):
TestCase.__init__(self)
- self.reactor_timeout = 120
+ self.reactor_timeout = 120
self.create_asterisk(2)
# copy the tiff file we are going to send to a good known location
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-t38/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "SUCCESS" and event['error'] == "NATIVE_T38":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "gateway result should have been SUCCESS with error NATIVE_T38"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("gateway result should have been SUCCESS with error NATIVE_T38")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_no_t38/run-test b/tests/fax/sip/gateway_no_t38/run-test
index fff3de4..97d0606 100755
--- a/tests/fax/sip/gateway_no_t38/run-test
+++ b/tests/fax/sip/gateway_no_t38/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-g711/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "FAILED" and event['error'] == "T38_NEG_ERROR":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "gateway status should have been FAILED with error T38_NEG_ERROR"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("gateway status should have been FAILED with error T38_NEG_ERROR")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_t38_g711/run-test b/tests/fax/sip/gateway_t38_g711/run-test
index a02325e..f226a68 100755
--- a/tests/fax/sip/gateway_t38_g711/run-test
+++ b/tests/fax/sip/gateway_t38_g711/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-t38/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "gateway error:"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("gateway error:")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_timeout1/run-test b/tests/fax/sip/gateway_timeout1/run-test
index 368b896..fe3a6cc 100755
--- a/tests/fax/sip/gateway_timeout1/run-test
+++ b/tests/fax/sip/gateway_timeout1/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-g711/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "FAILED" and event['error'] == "TIMEOUT":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "test error, expected FAILED and TIMEOUT"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("test error, expected FAILED and TIMEOUT")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_timeout2/run-test b/tests/fax/sip/gateway_timeout2/run-test
index 84e2cb4..c4fb6be 100755
--- a/tests/fax/sip/gateway_timeout2/run-test
+++ b/tests/fax/sip/gateway_timeout2/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-t38/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "FAILED" and event['error'] == "TIMEOUT":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "test error, expected FAILED and TIMEOUT"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("test error, expected FAILED and TIMEOUT")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,10 +72,10 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful playback"
+ print("successful playback")
self.success_count += 1
else:
- print "this can't happen"
+ print("this can't happen")
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_timeout3/run-test b/tests/fax/sip/gateway_timeout3/run-test
index af25d79..cc3d3a4 100755
--- a/tests/fax/sip/gateway_timeout3/run-test
+++ b/tests/fax/sip/gateway_timeout3/run-test
@@ -33,14 +33,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-t38/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -56,13 +56,13 @@
self.event_count += 1
if event['status'] == "FAILED" and event['error'] == "TIMEOUT":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "test error, expected FAILED and TIMEOUT"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("test error, expected FAILED and TIMEOUT")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -73,10 +73,10 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful playback"
+ print("successful playback")
self.success_count += 1
else:
- print "this can't happen"
+ print("this can't happen")
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_timeout4/run-test b/tests/fax/sip/gateway_timeout4/run-test
index 7a80e16..153b6ef 100755
--- a/tests/fax/sip/gateway_timeout4/run-test
+++ b/tests/fax/sip/gateway_timeout4/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-t38/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -57,10 +57,10 @@
if event['status'] == "SUCCESS":
self.success_count += 1
else:
- print "test error, expected SUCCESS"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("test error, expected SUCCESS")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/fax/sip/gateway_timeout5/run-test b/tests/fax/sip/gateway_timeout5/run-test
index 28a0d54..d27129a 100755
--- a/tests/fax/sip/gateway_timeout5/run-test
+++ b/tests/fax/sip/gateway_timeout5/run-test
@@ -32,14 +32,14 @@
def ami_connect(self, ami):
if ami.id == 0:
- print "sending a call from ast1 to ast2"
+ print("sending a call from ast1 to ast2")
ami.registerEvent('UserEvent', self.fax_result)
df = ami.originate("sip/ast2-t38/1234", "sendfax", "1234", 1)
def handle_failure(reason):
- print "error sending originate:"
- print reason.getTraceback()
+ print("error sending originate:")
+ print(reason.getTraceback())
self.stop_reactor()
return reason
@@ -55,13 +55,13 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful gateway operation"
+ print("successful gateway operation")
self.success_count += 1
else:
- print "gateway error:"
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("gateway error:")
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
@@ -72,14 +72,14 @@
self.event_count += 1
if event['status'] == "SUCCESS":
- print "successful %s through gateway" % (event['operation'],)
+ print("successful %s through gateway" % (event['operation'],))
self.success_count += 1
else:
- print "error sending fax through gateway:"
- print "operation: %s" % (event['operation'],)
- print "status: %s" % (event['status'],)
- print "error: %s" % (event['error'],)
- print "statusstr: %s" % (event['statusstr'],)
+ print("error sending fax through gateway:")
+ print("operation: %s" % (event['operation'],))
+ print("status: %s" % (event['status'],))
+ print("error: %s" % (event['error'],))
+ print("statusstr: %s" % (event['statusstr'],))
self.are_we_there_yet()
diff --git a/tests/funcs/func_srv/run-test b/tests/funcs/func_srv/run-test
index 23ce2c0..6a53d74 100755
--- a/tests/funcs/func_srv/run-test
+++ b/tests/funcs/func_srv/run-test
@@ -23,7 +23,7 @@
self.weight = weight
def match(self, record):
- print "Matching: %s/%s, %s/%s, %s/%s, %s/%s" % (self.host, record.host, self.port, record.port, self.priority, record.priority, self.weight, record.weight)
+ print("Matching: %s/%s, %s/%s, %s/%s, %s/%s" % (self.host, record.host, self.port, record.port, self.priority, record.priority, self.weight, record.weight))
if self.host != record.host or self.port != record.port or self.priority != record.priority or self.weight != record.weight:
return False
else:
@@ -57,7 +57,7 @@
return
r = srv_record(event.get("recordnum"), event.get("host"), event.get("port"), event.get("priority"), event.get("weight"))
- print "Got record (%s): Host - %s, Port - %s, Priority - %s, Weight - %s" % (r.record_num, r.host, r.port, r.priority, r.weight)
+ print("Got record (%s): Host - %s, Port - %s, Priority - %s, Weight - %s" % (r.record_num, r.host, r.port, r.priority, r.weight))
records.append(r)
if len(self.srv_records) == len(self.test1_records) and len(self.srv_records) == len(self.test2_records):
@@ -66,7 +66,7 @@
if not r.match(t[r.record_num - 1]):
# Records with the same priority are ordered randomly, so check 2/3 instead.
if not (r.record_num == 2 and r.match(t[2])) and not (r.record_num == 3 and r.match(t[1])):
- print "Record #%s did not match." % r.record_num
+ print("Record #%s did not match." % r.record_num)
self.stop_reactor()
return
diff --git a/tests/hep/hep_capture_node.py b/tests/hep/hep_capture_node.py
index 010756a..766c51d 100644
--- a/tests/hep/hep_capture_node.py
+++ b/tests/hep/hep_capture_node.py
@@ -144,9 +144,11 @@
hep_protocol_type,
hep_capture_agent_id)
- def datagramReceived(self, data, (host, port)):
+ def datagramReceived(self, data, addr):
"""Process a received datagram"""
+ (host, port) = addr
+
LOGGER.debug("Received %r from %s:%d (len: %d)" %
(data, host, port, len(data)))
diff --git a/tests/manager/userevent/event.py b/tests/manager/userevent/event.py
index 8e91fb8..86eb1cc 100644
--- a/tests/manager/userevent/event.py
+++ b/tests/manager/userevent/event.py
@@ -17,12 +17,12 @@
def ami_connect(self, ami):
ami.registerEvent('UserEvent', self.userevent)
message = [
- 'FootBoneConnectedToThe: AnkleBone',
- 'AnkleBoneConnectedToThe: ShinBone',
- 'Action: UserEvent',
- 'ShinBoneConnectedToThe: KneeBone',
- 'UserEvent: AnatomyLesson',
- 'KneeBoneConnectedToThe: ThighBone',
+ b"FootBoneConnectedToThe: AnkleBone",
+ b"AnkleBoneConnectedToThe: ShinBone",
+ b"Action: UserEvent",
+ b"ShinBoneConnectedToThe: KneeBone",
+ b"UserEvent: AnatomyLesson",
+ b"KneeBoneConnectedToThe: ThighBone",
]
# We have to forego the typical methods of sending an AMI command
# because the order the headers are sent in matters for this test.
@@ -36,7 +36,7 @@
message.append(message.pop(0))
for line in message:
ami.sendLine(line)
- ami.sendLine('')
+ ami.sendLine(b"")
def userevent(self, ami, event):
# This isn't strictly necessary, but without it, the test will take 30
diff --git a/tests/masquerade/run-test b/tests/masquerade/run-test
index 096202d..a9eb285 100755
--- a/tests/masquerade/run-test
+++ b/tests/masquerade/run-test
@@ -90,7 +90,7 @@
self.ami[0].originate(
channel="Local/start at outgoing",
context="parked", exten="parkme12", priority=1,
- timeout=900, async=True, variable={'DEST': str(exten)}
+ timeout=900, asyncrn=True, variable={'DEST': str(exten)}
).addErrback(TestCase.handle_originate_failure)
def get_parkedcall(self):
@@ -102,7 +102,7 @@
self.ami[1].originate(
channel=tech_prefix + str(self.expected_space),
context="getit", exten="retrieve", priority=1,
- timeout=30, async=True
+ timeout=30, asyncrn=True
).addErrback(TestCase.handle_originate_failure)
def evt_parkedcall(self, ami, event):
diff --git a/tests/rtp/strict_rtp/strict_rtp_seqno/strict_rtp.py b/tests/rtp/strict_rtp/strict_rtp_seqno/strict_rtp.py
index ea58956..969b55d 100644
--- a/tests/rtp/strict_rtp/strict_rtp_seqno/strict_rtp.py
+++ b/tests/rtp/strict_rtp/strict_rtp_seqno/strict_rtp.py
@@ -32,7 +32,7 @@
"""
self.test_object = test_object
- def datagramReceived(self, data, (host, port)):
+ def datagramReceived(self, data, addr):
"""Callback for when a datagram is received.
We don't want anything to happen here because we do all
of the handling ourselves via TestEvent.
@@ -41,6 +41,7 @@
data The actual packet
(host, port) Tuple of source host and port
"""
+ (host, port) = addr
LOGGER.debug('Packet received from {0}:{1}\n{2}'.format(
host, port, data))
diff --git a/tests/rtp/strict_rtp/strict_rtp_yes/strict_rtp.py b/tests/rtp/strict_rtp/strict_rtp_yes/strict_rtp.py
index 57974b5..8984cc0 100644
--- a/tests/rtp/strict_rtp/strict_rtp_yes/strict_rtp.py
+++ b/tests/rtp/strict_rtp/strict_rtp_yes/strict_rtp.py
@@ -34,13 +34,14 @@
"""
self.test_object = test_object
- def datagramReceived(self, data, (host, port)):
+ def datagramReceived(self, data, addr):
"""Callback for when a datagram is received
Keyword Arguments:
data The actual packet
(host, port) Tuple of source host and port
"""
+ (host, port) = addr
LOGGER.debug('Packet received from {0}:{1}\n{2}'.format(
host, port, data))
--
To view, visit https://gerrit.asterisk.org/c/testsuite/+/18199
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: development/16/python3
Gerrit-Change-Id: Ic7a1d72b174df59107370fcb03fae9dc4cdfc9d3
Gerrit-Change-Number: 18199
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220314/a2595674/attachment-0001.html>
More information about the asterisk-code-review
mailing list