diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-08 22:13:49 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-08 22:13:49 +0000 |
commit | 6f144fbaf062d9644af06fdd11020e3d5d349639 (patch) | |
tree | a1fc5133225dd4cb6983d04a8250be3a5aced250 /ipalib/tests/tstutil.py | |
parent | 1744723d11b2fbc93f43699f79df40d5d0b9305d (diff) | |
download | freeipa.git-6f144fbaf062d9644af06fdd11020e3d5d349639.tar.gz freeipa.git-6f144fbaf062d9644af06fdd11020e3d5d349639.tar.xz freeipa.git-6f144fbaf062d9644af06fdd11020e3d5d349639.zip |
89: Moved ClassChecker from test_public.py into tstutil.py; improved unit tests for plugable.ReadOnly
Diffstat (limited to 'ipalib/tests/tstutil.py')
-rw-r--r-- | ipalib/tests/tstutil.py | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/ipalib/tests/tstutil.py b/ipalib/tests/tstutil.py index 63c75665..7b3a2d5e 100644 --- a/ipalib/tests/tstutil.py +++ b/ipalib/tests/tstutil.py @@ -21,6 +21,8 @@ Utility functions for the unit tests. """ +import inspect + class ExceptionNotRaised(Exception): """ Exception raised when an *expected* exception is *not* raised during a @@ -91,9 +93,25 @@ def is_prop(prop): class ClassChecker(object): - - def new(self, *args, **kw): - return self.cls(*args, **kw) - - def get_sub(self): - raise NotImplementedError('get_sub()') + __cls = None + __subcls = None + + def __get_cls(self): + if self.__cls is None: + self.__cls = self._cls + assert inspect.isclass(self.__cls) + return self.__cls + cls = property(__get_cls) + + def __get_subcls(self): + if self.__subcls is None: + self.__subcls = self.get_subcls() + assert inspect.isclass(self.__subcls) + return self.__subcls + subcls = property(__get_subcls) + + def get_subcls(self): + raise NotImplementedError( + self.__class__.__name__, + 'get_subcls()' + ) |