diff options
author | Steven Knight <knight@baldmt.com> | 2004-08-31 02:16:18 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-08-31 02:16:18 (GMT) |
commit | 6ea37f7bb442c511270e5a89cd8fbf801c81e8c2 (patch) | |
tree | 93a794ffac5d3eb42d53830cd730211437e4a965 | |
parent | c0c32fb930d47c02fcdceea5d1759a35c4a92025 (diff) | |
download | SCons-6ea37f7bb442c511270e5a89cd8fbf801c81e8c2.zip SCons-6ea37f7bb442c511270e5a89cd8fbf801c81e8c2.tar.gz SCons-6ea37f7bb442c511270e5a89cd8fbf801c81e8c2.tar.bz2 |
Fix comparisons between Action and subclass instances. (Kevin Quick)
-rw-r--r-- | src/engine/SCons/Action.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/ActionTests.py | 32 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 8306791..69ba78c 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -474,7 +474,7 @@ class LazyCmdGenerator: return '' def __cmp__(self, other): - return cmp(self.__dict__, other.__dict__) + return cmp(self.__dict__, other) class FunctionAction(ActionBase): """Class for Python function actions.""" diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 4c1649c..be0b418 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -1521,6 +1521,35 @@ class ActionFactoryTestCase(unittest.TestCase): assert strfunc_args == [3, 6, 9], strfunc_args +class ActionCompareTestCase(unittest.TestCase): + + def test_1_solo_name(self): + """Test Lazy Cmd Generator Action get_name alone. + + Basically ensures we can locate the builder, comparing it to + itself along the way.""" + bar = SCons.Builder.Builder(action = {}) + env = Environment( BUILDERS = {'BAR' : bar} ) + name = bar.get_name(env) + assert name == 'BAR', name + + def test_2_multi_name(self): + """Test LazyCmdGenerator Action get_name multi builders. + + Ensure that we can compare builders (and thereby actions) to + each other safely.""" + foo = SCons.Builder.Builder(action = '$FOO', suffix = '.foo') + bar = SCons.Builder.Builder(action = {}) + assert foo != bar + assert foo.action != bar.action + env = Environment( BUILDERS = {'FOO' : foo, + 'BAR' : bar} ) + name = foo.get_name(env) + assert name == 'FOO', name + name = bar.get_name(env) + assert name == 'BAR', name + + if __name__ == "__main__": suite = unittest.TestSuite() tclasses = [ ActionTestCase, @@ -1531,7 +1560,8 @@ if __name__ == "__main__": ListActionTestCase, LazyActionTestCase, ActionCallerTestCase, - ActionFactoryTestCase ] + ActionFactoryTestCase, + ActionCompareTestCase ] for tclass in tclasses: names = unittest.getTestCaseNames(tclass, 'test_') suite.addTests(map(tclass, names)) |