diff options
-rw-r--r-- | ipalib/base.py | 16 | ||||
-rw-r--r-- | ipalib/errors.py (renamed from ipalib/exceptions.py) | 4 | ||||
-rw-r--r-- | ipalib/plugable.py | 10 | ||||
-rw-r--r-- | ipalib/tests/test_base.py | 10 | ||||
-rw-r--r-- | ipalib/tests/test_plugable.py | 10 |
5 files changed, 25 insertions, 25 deletions
diff --git a/ipalib/base.py b/ipalib/base.py index 63bb940b0..ae9dfae49 100644 --- a/ipalib/base.py +++ b/ipalib/base.py @@ -23,7 +23,7 @@ Base classes for plug-in architecture and generative API. import re import inspect -import exceptions +import errors class NameSpace(object): @@ -45,7 +45,7 @@ class NameSpace(object): For example, setting an attribute the normal way will raise an exception: >>> ns.my_message = 'some new value' - (raises exceptions.SetError) + (raises errors.SetError) But a programmer could still set the attribute like this: @@ -82,7 +82,7 @@ class NameSpace(object): NameSpace has been locked; otherwise calls object.__setattr__(). """ if self.__locked: - raise exceptions.SetError(name) + raise errors.SetError(name) super(NameSpace, self).__setattr__(name, value) def __getitem__(self, key): @@ -190,7 +190,7 @@ class Attribute(Named): return self.__obj def __set_obj(self, obj): if self.__obj is not None: - raise exceptions.TwiceSetError(self.__class__.__name__, 'obj') + raise errors.TwiceSetError(self.__class__.__name__, 'obj') assert isinstance(obj, Object) self.__obj = obj assert self.obj is obj @@ -227,7 +227,7 @@ class Object(Named): return self.__methods def __set_methods(self, methods): if self.__methods is not None: - raise exceptions.TwiceSetError( + raise errors.TwiceSetError( self.__class__.__name__, 'methods' ) assert type(methods) is NameSpace @@ -239,7 +239,7 @@ class Object(Named): return self.__properties def __set_properties(self, properties): if self.__properties is not None: - raise exceptions.TwiceSetError( + raise errors.TwiceSetError( self.__class__.__name__, 'properties' ) assert type(properties) is NameSpace @@ -338,11 +338,11 @@ class Registrar(object): def __findbase(self, cls): if not inspect.isclass(cls): - raise exceptions.RegistrationError('not a class', cls) + raise errors.RegistrationError('not a class', cls) for base in self.__allowed: if issubclass(cls, base): return base - raise exceptions.RegistrationError( + raise errors.RegistrationError( 'not subclass of an allowed base', cls, ) diff --git a/ipalib/exceptions.py b/ipalib/errors.py index 376a7a567..53a0870e6 100644 --- a/ipalib/exceptions.py +++ b/ipalib/errors.py @@ -18,12 +18,12 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -All custom exceptions raised by `ipalib` package. +All custom errors raised by `ipalib` package. """ class IPAError(Exception): """ - Use this base class for your custom IPA exceptions unless there is a + Use this base class for your custom IPA errors unless there is a specific reason to subclass from AttributeError, KeyError, etc. """ msg = None diff --git a/ipalib/plugable.py b/ipalib/plugable.py index ba2241b99..0de31d820 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -22,7 +22,7 @@ Utility classes for registering plugins, base classe for writing plugins. """ import inspect -import exceptions +import errors @@ -50,7 +50,7 @@ class Registrar(object): for base in self.__allowed: if issubclass(cls, base): return base - raise exceptions.SubclassError(cls, self.__allowed) + raise errors.SubclassError(cls, self.__allowed) def __call__(self, cls, override=False): """ @@ -65,17 +65,17 @@ class Registrar(object): # Raise DuplicateError if this exact class was already registered: if cls in self.__registered: - raise exceptions.DuplicateError(cls) + raise errors.DuplicateError(cls) # Check override: if cls.__name__ in sub_d: # Must use override=True to override: if not override: - raise exceptions.OverrideError(base, cls) + raise errors.OverrideError(base, cls) else: # There was nothing already registered to override: if override: - raise exceptions.MissingOverrideError(base, cls) + raise errors.MissingOverrideError(base, cls) # The plugin is okay, add to __registered and sub_d: self.__registered.add(cls) diff --git a/ipalib/tests/test_base.py b/ipalib/tests/test_base.py index 8f6a0313c..da9de7a03 100644 --- a/ipalib/tests/test_base.py +++ b/ipalib/tests/test_base.py @@ -21,7 +21,7 @@ Unit tests for `ipalib.base` module. """ -from ipalib import base, exceptions, crud +from ipalib import base, errors, crud def read_only(obj, name): @@ -129,7 +129,7 @@ class test_NameSpace: raised = False try: setattr(ns, key, value) - except exceptions.SetError: + except errors.SetError: raised = True assert raised assert getattr(ns, key, None) != value @@ -206,7 +206,7 @@ def test_Attribute(): raised = False try: i.obj = u - except exceptions.TwiceSetError: + except errors.TwiceSetError: raised = True assert raised @@ -307,14 +307,14 @@ class test_Registrar(): raised = False try: r(user()) - except exceptions.RegistrationError: + except errors.RegistrationError: raised = True # Check that exception is raised trying to register class of wrong base: raised = False try: r(wrong_base) - except exceptions.RegistrationError: + except errors.RegistrationError: raised = True assert raised diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index 1ba021134..f0bdeb4a0 100644 --- a/ipalib/tests/test_plugable.py +++ b/ipalib/tests/test_plugable.py @@ -21,7 +21,7 @@ Unit tests for `ipalib.plugable` module. """ -from ipalib import plugable, exceptions +from ipalib import plugable, errors def test_Registrar(): @@ -56,7 +56,7 @@ def test_Registrar(): raised = False try: r(plugin3) - except exceptions.SubclassError: + except errors.SubclassError: raised = True assert raised @@ -74,7 +74,7 @@ def test_Registrar(): raised = False try: r(plugin1) - except exceptions.DuplicateError: + except errors.DuplicateError: raised = True assert raised @@ -88,7 +88,7 @@ def test_Registrar(): raised = False try: r(plugin1) - except exceptions.OverrideError: + except errors.OverrideError: raised = True assert raised @@ -104,7 +104,7 @@ def test_Registrar(): raised = False try: r(plugin2, override=True) - except exceptions.MissingOverrideError: + except errors.MissingOverrideError: raised = True assert raised |