From: stevenknight Date: Tue, 31 Aug 2004 02:16:18 +0000 (+0000) Subject: Fix comparisons between Action and subclass instances. (Kevin Quick) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=befaa86167e9f7f4369a4eea91ca39260d2e6f2d;p=scons.git Fix comparisons between Action and subclass instances. (Kevin Quick) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1051 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 83067910..69ba78c1 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 4c1649c7..be0b418f 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))