diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-03-13 00:53:05 -0600 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-03-13 10:31:00 -0400 |
commit | 13ff27e9ecd06cf893abf12f40051e54639be47d (patch) | |
tree | 7bb11a04aafb41362f14869882c7b4af7d77b103 | |
parent | 588c90d8e604c08604840bd3f41d2a5226154fbe (diff) | |
download | freeipa-13ff27e9ecd06cf893abf12f40051e54639be47d.tar.gz freeipa-13ff27e9ecd06cf893abf12f40051e54639be47d.tar.xz freeipa-13ff27e9ecd06cf893abf12f40051e54639be47d.zip |
Fixed Executioner.execute() so that its 'name' argument doesn't conflict with a param called 'name' (which is a valid param name)
-rw-r--r-- | ipalib/backend.py | 8 | ||||
-rw-r--r-- | tests/test_ipalib/test_backend.py | 14 |
2 files changed, 18 insertions, 4 deletions
diff --git a/ipalib/backend.py b/ipalib/backend.py index 22aa128b3..1902929aa 100644 --- a/ipalib/backend.py +++ b/ipalib/backend.py @@ -102,12 +102,12 @@ class Executioner(Backend): else: self.Backend.xmlclient.connect() - def execute(self, name, *args, **options): + def execute(self, _name, *args, **options): error = None try: - if name not in self.Command: - raise CommandError(name=name) - result = self.Command[name](*args, **options) + if _name not in self.Command: + raise CommandError(name=_name) + result = self.Command[_name](*args, **options) except PublicError, e: error = e except StandardError, e: diff --git a/tests/test_ipalib/test_backend.py b/tests/test_ipalib/test_backend.py index 30928532b..798e93de8 100644 --- a/tests/test_ipalib/test_backend.py +++ b/tests/test_ipalib/test_backend.py @@ -192,6 +192,15 @@ class test_Executioner(ClassChecker): raise ValueError('This is private.') api.register(bad) + class with_name(Command): + """ + Test that a kwarg named 'name' can be used. + """ + takes_options=['name'] + def execute(self, **options): + return options['name'].upper() + api.register(with_name) + api.finalize() o = self.cls() o.set_api(api) @@ -238,3 +247,8 @@ class test_Executioner(ClassChecker): e = raises(errors2.InternalError, o.execute, 'bad') assert conn.disconnect.called is True # Make sure destroy_context() was called assert context.__dict__.keys() == [] + + # Test with option 'name': + conn = Connection('The connection.', Disconnect()) + context.someconn = conn + assert o.execute('with_name', name=u'test') == u'TEST' |