summaryrefslogtreecommitdiffstats
path: root/QMTest
diff options
context:
space:
mode:
Diffstat (limited to 'QMTest')
-rw-r--r--QMTest/SConscript3
-rw-r--r--QMTest/TestCmd.py68
-rw-r--r--QMTest/TestCommon.py57
-rw-r--r--QMTest/TestRuntest.py15
-rw-r--r--QMTest/TestSCons.py124
-rw-r--r--QMTest/TestSConsMSVS.py25
-rw-r--r--QMTest/TestSCons_time.py19
-rw-r--r--QMTest/TestSConsign.py7
-rw-r--r--QMTest/scons_tdb.py33
-rw-r--r--QMTest/unittest.py40
10 files changed, 192 insertions, 199 deletions
diff --git a/QMTest/SConscript b/QMTest/SConscript
index e141a51..8e5585f 100644
--- a/QMTest/SConscript
+++ b/QMTest/SConscript
@@ -26,7 +26,6 @@
#
import os.path
-import string
Import('build_dir', 'env')
@@ -50,7 +49,7 @@ def copy(target, source, env):
# Note: We construct the __ VERSION __ substitution string at
# run-time so it doesn't get replaced when this file gets copied
# into the tree for packaging.
- c = string.replace(c, '__' + 'VERSION' + '__', env['VERSION'])
+ c = c.replace('__' + 'VERSION' + '__', env['VERSION'])
open(t, 'wb').write(c)
for file in files:
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index 029c1d0..163a78d 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -213,6 +213,7 @@ version.
# PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
# AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
__author__ = "Steven Knight <knight at baldmt dot com>"
__revision__ = "TestCmd.py 0.37.D001 2010/01/11 16:55:50 knight"
@@ -224,7 +225,6 @@ import os.path
import re
import shutil
import stat
-import string
import sys
import tempfile
import time
@@ -282,7 +282,7 @@ _chain_to_exitfunc = None
def _clean():
global _Cleanup
- cleanlist = filter(None, _Cleanup)
+ cleanlist = [_f for _f in _Cleanup if _f]
del _Cleanup[:]
cleanlist.reverse()
for test in cleanlist:
@@ -307,16 +307,16 @@ try:
except NameError:
def zip(*lists):
result = []
- for i in xrange(min(map(len, lists))):
- result.append(tuple(map(lambda l, i=i: l[i], lists)))
+ for i in xrange(min(list(map(len, lists)))):
+ result.append(tuple([l[i] for l in lists]))
return result
class Collector:
def __init__(self, top):
self.entries = [top]
def __call__(self, arg, dirname, names):
- pathjoin = lambda n, d=dirname: os.path.join(d, n)
- self.entries.extend(map(pathjoin, names))
+ pathjoin = lambda n: os.path.join(dirname, n)
+ self.entries.extend(list(map(pathjoin, names)))
def _caller(tblist, skip):
string = ""
@@ -407,9 +407,9 @@ def match_exact(lines = None, matches = None):
"""
"""
if not is_List(lines):
- lines = string.split(lines, "\n")
+ lines = lines.split("\n")
if not is_List(matches):
- matches = string.split(matches, "\n")
+ matches = matches.split("\n")
if len(lines) != len(matches):
return
for i in range(len(lines)):
@@ -421,9 +421,9 @@ def match_re(lines = None, res = None):
"""
"""
if not is_List(lines):
- lines = string.split(lines, "\n")
+ lines = lines.split("\n")
if not is_List(res):
- res = string.split(res, "\n")
+ res = res.split("\n")
if len(lines) != len(res):
return
for i in range(len(lines)):
@@ -441,9 +441,9 @@ def match_re_dotall(lines = None, res = None):
"""
"""
if not type(lines) is type(""):
- lines = string.join(lines, "\n")
+ lines = "\n".join(lines)
if not type(res) is type(""):
- res = string.join(res, "\n")
+ res = "\n".join(res)
s = "^" + res + "$"
try:
expr = re.compile(s, re.DOTALL)
@@ -472,15 +472,15 @@ else:
for op, a1, a2, b1, b2 in sm.get_opcodes():
if op == 'delete':
result.append("%sd%d" % (comma(a1, a2), b1))
- result.extend(map(lambda l: '< ' + l, a[a1:a2]))
+ result.extend(['< ' + l for l in a[a1:a2]])
elif op == 'insert':
result.append("%da%s" % (a1, comma(b1, b2)))
- result.extend(map(lambda l: '> ' + l, b[b1:b2]))
+ result.extend(['> ' + l for l in b[b1:b2]])
elif op == 'replace':
result.append("%sc%s" % (comma(a1, a2), comma(b1, b2)))
- result.extend(map(lambda l: '< ' + l, a[a1:a2]))
+ result.extend(['< ' + l for l in a[a1:a2]])
result.append('---')
- result.extend(map(lambda l: '> ' + l, b[b1:b2]))
+ result.extend(['> ' + l for l in b[b1:b2]])
return result
def diff_re(a, b, fromfile='', tofile='',
@@ -530,13 +530,13 @@ if sys.platform == 'win32':
if path is None:
path = os.environ['PATH']
if is_String(path):
- path = string.split(path, os.pathsep)
+ path = path.split(os.pathsep)
if pathext is None:
pathext = os.environ['PATHEXT']
if is_String(pathext):
- pathext = string.split(pathext, os.pathsep)
+ pathext = pathext.split(os.pathsep)
for ext in pathext:
- if string.lower(ext) == string.lower(file[-len(ext):]):
+ if ext.lower() == file[-len(ext):].lower():
pathext = ['']
break
for dir in path:
@@ -553,7 +553,7 @@ else:
if path is None:
path = os.environ['PATH']
if is_String(path):
- path = string.split(path, os.pathsep)
+ path = path.split(os.pathsep)
for dir in path:
f = os.path.join(dir, file)
if os.path.isfile(f):
@@ -649,14 +649,14 @@ except ImportError:
universal_newlines = 1
def __init__(self, command, **kw):
if kw.get('stderr') == 'STDOUT':
- apply(popen2.Popen4.__init__, (self, command, 1))
+ popen2.Popen4.__init__(self, command, 1)
else:
- apply(popen2.Popen3.__init__, (self, command, 1))
+ popen2.Popen3.__init__(self, command, 1)
self.stdin = self.tochild
self.stdout = self.fromchild
self.stderr = self.childerr
def wait(self, *args, **kw):
- resultcode = apply(popen2.Popen3.wait, (self,)+args, kw)
+ resultcode = popen2.Popen3.wait(self, *args, **kw)
if os.WIFEXITED(resultcode):
return os.WEXITSTATUS(resultcode)
elif os.WIFSIGNALED(resultcode):
@@ -879,7 +879,7 @@ class TestCmd(object):
#self.diff_function = difflib.unified_diff
self._dirlist = []
self._preserve = {'pass_test': 0, 'fail_test': 0, 'no_result': 0}
- if os.environ.has_key('PRESERVE') and not os.environ['PRESERVE'] is '':
+ if 'PRESERVE' in os.environ and not os.environ['PRESERVE'] is '':
self._preserve['pass_test'] = os.environ['PRESERVE']
self._preserve['fail_test'] = os.environ['PRESERVE']
self._preserve['no_result'] = os.environ['PRESERVE']
@@ -924,9 +924,9 @@ class TestCmd(object):
slash = '\\'
special = '"$'
- arg = string.replace(arg, slash, slash+slash)
+ arg = arg.replace(slash, slash+slash)
for c in special:
- arg = string.replace(arg, c, slash+c)
+ arg = arg.replace(c, slash+c)
if re_space.search(arg):
arg = '"' + arg + '"'
@@ -944,7 +944,7 @@ class TestCmd(object):
def canonicalize(self, path):
if is_List(path):
- path = apply(os.path.join, tuple(path))
+ path = os.path.join(*tuple(path))
if not os.path.isabs(path):
path = os.path.join(self.workdir, path)
return path
@@ -1012,7 +1012,7 @@ class TestCmd(object):
cmd = list(interpreter) + cmd
if arguments:
if type(arguments) == type(''):
- arguments = string.split(arguments)
+ arguments = arguments.split()
cmd.extend(arguments)
return cmd
@@ -1033,7 +1033,7 @@ class TestCmd(object):
def diff(self, a, b, name, *args, **kw):
print self.banner(name)
args = (a.splitlines(), b.splitlines()) + args
- lines = apply(self.diff_function, args, kw)
+ lines = self.diff_function(*args, **kw)
for l in lines:
print l
@@ -1149,7 +1149,7 @@ class TestCmd(object):
prepended unless it is enclosed in a [list].
"""
cmd = self.command_args(program, interpreter, arguments)
- cmd_string = string.join(map(self.escape, cmd), ' ')
+ cmd_string = ' '.join(map(self.escape, cmd))
if self.verbose:
sys.stderr.write(cmd_string + "\n")
if universal_newlines is None:
@@ -1314,7 +1314,7 @@ class TestCmd(object):
if sub is None:
continue
if is_List(sub):
- sub = apply(os.path.join, tuple(sub))
+ sub = os.path.join(*tuple(sub))
new = os.path.join(self.workdir, sub)
try:
os.mkdir(new)
@@ -1362,7 +1362,7 @@ class TestCmd(object):
# letters is pretty much random on win32:
drive,rest = os.path.splitdrive(path)
if drive:
- path = string.upper(drive) + rest
+ path = drive.upper() + rest
#
self._dirlist.append(path)
@@ -1404,7 +1404,7 @@ class TestCmd(object):
"""Find an executable file.
"""
if is_List(file):
- file = apply(os.path.join, tuple(file))
+ file = os.path.join(*tuple(file))
if not os.path.isabs(file):
file = where_is(file, path, pathext)
return file
@@ -1426,7 +1426,7 @@ class TestCmd(object):
the temporary working directory name with the specified
arguments using the os.path.join() method.
"""
- return apply(os.path.join, (self.workdir,) + tuple(args))
+ return os.path.join(self.workdir, *tuple(args))
def readable(self, top, read=1):
"""Make the specified directory tree readable (read == 1)
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index 4aa7185..e9ae6a4 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -87,6 +87,7 @@ The TestCommon module also provides the following variables
# PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
# AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
__author__ = "Steven Knight <knight at baldmt dot com>"
__revision__ = "TestCommon.py 0.37.D001 2010/01/11 16:55:50 knight"
@@ -96,7 +97,6 @@ import copy
import os
import os.path
import stat
-import string
import sys
import types
import UserList
@@ -134,7 +134,7 @@ elif sys.platform == 'cygwin':
lib_suffix = '.a'
dll_prefix = ''
dll_suffix = '.dll'
-elif string.find(sys.platform, 'irix') != -1:
+elif sys.platform.find('irix') != -1:
exe_suffix = ''
obj_suffix = '.o'
shobj_suffix = '.o'
@@ -143,7 +143,7 @@ elif string.find(sys.platform, 'irix') != -1:
lib_suffix = '.a'
dll_prefix = 'lib'
dll_suffix = '.so'
-elif string.find(sys.platform, 'darwin') != -1:
+elif sys.platform.find('darwin') != -1:
exe_suffix = ''
obj_suffix = '.o'
shobj_suffix = '.os'
@@ -152,7 +152,7 @@ elif string.find(sys.platform, 'darwin') != -1:
lib_suffix = '.a'
dll_prefix = 'lib'
dll_suffix = '.dylib'
-elif string.find(sys.platform, 'sunos') != -1:
+elif sys.platform.find('sunos') != -1:
exe_suffix = ''
obj_suffix = '.o'
shobj_suffix = '.os'
@@ -217,7 +217,7 @@ class TestCommon(TestCmd):
calling the base class initialization, and then changing directory
to the workdir.
"""
- apply(TestCmd.__init__, [self], kw)
+ TestCmd.__init__(self, **kw)
os.chdir(self.workdir)
def must_be_writable(self, *files):
@@ -227,20 +227,20 @@ class TestCommon(TestCmd):
them. Exits FAILED if any of the files does not exist or is
not writable.
"""
- files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
+ files = [is_List(x) and os.path.join(*x) or x for x in files]
existing, missing = separate_files(files)
- unwritable = filter(lambda x, iw=is_writable: not iw(x), existing)
+ unwritable = [x for x in existing if not is_writable(x)]
if missing:
- print "Missing files: `%s'" % string.join(missing, "', `")
+ print "Missing files: `%s'" % "', `".join(missing)
if unwritable:
- print "Unwritable files: `%s'" % string.join(unwritable, "', `")
+ print "Unwritable files: `%s'" % "', `".join(unwritable)
self.fail_test(missing + unwritable)
def must_contain(self, file, required, mode = 'rb'):
"""Ensures that the specified file contains the required text.
"""
file_contents = self.read(file, mode)
- contains = (string.find(file_contents, required) != -1)
+ contains = (file_contents.find(required) != -1)
if not contains:
print "File `%s' does not contain required string." % file
print self.banner('Required string ')
@@ -261,7 +261,7 @@ class TestCommon(TestCmd):
for lines in the output.
"""
if find is None:
- find = lambda o, l: string.find(o, l) != -1
+ find = lambda o, l: o.find(l) != -1
missing = []
for line in lines:
if not find(output, line):
@@ -289,7 +289,7 @@ class TestCommon(TestCmd):
for lines in the output.
"""
if find is None:
- find = lambda o, l: string.find(o, l) != -1
+ find = lambda o, l: o.find(l) != -1
for line in lines:
if find(output, line):
return
@@ -313,10 +313,10 @@ class TestCommon(TestCmd):
pathname will be constructed by concatenating them. Exits FAILED
if any of the files does not exist.
"""
- files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
- missing = filter(lambda x: not os.path.exists(x), files)
+ files = [is_List(x) and os.path.join(*x) or x for x in files]
+ missing = [x for x in files if not os.path.exists(x)]
if missing:
- print "Missing files: `%s'" % string.join(missing, "', `")
+ print "Missing files: `%s'" % "', `".join(missing)
self.fail_test(missing)
def must_match(self, file, expect, mode = 'rb'):
@@ -339,7 +339,7 @@ class TestCommon(TestCmd):
"""Ensures that the specified file doesn't contain the banned text.
"""
file_contents = self.read(file, mode)
- contains = (string.find(file_contents, banned) != -1)
+ contains = (file_contents.find(banned) != -1)
if contains:
print "File `%s' contains banned string." % file
print self.banner('Banned string ')
@@ -360,7 +360,7 @@ class TestCommon(TestCmd):
for lines in the output.
"""
if find is None:
- find = lambda o, l: string.find(o, l) != -1
+ find = lambda o, l: o.find(l) != -1
unexpected = []
for line in lines:
if find(output, line):
@@ -385,10 +385,10 @@ class TestCommon(TestCmd):
which case the pathname will be constructed by concatenating them.
Exits FAILED if any of the files exists.
"""
- files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
- existing = filter(os.path.exists, files)
+ files = [is_List(x) and os.path.join(*x) or x for x in files]
+ existing = list(filter(os.path.exists, files))
if existing:
- print "Unexpected files exist: `%s'" % string.join(existing, "', `")
+ print "Unexpected files exist: `%s'" % "', `".join(existing)
self.fail_test(existing)
@@ -399,13 +399,13 @@ class TestCommon(TestCmd):
them. Exits FAILED if any of the files does not exist or is
writable.
"""
- files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
+ files = [is_List(x) and os.path.join(*x) or x for x in files]
existing, missing = separate_files(files)
- writable = filter(is_writable, existing)
+ writable = list(filter(is_writable, existing))
if missing:
- print "Missing files: `%s'" % string.join(missing, "', `")
+ print "Missing files: `%s'" % "', `".join(missing)
if writable:
- print "Writable files: `%s'" % string.join(writable, "', `")
+ print "Writable files: `%s'" % "', `".join(writable)
self.fail_test(missing + writable)
def _complete(self, actual_stdout, expected_stdout,
@@ -458,9 +458,8 @@ class TestCommon(TestCmd):
else:
arguments = options + " " + arguments
try:
- return apply(TestCmd.start,
- (self, program, interpreter, arguments, universal_newlines),
- kw)
+ return TestCmd.start(self, program, interpreter, arguments, universal_newlines,
+ **kw)
except KeyboardInterrupt:
raise
except Exception, e:
@@ -496,7 +495,7 @@ class TestCommon(TestCmd):
command. A value of None means don't
test exit status.
"""
- apply(TestCmd.finish, (self, popen,), kw)
+ TestCmd.finish(self, popen, **kw)
match = kw.get('match', self.match)
self._complete(self.stdout(), stdout,
self.stderr(), stderr, status, match)
@@ -538,7 +537,7 @@ class TestCommon(TestCmd):
del kw['match']
except KeyError:
match = self.match
- apply(TestCmd.run, [self], kw)
+ TestCmd.run(self, **kw)
self._complete(self.stdout(), stdout,
self.stderr(), stderr, status, match)
diff --git a/QMTest/TestRuntest.py b/QMTest/TestRuntest.py
index 679a6ab..11f8ab2 100644
--- a/QMTest/TestRuntest.py
+++ b/QMTest/TestRuntest.py
@@ -19,7 +19,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
import os.path
import re
-import string
import shutil
import sys
@@ -39,7 +38,7 @@ if re.search('\s', python):
pythonstring = _python_
else:
pythonstring = python
-pythonstring = string.replace(pythonstring, '\\', '\\\\')
+pythonstring = pythonstring.replace('\\', '\\\\')
failing_test_template = """\
@@ -108,14 +107,14 @@ class TestRuntest(TestCommon):
appears in a normal workspace.
"""
set_workpath_runtest = None
- if not kw.has_key('program'):
+ if 'program' not in kw:
kw['program'] = 'runtest.py'
set_workpath_runtest = 1
- if not kw.has_key('interpreter'):
+ if 'interpreter' not in kw:
kw['interpreter'] = [python, '-tt']
- if not kw.has_key('match'):
+ if 'match' not in kw:
kw['match'] = match_exact
- if not kw.has_key('workdir'):
+ if 'workdir' not in kw:
kw['workdir'] = ''
try:
@@ -126,7 +125,7 @@ class TestRuntest(TestCommon):
del kw['noqmtest']
orig_cwd = os.getcwd()
- apply(TestCommon.__init__, [self], kw)
+ TestCommon.__init__(self, **kw)
if not noqmtest:
qmtest = self.where_is('qmtest')
@@ -141,7 +140,7 @@ class TestRuntest(TestCommon):
dirs = [os.environ.get('SCONS_RUNTEST_DIR', orig_cwd)]
spe = os.environ.get('SCONS_SOURCE_PATH_EXECUTABLE', orig_cwd)
- for d in string.split(spe, os.pathsep):
+ for d in spe.split(os.pathsep):
dirs.append(os.path.join(d, 'build'))
dirs.append(d)
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index 506f708..38f2c92 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -13,13 +13,13 @@ attributes defined in this subclass.
"""
# __COPYRIGHT__
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
import re
import shutil
-import string
import sys
import time
@@ -30,7 +30,7 @@ except AttributeError:
def zip(*lists):
result = []
for i in xrange(len(lists[0])):
- result.append(tuple(map(lambda l, i=i: l[i], lists)))
+ result.append(tuple([l[i] for l in lists]))
return result
__builtin__.zip = zip
@@ -123,7 +123,7 @@ def gccFortranLibs():
stderr = p.stderr
for l in stderr.readlines():
- list = string.split(l)
+ list = l.split()
if len(list) > 3 and list[:2] == ['gcc', 'version']:
if list[2][:3] in ('4.1','4.2','4.3'):
libs = ['gfortranbegin']
@@ -148,7 +148,7 @@ if sys.platform == 'win32':
fortran_lib = gccFortranLibs()
elif sys.platform == 'cygwin':
fortran_lib = gccFortranLibs()
-elif string.find(sys.platform, 'irix') != -1:
+elif sys.platform.find('irix') != -1:
fortran_lib = ['ftn']
else:
fortran_lib = gccFortranLibs()
@@ -161,7 +161,7 @@ file_expr = r"""File "[^"]*", line \d+, in .+
# re.escape escapes too much.
def re_escape(str):
for c in ['.', '[', ']', '(', ')', '*', '+', '?']: # Not an exhaustive list.
- str = string.replace(str, c, '\\' + c)
+ str = str.replace(c, '\\' + c)
return str
@@ -170,12 +170,12 @@ try:
sys.version_info
except AttributeError:
# Pre-1.6 Python has no sys.version_info
- version_string = string.split(sys.version)[0]
- version_ints = map(int, string.split(version_string, '.'))
+ version_string = sys.version.split()[0]
+ version_ints = list(map(int, version_string.split('.')))
sys.version_info = tuple(version_ints + ['final', 0])
def python_version_string():
- return string.split(sys.version)[0]
+ return sys.version.split()[0]
def python_minor_version_string():
return sys.version[:3]
@@ -234,7 +234,7 @@ class TestSCons(TestCommon):
pass
else:
os.chdir(script_dir)
- if not kw.has_key('program'):
+ if 'program' not in kw:
kw['program'] = os.environ.get('SCONS')
if not kw['program']:
if os.path.exists('scons'):
@@ -243,11 +243,11 @@ class TestSCons(TestCommon):
kw['program'] = 'scons.py'
elif not os.path.isabs(kw['program']):
kw['program'] = os.path.join(self.orig_cwd, kw['program'])
- if not kw.has_key('interpreter') and not os.environ.get('SCONS_EXEC'):
+ if 'interpreter' not in kw and not os.environ.get('SCONS_EXEC'):
kw['interpreter'] = [python, '-tt']
- if not kw.has_key('match'):
+ if 'match' not in kw:
kw['match'] = match_exact
- if not kw.has_key('workdir'):
+ if 'workdir' not in kw:
kw['workdir'] = ''
# Term causing test failures due to bogus readline init
@@ -266,9 +266,9 @@ class TestSCons(TestCommon):
else:
sconsflags = []
sconsflags = sconsflags + ['--warn=no-python-version']
- os.environ['SCONSFLAGS'] = string.join(sconsflags)
+ os.environ['SCONSFLAGS'] = ' '.join(sconsflags)
- apply(TestCommon.__init__, [self], kw)
+ TestCommon.__init__(self, **kw)
import SCons.Node.FS
if SCons.Node.FS.default_fs is None:
@@ -284,7 +284,7 @@ class TestSCons(TestCommon):
if not ENV is None:
kw['ENV'] = ENV
try:
- return apply(SCons.Environment.Environment, args, kw)
+ return SCons.Environment.Environment(*args, **kw)
except (SCons.Errors.UserError, SCons.Errors.InternalError):
return None
@@ -307,7 +307,7 @@ class TestSCons(TestCommon):
return None
result = env.WhereIs(prog)
if norm and os.sep != '/':
- result = string.replace(result, os.sep, '/')
+ result = result.replace(os.sep, '/')
return result
def detect_tool(self, tool, prog=None, ENV=None):
@@ -376,16 +376,16 @@ class TestSCons(TestCommon):
# support the --warn=no-visual-c-missing warning.)
sconsflags = sconsflags + [os.environ.get('TESTSCONS_SCONSFLAGS',
'--warn=no-visual-c-missing')]
- os.environ['SCONSFLAGS'] = string.join(sconsflags)
+ os.environ['SCONSFLAGS'] = ' '.join(sconsflags)
try:
- result = apply(TestCommon.run, (self,)+args, kw)
+ result = TestCommon.run(self, *args, **kw)
finally:
sconsflags = save_sconsflags
return result
def up_to_date(self, options = None, arguments = None, read_str = "", **kw):
s = ""
- for arg in string.split(arguments):
+ for arg in arguments.split():
s = s + "scons: `%s' is up to date.\n" % arg
if options:
arguments = options + " " + arguments
@@ -395,7 +395,7 @@ class TestSCons(TestCommon):
# up-to-date output is okay.
kw['stdout'] = re.escape(stdout) + '.*'
kw['match'] = self.match_re_dotall
- apply(self.run, [], kw)
+ self.run(**kw)
def not_up_to_date(self, options = None, arguments = None, **kw):
"""Asserts that none of the targets listed in arguments is
@@ -403,16 +403,16 @@ class TestSCons(TestCommon):
This function is most useful in conjunction with the -n option.
"""
s = ""
- for arg in string.split(arguments):
+ for arg in arguments.split():
s = s + "(?!scons: `%s' is up to date.)" % re.escape(arg)
if options:
arguments = options + " " + arguments
s = '('+s+'[^\n]*\n)*'
kw['arguments'] = arguments
stdout = re.escape(self.wrap_stdout(build_str='ARGUMENTSGOHERE'))
- kw['stdout'] = string.replace(stdout, 'ARGUMENTSGOHERE', s)
+ kw['stdout'] = stdout.replace('ARGUMENTSGOHERE', s)
kw['match'] = self.match_re_dotall
- apply(self.run, [], kw)
+ self.run(**kw)
def option_not_yet_implemented(self, option, arguments=None, **kw):
"""
@@ -430,7 +430,7 @@ class TestSCons(TestCommon):
kw['arguments'] = option + ' ' + arguments
# TODO(1.5)
#return self.run(**kw)
- return apply(self.run, (), kw)
+ return self.run(**kw)
def diff_substr(self, expect, actual, prelen=20, postlen=40):
i = 0
@@ -461,9 +461,9 @@ class TestSCons(TestCommon):
places, abstracting out the version difference.
"""
exec 'import traceback; x = traceback.format_stack()[-1]'
- x = string.lstrip(x)
- x = string.replace(x, '<string>', file)
- x = string.replace(x, 'line 1,', 'line %s,' % line)
+ x = x.lstrip()
+ x = x.replace('<string>', file)
+ x = x.replace('line 1,', 'line %s,' % line)
return x
def normalize_pdf(self, s):
@@ -486,12 +486,12 @@ class TestSCons(TestCommon):
end_marker = 'endstream\nendobj'
encoded = []
- b = string.find(s, begin_marker, 0)
+ b = s.find(begin_marker, 0)
while b != -1:
b = b + len(begin_marker)
- e = string.find(s, end_marker, b)
+ e = s.find(end_marker, b)
encoded.append((b, e))
- b = string.find(s, begin_marker, e + len(end_marker))
+ b = s.find(begin_marker, e + len(end_marker))
x = 0
r = []
@@ -507,7 +507,7 @@ class TestSCons(TestCommon):
r.append(d)
x = e
r.append(s[x:])
- s = string.join(r, '')
+ s = ''.join(r)
return s
@@ -553,7 +553,7 @@ class TestSCons(TestCommon):
]
java_path = self.paths(patterns) + [env['ENV']['PATH']]
- env['ENV']['PATH'] = string.join(java_path, os.pathsep)
+ env['ENV']['PATH'] = os.pathsep.join(java_path)
return env['ENV']
def java_where_includes(self,version=None):
@@ -634,7 +634,7 @@ class TestSCons(TestCommon):
stderr=None,
status=None)
if version:
- if string.find(self.stderr(), 'javac %s' % version) == -1:
+ if self.stderr().find('javac %s' % version) == -1:
fmt = "Could not find javac for Java version %s, skipping test(s).\n"
self.skip_test(fmt % version)
else:
@@ -673,7 +673,6 @@ class TestSCons(TestCommon):
self.write([dir, 'bin', 'mymoc.py'], """\
import getopt
import sys
-import string
import re
# -w and -z are fake options used in test/QT/QTFLAGS.py
cmd_opts, args = getopt.getopt(sys.argv[1:], 'io:wz', [])
@@ -687,11 +686,11 @@ for opt, arg in cmd_opts:
output.write("/* mymoc.py%s */\\n" % opt_string)
for a in args:
contents = open(a, 'rb').read()
- a = string.replace(a, '\\\\', '\\\\\\\\')
+ a = a.replace('\\\\', '\\\\\\\\')
subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }'
if impl:
contents = re.sub( r'#include.*', '', contents )
- output.write(string.replace(contents, 'Q_OBJECT', subst))
+ output.write(contents.replace('Q_OBJECT', subst))
output.close()
sys.exit(0)
""")
@@ -700,7 +699,6 @@ sys.exit(0)
import os.path
import re
import sys
-import string
output_arg = 0
impl_arg = 0
impl = None
@@ -773,7 +771,7 @@ else:
def Qt_create_SConstruct(self, place):
if type(place) is type([]):
- place = apply(test.workpath, place)
+ place = test.workpath(*place)
self.write(place, """\
if ARGUMENTS.get('noqtdir', 0): QTDIR=None
else: QTDIR=r'%s'
@@ -845,7 +843,7 @@ SConscript( sconscript )
lastEnd = 0
logfile = self.read(self.workpath(logfile))
if (doCheckLog and
- string.find( logfile, "scons: warning: The stored build "
+ logfile.find( "scons: warning: The stored build "
"information has an unexpected class." ) >= 0):
self.fail_test()
sconf_dir = sconf_dir
@@ -957,7 +955,7 @@ print os.path.join(sys.prefix, 'lib', py_ver, 'config')
print py_ver
""")
- return [python] + string.split(string.strip(self.stdout()), '\n')
+ return [python] + self.stdout().strip().split('\n')
def start(self, *args, **kw):
"""
@@ -967,9 +965,9 @@ print py_ver
use standard input without forcing every .start() call in the
individual tests to do so explicitly.
"""
- if not kw.has_key('stdin'):
+ if 'stdin' not in kw:
kw['stdin'] = True
- return apply(TestCommon.start, (self,) + args, kw)
+ return TestCommon.start(self, *args, **kw)
def wait_for(self, fname, timeout=10.0, popen=None):
"""
@@ -1058,12 +1056,12 @@ class TimeSCons(TestSCons):
self.calibrate = os.environ.get('TIMESCONS_CALIBRATE', '0') != '0'
- if not kw.has_key('verbose') and not self.calibrate:
+ if 'verbose' not in kw and not self.calibrate:
kw['verbose'] = True
# TODO(1.5)
#TestSCons.__init__(self, *args, **kw)
- apply(TestSCons.__init__, (self,)+args, kw)
+ TestSCons.__init__(self, *args, **kw)
# TODO(sgk): better way to get the script dir than sys.argv[0]
test_dir = os.path.dirname(sys.argv[0])
@@ -1090,7 +1088,7 @@ class TimeSCons(TestSCons):
The elapsed time to execute each build is printed after
it has finished.
"""
- if not kw.has_key('options') and self.variables:
+ if 'options' not in kw and self.variables:
options = []
for variable, value in self.variables.items():
options.append('%s=%s' % (variable, value))
@@ -1098,16 +1096,16 @@ class TimeSCons(TestSCons):
if self.calibrate:
# TODO(1.5)
#self.calibration(*args, **kw)
- apply(self.calibration, args, kw)
+ self.calibration(*args, **kw)
else:
self.uptime()
# TODO(1.5)
#self.startup(*args, **kw)
#self.full(*args, **kw)
#self.null(*args, **kw)
- apply(self.startup, args, kw)
- apply(self.full, args, kw)
- apply(self.null, args, kw)
+ self.startup(*args, **kw)
+ self.full(*args, **kw)
+ self.null(*args, **kw)
def trace(self, graph, name, value, units, sort=None):
fmt = "TRACE: graph=%s name=%s value=%s units=%s"
@@ -1127,7 +1125,7 @@ class TimeSCons(TestSCons):
for name, args in stats.items():
# TODO(1.5)
#self.trace(name, trace, *args)
- apply(self.trace, (name, trace), args)
+ self.trace(name, trace, **args)
def uptime(self):
try:
@@ -1168,7 +1166,7 @@ class TimeSCons(TestSCons):
kw['status'] = None
# TODO(1.5)
#self.run(*args, **kw)
- apply(self.run, args, kw)
+ self.run(*args, **kw)
sys.stdout.write(self.stdout())
stats = self.collect_stats(self.stdout())
# Delete the time-commands, since no commands are ever
@@ -1182,7 +1180,7 @@ class TimeSCons(TestSCons):
"""
# TODO(1.5)
#self.run(*args, **kw)
- apply(self.run, args, kw)
+ self.run(*args, **kw)
sys.stdout.write(self.stdout())
stats = self.collect_stats(self.stdout())
self.report_traces('full', stats)
@@ -1190,9 +1188,9 @@ class TimeSCons(TestSCons):
#self.trace('full-memory', 'initial', **stats['memory-initial'])
#self.trace('full-memory', 'prebuild', **stats['memory-prebuild'])
#self.trace('full-memory', 'final', **stats['memory-final'])
- apply(self.trace, ('full-memory', 'initial'), stats['memory-initial'])
- apply(self.trace, ('full-memory', 'prebuild'), stats['memory-prebuild'])
- apply(self.trace, ('full-memory', 'final'), stats['memory-final'])
+ self.trace('full-memory', 'initial', **stats['memory-initial'])
+ self.trace('full-memory', 'prebuild', **stats['memory-prebuild'])
+ self.trace('full-memory', 'final', **stats['memory-final'])
def calibration(self, *args, **kw):
"""
@@ -1202,7 +1200,7 @@ class TimeSCons(TestSCons):
"""
# TODO(1.5)
#self.run(*args, **kw)
- apply(self.run, args, kw)
+ self.run(*args, **kw)
if self.variables:
for variable, value in self.variables.items():
sys.stdout.write('VARIABLE: %s=%s\n' % (variable, value))
@@ -1218,7 +1216,7 @@ class TimeSCons(TestSCons):
#self.up_to_date(arguments='.', **kw)
kw = kw.copy()
kw['arguments'] = '.'
- apply(self.up_to_date, (), kw)
+ self.up_to_date(**kw)
sys.stdout.write(self.stdout())
stats = self.collect_stats(self.stdout())
# time-commands should always be 0.0 on a null build, because
@@ -1233,9 +1231,9 @@ class TimeSCons(TestSCons):
#self.trace('null-memory', 'initial', **stats['memory-initial'])
#self.trace('null-memory', 'prebuild', **stats['memory-prebuild'])
#self.trace('null-memory', 'final', **stats['memory-final'])
- apply(self.trace, ('null-memory', 'initial'), stats['memory-initial'])
- apply(self.trace, ('null-memory', 'prebuild'), stats['memory-prebuild'])
- apply(self.trace, ('null-memory', 'final'), stats['memory-final'])
+ self.trace('null-memory', 'initial', **stats['memory-initial'])
+ self.trace('null-memory', 'prebuild', **stats['memory-prebuild'])
+ self.trace('null-memory', 'final', **stats['memory-final'])
def elapsed_time(self):
"""
@@ -1257,7 +1255,7 @@ class TimeSCons(TestSCons):
try:
# TODO(1.5)
#result = TestSCons.run(self, *args, **kw)
- result = apply(TestSCons.run, (self,)+args, kw)
+ result = TestSCons.run(self, *args, **kw)
finally:
self.endTime = time.time()
return result
@@ -1278,8 +1276,8 @@ class TimeSCons(TestSCons):
#dirs = [ d for d in dirs if not d.startswith('TimeSCons-') ]
#files = [ f for f in files if not f.startswith('TimeSCons-') ]
not_timescons_entries = lambda s: not s.startswith('TimeSCons-')
- dirs = filter(not_timescons_entries, dirs)
- files = filter(not_timescons_entries, files)
+ dirs = list(filter(not_timescons_entries, dirs))
+ files = list(filter(not_timescons_entries, files))
for dirname in dirs:
source = os.path.join(root, dirname)
destination = source.replace(source_dir, dest_dir)
diff --git a/QMTest/TestSConsMSVS.py b/QMTest/TestSConsMSVS.py
index 0f6fc6f..ac10cd3 100644
--- a/QMTest/TestSConsMSVS.py
+++ b/QMTest/TestSConsMSVS.py
@@ -18,7 +18,6 @@ in this subclass.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
-import string
import sys
from TestSCons import *
@@ -596,7 +595,7 @@ print "self._msvs_versions =", str(SCons.Tool.MSCommon.query_versions())
replace = 'sys.path = [ %s, join(sys' % enginepath
contents = self.read(fname)
- contents = string.replace(contents, orig, replace)
+ contents = contents.replace(orig, replace)
self.write(fname, contents)
def msvs_substitute(self, input, msvs_ver,
@@ -620,18 +619,18 @@ print "self._msvs_versions =", str(SCons.Tool.MSCommon.query_versions())
if project_guid is None:
project_guid = "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
- if os.environ.has_key('SCONS_LIB_DIR'):
+ if 'SCONS_LIB_DIR' in os.environ:
exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % os.environ['SCONS_LIB_DIR']
else:
exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%s'), join(sys.prefix, 'scons-%s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % (self.scons_version, self.scons_version)
- exec_script_main_xml = string.replace(exec_script_main, "'", "&apos;")
-
- result = string.replace(input, r'<WORKPATH>', workpath)
- result = string.replace(result, r'<PYTHON>', python)
- result = string.replace(result, r'<SCONSCRIPT>', sconscript)
- result = string.replace(result, r'<SCONS_SCRIPT_MAIN>', exec_script_main)
- result = string.replace(result, r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
- result = string.replace(result, r'<PROJECT_GUID>', project_guid)
+ exec_script_main_xml = exec_script_main.replace("'", "&apos;")
+
+ result = input.replace(r'<WORKPATH>', workpath)
+ result = result.replace(r'<PYTHON>', python)
+ result = result.replace(r'<SCONSCRIPT>', sconscript)
+ result = result.replace(r'<SCONS_SCRIPT_MAIN>', exec_script_main)
+ result = result.replace(r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
+ result = result.replace(r'<PROJECT_GUID>', project_guid)
return result
def get_msvs_executable(self, version):
@@ -655,9 +654,9 @@ print "self._msvs_versions =", str(SCons.Tool.MSCommon.query_versions())
else:
sconsflags = []
sconsflags = sconsflags + ['--warn=no-deprecated']
- os.environ['SCONSFLAGS'] = string.join(sconsflags)
+ os.environ['SCONSFLAGS'] = ' '.join(sconsflags)
try:
- result = apply(TestSCons.run, (self,)+args, kw)
+ result = TestSCons.run(self, *args, **kw)
finally:
os.environ['SCONSFLAGS'] = save_sconsflags or ''
return result
diff --git a/QMTest/TestSCons_time.py b/QMTest/TestSCons_time.py
index f9a639e..e846ab5 100644
--- a/QMTest/TestSCons_time.py
+++ b/QMTest/TestSCons_time.py
@@ -17,7 +17,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
import os.path
-import string
import sys
from TestCommon import *
@@ -168,7 +167,7 @@ class TestSCons_time(TestCommon):
pass
else:
os.chdir(script_dir)
- if not kw.has_key('program'):
+ if 'program' not in kw:
p = os.environ.get('SCONS_TIME')
if not p:
p = 'scons-time'
@@ -176,16 +175,16 @@ class TestSCons_time(TestCommon):
p = 'scons-time.py'
kw['program'] = p
- if not kw.has_key('interpreter'):
+ if 'interpreter' not in kw:
kw['interpreter'] = [python, '-tt']
- if not kw.has_key('match'):
+ if 'match' not in kw:
kw['match'] = match_exact
- if not kw.has_key('workdir'):
+ if 'workdir' not in kw:
kw['workdir'] = ''
- apply(TestCommon.__init__, [self], kw)
+ TestCommon.__init__(self, **kw)
# Now that the testing object has been set up, check if we should
# skip the test due to the Python version. We need to be able to
@@ -196,14 +195,14 @@ class TestSCons_time(TestCommon):
try:
import __future__
except ImportError:
- version = string.split(sys.version)[0]
+ version = sys.version.split()[0]
msg = 'scons-time does not work on Python version %s\n' % version
self.skip_test(msg)
try:
eval('[x for x in [1, 2]]')
except SyntaxError:
- version = string.split(sys.version)[0]
+ version = sys.version.split()[0]
msg = 'scons-time does not work on Python version %s\n' % version
self.skip_test(msg)
@@ -247,9 +246,9 @@ class TestSCons_time(TestCommon):
tempdir = realpath(tempdir)
args = (tempdir, 'scons-time-',) + args
- x = apply(os.path.join, args)
+ x = os.path.join(*args)
x = re.escape(x)
- x = string.replace(x, 'time\\-', 'time\\-[^%s]*' % sep)
+ x = x.replace('time\\-', 'time\\-[^%s]*' % sep)
return x
def write_fake_aegis_py(self, name):
diff --git a/QMTest/TestSConsign.py b/QMTest/TestSConsign.py
index 29d8b2c..700c242 100644
--- a/QMTest/TestSConsign.py
+++ b/QMTest/TestSConsign.py
@@ -19,7 +19,6 @@ in this subclass.
import os
import os.path
-import string
import sys
from TestSCons import *
@@ -48,13 +47,13 @@ class TestSConsign(TestSCons):
os.chdir(script_dir)
self.script_dir = os.getcwd()
- apply(TestSCons.__init__, (self,)+args, kw)
+ TestSCons.__init__(self, *args, **kw)
self.my_kw = {
'interpreter' : python, # imported from TestSCons
}
- if not kw.has_key('program'):
+ if 'program' not in kw:
kw['program'] = os.environ.get('SCONS')
if not kw['program']:
if os.path.exists('scons'):
@@ -81,7 +80,7 @@ class TestSConsign(TestSCons):
def run_sconsign(self, *args, **kw):
kw.update(self.my_kw)
- return apply(self.run, args, kw)
+ return self.run(*args, **kw)
# Local Variables:
# tab-width:4
diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py
index b725d3f..73e8430 100644
--- a/QMTest/scons_tdb.py
+++ b/QMTest/scons_tdb.py
@@ -22,13 +22,14 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
"""
QMTest classes to support SCons' testing and Aegis-inspired workflow.
Thanks to Stefan Seefeld for the initial code.
"""
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
########################################################################
# Imports
@@ -96,7 +97,7 @@ def get_explicit_arguments(e):
# Do not record computed fields.
if field.IsComputed():
continue
- if e.__dict__.has_key(name):
+ if name in e.__dict__:
explicit_arguments[name] = e.__dict__[name]
return explicit_arguments
@@ -153,10 +154,10 @@ sys_attributes = [
def get_sys_values():
sys_attributes.sort()
- result = map(lambda k: (k, getattr(sys, k, _null)), sys_attributes)
- result = filter(lambda t: not t[1] is _null, result)
- result = map(lambda t: t[0] + '=' + repr(t[1]), result)
- return string.join(result, '\n ')
+ result = [(k, getattr(sys, k, _null)) for k in sys_attributes]
+ result = [t for t in result if not t[1] is _null]
+ result = [t[0] + '=' + repr(t[1]) for t in result]
+ return '\n '.join(result)
module_attributes = [
'__version__',
@@ -168,10 +169,10 @@ module_attributes = [
def get_module_info(module):
module_attributes.sort()
- result = map(lambda k: (k, getattr(module, k, _null)), module_attributes)
- result = filter(lambda t: not t[1] is _null, result)
- result = map(lambda t: t[0] + '=' + repr(t[1]), result)
- return string.join(result, '\n ')
+ result = [(k, getattr(module, k, _null)) for k in module_attributes]
+ result = [t for t in result if not t[1] is _null]
+ result = [t[0] + '=' + repr(t[1]) for t in result]
+ return '\n '.join(result)
environ_keys = [
'PATH',
@@ -214,10 +215,10 @@ environ_keys = [
def get_environment():
environ_keys.sort()
- result = map(lambda k: (k, os.environ.get(k, _null)), environ_keys)
- result = filter(lambda t: not t[1] is _null, result)
- result = map(lambda t: t[0] + '-' + t[1], result)
- return string.join(result, '\n ')
+ result = [(k, os.environ.get(k, _null)) for k in environ_keys]
+ result = [t for t in result if not t[1] is _null]
+ result = [t[0] + '-' + t[1] for t in result]
+ return '\n '.join(result)
class SConsXMLResultStream(XMLResultStream):
def __init__(self, *args, **kw):
@@ -400,7 +401,7 @@ class AegisBatchStream(FileResultStream):
file_names.sort()
for file_name in file_names:
exit_status = self._outcomes[file_name]
- file_name = string.replace(file_name, '\\', '/')
+ file_name = file_name.replace('\\', '/')
self.file.write(' { file_name = "%s";\n' % file_name)
self.file.write(' exit_status = %s; },\n' % exit_status)
self.file.write('];\n')
diff --git a/QMTest/unittest.py b/QMTest/unittest.py
index c74a4c7..e5a8668 100644
--- a/QMTest/unittest.py
+++ b/QMTest/unittest.py
@@ -28,6 +28,7 @@ PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
"""
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
__author__ = "Steve Purcell (stephen_purcell@yahoo.com)"
__version__ = "$ Revision: 1.23 $"[11:-2]
@@ -35,15 +36,14 @@ __version__ = "$ Revision: 1.23 $"[11:-2]
import time
import sys
import traceback
-import string
import os
##############################################################################
# A platform-specific concession to help the code work for JPython users
##############################################################################
-plat = string.lower(sys.platform)
-_isJPython = string.find(plat, 'java') >= 0 or string.find(plat, 'jdk') >= 0
+plat = sys.platform.lower()
+_isJPython = plat.find('java') >= 0 or plat.find('jdk') >= 0
del plat
@@ -149,7 +149,7 @@ class TestCase:
the specified test method's docstring.
"""
doc = self.__testMethod.__doc__
- return doc and string.strip(string.split(doc, "\n")[0]) or None
+ return doc and doc.split("\n")[0].strip() or None
def id(self):
return "%s.%s" % (self.__class__, self.__testMethod.__name__)
@@ -205,7 +205,7 @@ class TestCase:
def failIf(self, expr, msg=None):
"Fail the test if the expression is true."
- apply(self.assert_,(not expr,msg))
+ self.assert_(not expr,msg)
def assertRaises(self, excClass, callableObj, *args, **kwargs):
"""Assert that an exception of class excClass is thrown
@@ -216,7 +216,7 @@ class TestCase:
unexpected exception.
"""
try:
- apply(callableObj, args, kwargs)
+ callableObj(*args, **kwargs)
except excClass:
return
else:
@@ -326,7 +326,7 @@ class FunctionTestCase(TestCase):
def shortDescription(self):
if self.__description is not None: return self.__description
doc = self.__testFunc.__doc__
- return doc and string.strip(string.split(doc, "\n")[0]) or None
+ return doc and doc.split("\n")[0].strip() or None
@@ -339,8 +339,7 @@ def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp):
and its base classes that start with the given prefix. This is used
by makeSuite().
"""
- testFnNames = filter(lambda n,p=prefix: n[:len(p)] == p,
- dir(testCaseClass))
+ testFnNames = [n for n in dir(testCaseClass) if n[:len(prefix)] == prefix]
for baseclass in testCaseClass.__bases__:
testFnNames = testFnNames + \
getTestCaseNames(baseclass, prefix, sortUsing=None)
@@ -355,8 +354,8 @@ def makeSuite(testCaseClass, prefix='test', sortUsing=cmp):
prefix. The cases are sorted by their function names
using the supplied comparison function, which defaults to 'cmp'.
"""
- cases = map(testCaseClass,
- getTestCaseNames(testCaseClass, prefix, sortUsing))
+ cases = list(map(testCaseClass,
+ getTestCaseNames(testCaseClass, prefix, sortUsing)))
return TestSuite(cases)
@@ -376,18 +375,18 @@ def createTestInstance(name, module=None):
-- returns result of calling makeSuite(ListTestCase, prefix="check")
"""
- spec = string.split(name, ':')
+ spec = name.split(':')
if len(spec) > 2: raise ValueError, "illegal test name: %s" % name
if len(spec) == 1:
testName = spec[0]
caseName = None
else:
testName, caseName = spec
- parts = string.split(testName, '.')
+ parts = testName.split('.')
if module is None:
if len(parts) < 2:
raise ValueError, "incomplete test name: %s" % name
- constructor = __import__(string.join(parts[:-1],'.'))
+ constructor = __import__('.'.join(parts[:-1]))
parts = parts[1:]
else:
constructor = module
@@ -429,7 +428,7 @@ class _WritelnDecorator:
return getattr(self.stream,attr)
def writeln(self, *args):
- if args: apply(self.write, args)
+ if args: self.write(*args)
self.write(self.linesep)
@@ -468,7 +467,7 @@ class _JUnitTextTestResult(TestResult):
(len(errors), errFlavour))
i = 1
for test,error in errors:
- errString = string.join(apply(traceback.format_exception,error),"")
+ errString = "".join(traceback.format_exception(*error))
self.stream.writeln("%i) %s" % (i, test))
self.stream.writeln(errString)
i = i + 1
@@ -567,8 +566,8 @@ class _VerboseTextTestResult(TestResult):
self.stream.writeln(separator1)
self.stream.writeln("\t%s" % flavour)
self.stream.writeln(separator2)
- for line in apply(traceback.format_exception, err):
- for l in string.split(line,"\n")[:-1]:
+ for line in traceback.format_exception(*err):
+ for l in line.split("\n")[:-1]:
self.stream.writeln("\t%s" % l)
self.stream.writeln(separator1)
@@ -597,9 +596,10 @@ class VerboseTextTestRunner:
self.stream.writeln()
if not result.wasSuccessful():
self.stream.write("FAILED (")
- failed, errored = map(len, (result.failures, result.errors))
+ failed = len(result.failures)
if failed:
self.stream.write("failures=%d" % failed)
+ errored = len(result.errors)
if errored:
if failed: self.stream.write(", ")
self.stream.write("errors=%d" % errored)
@@ -635,7 +635,7 @@ Examples:
argv=None, testRunner=None):
if type(module) == type(''):
self.module = __import__(module)
- for part in string.split(module,'.')[1:]:
+ for part in module.split('.')[1:]:
self.module = getattr(self.module, part)
else:
self.module = module