summaryrefslogtreecommitdiffstats
path: root/QMTest/TestCommon.py
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-03-25 04:14:28 (GMT)
committerGreg Noel <GregNoel@tigris.org>2010-03-25 04:14:28 (GMT)
commit22d352500f1cd6bd0c53d788a5dc44a1fefa676e (patch)
tree0984fd581082c27cfbfbb7f94d5751b0e6fd2741 /QMTest/TestCommon.py
parent75ac32ac8e32076e25b72a19eb56340cc585fa4e (diff)
downloadSCons-22d352500f1cd6bd0c53d788a5dc44a1fefa676e.zip
SCons-22d352500f1cd6bd0c53d788a5dc44a1fefa676e.tar.gz
SCons-22d352500f1cd6bd0c53d788a5dc44a1fefa676e.tar.bz2
Move 2.0 changes collected in branches/pending back to trunk for further
development. Note that this set of changes is NOT backward-compatible; the trunk no longer works with Python 1.5.2, 2.0, or 2.1.
Diffstat (limited to 'QMTest/TestCommon.py')
-rw-r--r--QMTest/TestCommon.py57
1 files changed, 28 insertions, 29 deletions
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)