fixes https://fedorahosted.org/freeipa/ticket/5368

--
Martin^3 Babinsky
From a13e6204f3941efb2138bf7a4767b4115d99dbce Mon Sep 17 00:00:00 2001
From: Martin Babinsky <mbabi...@redhat.com>
Date: Wed, 14 Oct 2015 08:59:08 +0200
Subject: [PATCH] fix class teardown in user plugin tests

https://fedorahosted.org/freeipa/ticket/5368
---
 ipatests/test_xmlrpc/test_user_plugin.py |  5 +++++
 ipatests/test_xmlrpc/xmlrpc_test.py      | 11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index 18305ad02906a63baafcdf49bd2c93fa39dc4584..3d7b5e6ba14e3ccb144575f52e4e503e6638037d 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -1619,6 +1619,11 @@ class test_denied_bind_with_expired_principal(XMLRPC_test):
         cls.connection = ldap.initialize('ldap://{host}'
                                          .format(host=api.env.host))
 
+    @classmethod
+    def teardown_class(cls):
+        cls.failsafe_del(api.Object.user, user1)
+        super(test_denied_bind_with_expired_principal, cls).teardown_class()
+
     def test_1_bind_as_test_user(self):
         self.failsafe_add(
             api.Object.user,
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index 80638e2efdd9d7ff07fd89688397acb7d44654cd..a7251f695bf6cd44d0e472234a7120a800ad6543 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -195,11 +195,20 @@ class XMLRPC_test(object):
         :param pk: The primary key of the entry to be created
         :param options: Kwargs to be passed to obj.add()
         """
+        self.failsafe_del(obj, pk)
+        return obj.methods['add'](pk, **options)
+
+    @classmethod
+    def failsafe_del(cls, obj, pk):
+        """
+        Delete an entry if it exists
+        :param obj: An Object like api.Object.user
+        :param pk: The primary key of the entry to be deleted
+        """
         try:
             obj.methods['del'](pk)
         except errors.NotFound:
             pass
-        return obj.methods['add'](pk, **options)
 
 
 IGNORE = """Command %r is missing attribute %r in output entry.
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to