[asterisk-commits] russell: testsuite/asterisk/trunk r192 - in /asterisk/trunk: ./ lib/python/as...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 2 16:34:46 CDT 2010
Author: russell
Date: Fri Apr 2 16:34:43 2010
New Revision: 192
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=192
Log:
Revert format() usage, it requires 2.6 and getting that on the build slave is a pain
Modified:
asterisk/trunk/lib/python/asterisk/asterisk.py
asterisk/trunk/lib/python/asterisk/config.py
asterisk/trunk/lib/python/asterisk/version.py
asterisk/trunk/runtests.py
asterisk/trunk/tests/ami-login/run-test
asterisk/trunk/tests/iax-call-basic/run-test
Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=192&r1=191&r2=192
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Fri Apr 2 16:34:43 2010
@@ -66,12 +66,11 @@
# Choose an install base
self.base = base
if self.base is None:
- self.base = "{0}/tmp".format(os.getcwd())
+ self.base = "%s/tmp" % os.getcwd()
i = 1
while True:
- d = "{0}/ast{1}".format(self.base, i)
- if not os.path.isdir(d):
- self.base = d
+ if not os.path.isdir("%s/ast%d" % (self.base, i)):
+ self.base = "%s/ast%d" % (self.base, i)
break
i += 1
os.makedirs(self.base)
@@ -99,7 +98,7 @@
cmd = [
"asterisk",
"-f", "-g", "-q", "-m",
- "-C", os.path.join(self.astetcdir, "asterisk.conf")
+ "-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf")
]
self.process = subprocess.Popen(cmd)
time.sleep(5.0)
@@ -140,7 +139,7 @@
asterisk.install_config("tests/my-cool-test/configs/manager.conf")
"""
if not os.path.exists(cfg_path):
- print "Config file '{0}' does not exist".format(cfg_path)
+ print "Config file '%s' does not exist" % cfg_path
return
if not self.astetcdir:
print "Don't know where to put local config!"
@@ -151,9 +150,9 @@
try:
shutil.copyfile(cfg_path, target_path)
except shutil.Error:
- print "'{0}' and '{1}' are the same file".format(cfg_path, target_path)
+ print "'%s' and '%s' are the same file" % (cfg_path, target_path)
except IOError:
- print "The destination is not writable '{0}'".format(target_path)
+ print "The destination is not writable '%s'" % target_path
def cli_exec(self, cli_cmd):
"""Execute a CLI command on this instance of Asterisk.
@@ -166,10 +165,10 @@
"""
cmd = [
"asterisk",
- "-C", os.path.join(self.astetcdir, "asterisk.conf"),
- "-rx", cli_cmd
+ "-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf"),
+ "-rx", "%s" % cli_cmd
]
- print "Executing {0} ...".format(cmd)
+ print "Executing %s ..." % cmd
process = subprocess.Popen(cmd)
process.wait()
@@ -177,7 +176,7 @@
self.astetcdir = None
for (var, val) in dir_cat.options:
if var == "astetcdir":
- self.astetcdir = "{0}{1}".format(self.base, val)
+ self.astetcdir = "%s%s" % (self.base, val)
os.makedirs(self.astetcdir)
if self.astetcdir is None:
@@ -189,20 +188,20 @@
try:
f = open(local_ast_conf_path, "w")
except IOError:
- print "Failed to open {0}".format(local_ast_conf_path)
+ print "Failed to open %s" % local_ast_conf_path
return
except:
- print "Unexpected error: {0}".format(sys.exc_info()[0])
+ print "Unexpected error: %s" % sys.exc_info()[0]
return
for c in ast_conf.categories:
- f.write("[{0}]\n\n".format(c.name))
+ f.write("[%s]\n\n" % c.name)
if c.name == "directories":
for (var, val) in c.options:
- f.write("{0} = {1}{2}\n".format(var, self.base, val))
+ f.write("%s = %s%s\n" % (var, self.base, val))
else:
for (var, val) in c.options:
- f.write("{0} = {1}\n".format(var, val))
+ f.write("%s = %s\n" % (var, val))
f.write("\n")
f.close()
@@ -215,15 +214,15 @@
blacklist = [ "astdb" ]
for dirname, dirnames, filenames in os.walk(ast_dir_path):
for filename in filenames:
- target = "{0}/{1}".format(self.base, os.path.join(ast_dir_path,
- dirname, filename))
+ target = "%s/%s" % (self.base, os.path.join(ast_dir_path,
+ dirname, filename))
if os.path.exists(target) or filename in blacklist:
continue
os.symlink(os.path.join(ast_dir_path, dirname, filename),
target)
def __makedirs(self, ast_dir_path):
- target_dir = "{0}{1}".format(self.base, ast_dir_path)
+ target_dir = "%s%s" % (self.base, ast_dir_path)
if not os.path.exists(target_dir):
os.makedirs(target_dir)
for dirname, dirnames, filenames in os.walk(ast_dir_path):
Modified: asterisk/trunk/lib/python/asterisk/config.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/config.py?view=diff&rev=192&r1=191&r2=192
==============================================================================
--- asterisk/trunk/lib/python/asterisk/config.py (original)
+++ asterisk/trunk/lib/python/asterisk/config.py Fri Apr 2 16:34:43 2010
@@ -49,7 +49,7 @@
match = self.varval_re.match(line)
if match is None:
if not is_blank_line(line):
- print "Invalid line: '{0}'".format(line.strip())
+ print "Invalid line: '%s'" % line.strip()
return
self.options.append((match.group("name"), match.group("value").strip()))
@@ -80,10 +80,10 @@
config_str = f.read()
f.close()
except IOError:
- print "Failed to open config file '{0}'".format(fn)
+ print "Failed to open config file '%s'" % fn
return
except:
- print "Unexpected error: {0}".format(sys.exc_info()[0])
+ print "Unexpected error: %s" % sys.exc_info()[0]
return
config_str = self.strip_mline_comments(config_str)
@@ -103,7 +103,7 @@
)
elif len(self.categories) == 0:
if not is_blank_line(line):
- print "Invalid line: '{0}'".format(line.strip())
+ print "Invalid line: '%s'" % line.strip()
else:
self.categories[-1].parse_line(line)
@@ -178,12 +178,9 @@
if len(argv) == 2:
conf = ConfigFile(argv[1])
for c in conf.categories:
- t = ""
- if c.template:
- t = "(!)"
- print "[{0}]{1}".format(c.name, t)
+ print "[%s]" % c.name
for (var, val) in c.options:
- print "{0} = {1}".format(var, val)
+ print "%s = %s" % (var, val)
else:
return unittest.main()
Modified: asterisk/trunk/lib/python/asterisk/version.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/version.py?view=diff&rev=192&r1=191&r2=192
==============================================================================
--- asterisk/trunk/lib/python/asterisk/version.py (original)
+++ asterisk/trunk/lib/python/asterisk/version.py Fri Apr 2 16:34:43 2010
@@ -106,9 +106,9 @@
v = match.group(1)
f.close()
except IOError:
- print "I/O Error getting Asterisk version from {0}".format(path)
+ print "I/O Error getting Asterisk version from %s" % path
except:
- print "Unexpected error getting version from {0}: {1}".format(math,
+ print "Unexpected error getting version from %s: %s" % (path,
sys.exc_info()[0])
return v
Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=192&r1=191&r2=192
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Fri Apr 2 16:34:43 2010
@@ -83,14 +83,14 @@
self.passed = False
start_time = time.time()
cmd = [
- "tests/{0}/run-test".format(self.test_name),
+ "tests/%s/run-test" % self.test_name,
"-v", str(self.ast_version)
]
if os.path.exists(cmd[0]):
- print "Running {0} ...".format(cmd)
+ print "Running %s ..." % cmd
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- p2 = subprocess.Popen(["tee", "tests/{0}/test-output.txt".format(
- self.test_name)], stdin=p.stdout)
+ p2 = subprocess.Popen(["tee", "tests/%s/test-output.txt" %
+ self.test_name], stdin=p.stdout)
p.wait()
p2.wait()
self.passed = p.returncode == 0
@@ -118,25 +118,25 @@
self.minversion = AsteriskVersion(properties["minversion"])
except:
self.can_run = False
- print "ERROR: '{0}' is not a valid minversion".format(
- properties["minversion"])
+ print "ERROR: '%s' is not a valid minversion" % \
+ properties["minversion"]
if "maxversion" in properties:
try:
self.maxversion = AsteriskVersion(properties["maxversion"])
except:
self.can_run = False
- print "ERROR: '{0}' is not a valid maxversion".format(
- properties["maxversion"])
+ print "ERROR: '%s' is not a valid maxversion" % \
+ properties["maxversion"]
def __parse_config(self):
- test_config = "tests/{0}/test-config.yaml".format(self.test_name)
+ test_config = "tests/%s/test-config.yaml" % self.test_name
try:
f = open(test_config, "r")
except IOError:
- print "Failed to open {0}".format(test_config)
+ print "Failed to open %s" % test_config
return
except:
- print "Unexpected error: {0}".format(sys.exc_info()[0])
+ print "Unexpected error: %s" % sys.exc_info()[0]
return
self.config = yaml.load(f)
@@ -174,10 +174,10 @@
try:
f = open(TESTS_CONFIG, "r")
except IOError:
- print "Failed to open {0}".format(TESTS_CONFIG)
+ print "Failed to open %s" % TESTS_CONFIG
return
except:
- print "Unexpected error: {0}".format(sys.exc_info()[0])
+ print "Unexpected error: %s" % sys.exc_info()[0]
return
self.config = yaml.load(f)
@@ -193,16 +193,16 @@
print "Configured tests:"
i = 1
for t in self.tests:
- print "{0:3d}) {1}".format(i, t.test_name)
- print " --> Summary: {0}".format(t.summary)
- print " --> Minimum Version: {0} ({1})".format(
- t.minversion, t.minversion_check)
+ print "%.3d) %s" % (i, t.test_name)
+ print " --> Summary: %s" % t.summary
+ print " --> Minimum Version: %s (%s)" % \
+ (str(t.minversion), str(t.minversion_check))
if t.maxversion is not None:
- print " --> Maximum Version: {0} ({1})".format(
- t.maxversion, t.maxversion_check)
+ print " --> Maximum Version: %s (%s)" % \
+ (str(t.maxversion), str(t.maxversion_check))
for d in t.deps:
- print " --> Dependency: {0} -- Met: {1}".format(d.name,
- d.met)
+ print " --> Dependency: %s -- Met: %s" % (d.name,
+ str(d.met))
i += 1
def run(self, ast_version):
@@ -210,13 +210,13 @@
for t in self.tests:
if t.can_run is False:
- print "--> Can not run test '{0}'".format(t.test_name)
+ print "--> Can not run test '%s'" % t.test_name
for d in t.deps:
- print "--- --> Dependency: {0} - {1}".format(d.name, d.met)
+ print "--- --> Dependency: %s - %s" % (d.name, str(d.met))
print
continue
- print "--> Running test '{0}' ...\n".format(t.test_name)
+ print "--> Running test '%s' ...\n" % t.test_name
# Establish Preconditions
os.chdir("..")
@@ -237,31 +237,30 @@
try:
f = open(TEST_RESULTS, "w")
except IOError:
- print "Failed to open file: {0}".format(TEST_RESULTS)
+ print "Failed to open test results output file: %s" % TEST_RESULTS
return
except:
- print "Unexpected error: {0}".format(sys.exc_info()[0])
+ print "Unexpected error: %s" % sys.exc_info()[0]
return
f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
- f.write('<testsuite errors="0" time="{0:.2f}" tests="{1}" '
- 'name="AsteriskTestSuite">\n'.format(
- self.total_time, len(self.tests)))
+ f.write('<testsuite errors="0" time="%.2f" tests="%d" '
+ 'name="AsteriskTestSuite">\n' %
+ (self.total_time, len(self.tests)))
for t in self.tests:
if t.can_run is False:
continue
- f.write('\t<testcase time="{0:.2f}" name="{1}"'.format(t.time, t.test_name))
+ f.write('\t<testcase time="%.2f" name="%s"' % (t.time, t.test_name))
if t.passed is True:
f.write('/>\n')
continue
f.write(">\n\t\t<failure><![CDATA[\n")
try:
- test_output = open("tests/{0}/test-output.txt".format(
- t.test_name), "r")
- f.write(test_output.read())
+ test_output = open("tests/%s/test-output.txt" % t.test_name, "r")
+ f.write("%s" % test_output.read())
test_output.close()
except IOError:
- print "Failed to open test output for {0}".format(t.test_name)
+ print "Failed to open test output for %s" % t.test_name
f.write("\n\t\t]]></failure>\n\t</testcase>\n")
f.write('</testsuite>\n')
f.close()
@@ -270,10 +269,10 @@
try:
f = open(TEST_RESULTS, "r")
except IOError:
- print "Failed to open test results output file: {0}".format(
- TEST_RESULTS)
+ print "Failed to open test results output file: %s" % \
+ TEST_RESULTS
except:
- print "Unexpected error: {0}".format(sys.exc_info()[0])
+ print "Unexpected error: %s" % sys.exc_info()[0]
else:
print f.read()
f.close()
@@ -309,7 +308,7 @@
test_suite = TestSuite(ast_version)
if options.list_tests is True:
- print "Asterisk Version: {0}\n".format(ast_version)
+ print "Asterisk Version: %s\n" % str(ast_version)
test_suite.list_tests()
return 0
@@ -318,7 +317,7 @@
print BIG_WARNING
return 1
- print "Running tests for Asterisk {0} ...\n".format(ast_version)
+ print "Running tests for Asterisk %s ...\n" % str(ast_version)
test_suite.run(ast_version)
@@ -326,7 +325,7 @@
for t in test_suite.tests:
if t.can_run is False:
continue
- sys.stdout.write("--> {0} --- ".format(t.test_name))
+ sys.stdout.write("--> %s --- " % t.test_name)
if t.passed is True:
print "PASSED"
else:
Modified: asterisk/trunk/tests/ami-login/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/ami-login/run-test?view=diff&rev=192&r1=191&r2=192
==============================================================================
--- asterisk/trunk/tests/ami-login/run-test (original)
+++ asterisk/trunk/tests/ami-login/run-test Fri Apr 2 16:34:43 2010
@@ -53,7 +53,7 @@
self.last_step = step
def on_error(self, ami):
- print "ERROR, Last Step: {0}".format(self.last_step)
+ print "ERROR, Last Step: %s" % self.last_step
self.stop_asterisk()
def on_logoff(self, ami):
Modified: asterisk/trunk/tests/iax-call-basic/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax-call-basic/run-test?view=diff&rev=192&r1=191&r2=192
==============================================================================
--- asterisk/trunk/tests/iax-call-basic/run-test (original)
+++ asterisk/trunk/tests/iax-call-basic/run-test Fri Apr 2 16:34:43 2010
@@ -54,7 +54,7 @@
def fastagi_func(self, agi):
sequence = fastagi.InSequence()
def get_channel(c):
- print "Connection received for {0} ...".format(c)
+ print "Connection received for %s ..." % c
if c.split("-")[0] == "IAX2/127.0.0.1:4569":
self.chan1_connected = True
elif c.split("-")[0] == "IAX2/127.0.0.1:4570":
More information about the asterisk-commits
mailing list