summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/ActionTests.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 /src/engine/SCons/ActionTests.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 'src/engine/SCons/ActionTests.py')
-rw-r--r--src/engine/SCons/ActionTests.py50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index ef91af4..12756e5 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -37,7 +37,6 @@ class GlobalActFunc:
import os
import re
import StringIO
-import string
import sys
import types
import unittest
@@ -68,16 +67,16 @@ try:
except:
pass
f.close()
-if os.environ.has_key( 'ACTPY_PIPE' ):
- if os.environ.has_key( 'PIPE_STDOUT_FILE' ):
+if 'ACTPY_PIPE' in os.environ:
+ if 'PIPE_STDOUT_FILE' in os.environ:
stdout_msg = open(os.environ['PIPE_STDOUT_FILE'], 'r').read()
else:
- stdout_msg = "act.py: stdout: executed act.py %s\\n" % string.join(sys.argv[1:])
+ stdout_msg = "act.py: stdout: executed act.py %s\\n" % ' '.join(sys.argv[1:])
sys.stdout.write( stdout_msg )
- if os.environ.has_key( 'PIPE_STDERR_FILE' ):
+ if 'PIPE_STDERR_FILE' in os.environ:
stderr_msg = open(os.environ['PIPE_STDERR_FILE'], 'r').read()
else:
- stderr_msg = "act.py: stderr: executed act.py %s\\n" % string.join(sys.argv[1:])
+ stderr_msg = "act.py: stderr: executed act.py %s\\n" % ' '.join(sys.argv[1:])
sys.stderr.write( stderr_msg )
sys.exit(0)
""")
@@ -147,7 +146,7 @@ class Environment:
def __setitem__(self, item, value):
self.d[item] = value
def has_key(self, item):
- return self.d.has_key(item)
+ return item in self.d
def get(self, key, value=None):
return self.d.get(key, value)
def items(self):
@@ -193,7 +192,7 @@ _null = SCons.Action._null
def test_varlist(pos_call, str_call, cmd, cmdstrfunc, **kw):
def call_action(a, pos_call=pos_call, str_call=str_call, kw=kw):
#FUTURE a = SCons.Action.Action(*a, **kw)
- a = apply(SCons.Action.Action, a, kw)
+ a = SCons.Action.Action(*a, **kw)
# returned object must provide these entry points
assert hasattr(a, '__call__')
assert hasattr(a, 'get_contents')
@@ -229,7 +228,7 @@ def test_positional_args(pos_callback, cmd, **kw):
"""Test that Action() returns the expected type and that positional args work.
"""
#FUTURE act = SCons.Action.Action(cmd, **kw)
- act = apply(SCons.Action.Action, (cmd,), kw)
+ act = SCons.Action.Action(cmd, **kw)
pos_callback(act)
assert act.varlist is (), act.varlist
@@ -237,7 +236,7 @@ def test_positional_args(pos_callback, cmd, **kw):
# only valid cmdstrfunc is None
def none(a): pass
#FUTURE test_varlist(pos_callback, none, cmd, None, **kw)
- apply(test_varlist, (pos_callback, none, cmd, None), kw)
+ test_varlist(pos_callback, none, cmd, None, **kw)
else:
# _ActionAction should have set these
assert hasattr(act, 'strfunction')
@@ -251,29 +250,29 @@ def test_positional_args(pos_callback, cmd, **kw):
assert hasattr(a, 'strfunction')
assert a.cmdstr == 'cmdstr', a.cmdstr
#FUTURE test_varlist(pos_callback, cmdstr, cmd, 'cmdstr', **kw)
- apply(test_varlist, (pos_callback, cmdstr, cmd, 'cmdstr'), kw)
+ test_varlist(pos_callback, cmdstr, cmd, 'cmdstr', **kw)
def fun(): pass
def strfun(a, fun=fun):
assert a.strfunction is fun, a.strfunction
assert a.cmdstr == _null, a.cmdstr
#FUTURE test_varlist(pos_callback, strfun, cmd, fun, **kw)
- apply(test_varlist, (pos_callback, strfun, cmd, fun), kw)
+ test_varlist(pos_callback, strfun, cmd, fun, **kw)
def none(a):
assert hasattr(a, 'strfunction')
assert a.cmdstr is None, a.cmdstr
#FUTURE test_varlist(pos_callback, none, cmd, None, **kw)
- apply(test_varlist, (pos_callback, none, cmd, None), kw)
+ test_varlist(pos_callback, none, cmd, None, **kw)
"""Test handling of bad cmdstrfunc arguments """
try:
#FUTURE a = SCons.Action.Action(cmd, [], **kw)
- a = apply(SCons.Action.Action, (cmd, []), kw)
+ a = SCons.Action.Action(cmd, [], **kw)
except SCons.Errors.UserError, e:
s = str(e)
m = 'Invalid command display variable'
- assert string.find(s, m) != -1, 'Unexpected string: %s' % s
+ assert s.find(m) != -1, 'Unexpected string: %s' % s
else:
raise Exception, "did not catch expected UserError"
@@ -490,7 +489,7 @@ class _ActionActionTestCase(unittest.TestCase):
except SCons.Errors.UserError, e:
s = str(e)
m = 'Cannot have both strfunction and cmdstr args to Action()'
- assert string.find(s, m) != -1, 'Unexpected string: %s' % s
+ assert s.find(m) != -1, 'Unexpected string: %s' % s
else:
raise Exception, "did not catch expected UserError"
@@ -752,8 +751,7 @@ class _ActionActionTestCase(unittest.TestCase):
sum = act1 + act2
assert isinstance(sum, SCons.Action.ListAction), str(sum)
assert len(sum.list) == 3, len(sum.list)
- assert map(lambda x: isinstance(x, SCons.Action.ActionBase),
- sum.list) == [ 1, 1, 1 ]
+ assert [isinstance(x, SCons.Action.ActionBase) for x in sum.list] == [ 1, 1, 1 ]
sum = act1 + act1
assert isinstance(sum, SCons.Action.ListAction), str(sum)
@@ -1050,7 +1048,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd3 = r'%s %s %s ${TARGETS}' % (_python_, act_py, outfile)
act = SCons.Action.CommandAction(cmd3)
- r = act(map(DummyNode, ['aaa', 'bbb']), [], env.Clone())
+ r = act(list(map(DummyNode, ['aaa', 'bbb'])), [], env.Clone())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'aaa' 'bbb'\n", c
@@ -1077,7 +1075,7 @@ class CommandActionTestCase(unittest.TestCase):
act = SCons.Action.CommandAction(cmd5)
env5 = Environment()
- if scons_env.has_key('ENV'):
+ if 'ENV' in scons_env:
env5['ENV'] = scons_env['ENV']
PATH = scons_env['ENV'].get('PATH', '')
else:
@@ -1332,8 +1330,8 @@ class CommandActionTestCase(unittest.TestCase):
# that scheme, then all of the '__t1__' and '__s6__' file names
# in the asserts below would change to 't1' and 's6' and the
# like.
- t = map(DummyNode, ['t1', 't2', 't3', 't4', 't5', 't6'])
- s = map(DummyNode, ['s1', 's2', 's3', 's4', 's5', 's6'])
+ t = list(map(DummyNode, ['t1', 't2', 't3', 't4', 't5', 't6']))
+ s = list(map(DummyNode, ['s1', 's2', 's3', 's4', 's5', 's6']))
env = Environment()
a = SCons.Action.CommandAction(["$TARGET"])
@@ -1528,7 +1526,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase):
def f_local(target, source, env, for_signature, LocalFunc=LocalFunc):
return SCons.Action.Action(LocalFunc, varlist=['XYZ'])
- matches_foo = map(lambda x: x + "foo", func_matches)
+ matches_foo = [x + "foo" for x in func_matches]
a = self.factory(f_global)
c = a.get_contents(target=[], source=[], env=env)
@@ -1676,7 +1674,7 @@ class FunctionActionTestCase(unittest.TestCase):
c = a.get_contents(target=[], source=[], env=Environment())
assert c in func_matches, repr(c)
- matches_foo = map(lambda x: x + "foo", func_matches)
+ matches_foo = [x + "foo" for x in func_matches]
a = factory(GlobalFunc, varlist=['XYZ'])
c = a.get_contents(target=[], source=[], env=Environment())
@@ -1892,7 +1890,7 @@ class LazyActionTestCase(unittest.TestCase):
c = a.get_contents(target=[], source=[], env=env)
assert c in func_matches, repr(c)
- matches_foo = map(lambda x: x + "foo", func_matches)
+ matches_foo = [x + "foo" for x in func_matches]
env = Environment(FOO = factory(GlobalFunc, varlist=['XYZ']))
c = a.get_contents(target=[], source=[], env=env)
@@ -2096,7 +2094,7 @@ if __name__ == "__main__":
ActionCompareTestCase ]
for tclass in tclasses:
names = unittest.getTestCaseNames(tclass, 'test_')
- suite.addTests(map(tclass, names))
+ suite.addTests(list(map(tclass, names)))
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)