summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2014-10-10 09:39:00 +0200
committerTomas Babej <tbabej@redhat.com>2014-11-21 12:14:44 +0100
commit07def0b275ea5ff0f7db7627189f3494588e7046 (patch)
tree642ea9f42f12bf93a411301972233c9e50906f90 /ipatests
parentdca259afc64647326af16d0dbe0e4c08993d90fb (diff)
downloadfreeipa-07def0b275ea5ff0f7db7627189f3494588e7046.tar.gz
freeipa-07def0b275ea5ff0f7db7627189f3494588e7046.tar.xz
freeipa-07def0b275ea5ff0f7db7627189f3494588e7046.zip
Declarative tests: Move cleanup to setup_class/teardown_class
https://fedorahosted.org/freeipa/ticket/4610 Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/test_xmlrpc/xmlrpc_test.py35
1 files changed, 16 insertions, 19 deletions
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index 1f44f7794..ee6d55e17 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -252,23 +252,30 @@ class Declarative(XMLRPC_test):
cleanup_commands = tuple()
tests = tuple()
- def cleanup_generate(self, stage):
- for (i, command) in enumerate(self.cleanup_commands):
- func = lambda: self.cleanup(command)
- func.description = '%s %s-cleanup[%d]: %r' % (
- self.__class__.__name__, stage, i, command
- )
- yield (func,)
+ @classmethod
+ def setup_class(cls):
+ super(Declarative, cls).setup_class()
+ for command in cls.cleanup_commands:
+ cls.cleanup(command)
- def cleanup(self, command):
+ @classmethod
+ def teardown_class(cls):
+ for command in cls.cleanup_commands:
+ cls.cleanup(command)
+ super(Declarative, cls).teardown_class()
+
+ @classmethod
+ def cleanup(cls, command):
(cmd, args, options) = command
+ print 'Cleanup:', cmd, args, options
if cmd not in api.Command:
raise nose.SkipTest(
'cleanup command %r not in api.Command' % cmd
)
try:
api.Command[cmd](*args, **options)
- except (errors.NotFound, errors.EmptyModlist):
+ except (errors.NotFound, errors.EmptyModlist) as e:
+ print e
pass
def test_generator(self):
@@ -277,12 +284,6 @@ class Declarative(XMLRPC_test):
nose reports each one as a seperate test.
"""
-
- # Iterate through pre-cleanup:
- for tup in self.cleanup_generate('pre'):
- yield tup
-
- # Iterate through the tests:
name = self.__class__.__name__
for (i, test) in enumerate(self.tests):
if callable(test):
@@ -299,10 +300,6 @@ class Declarative(XMLRPC_test):
func.description = nice
yield (func,)
- # Iterate through post-cleanup:
- for tup in self.cleanup_generate('post'):
- yield tup
-
def check(self, nice, desc, command, expected, extra_check=None):
(cmd, args, options) = command
options.setdefault('version', self.default_version)