This makes all tests except
- integration
- xmlrpc
- doctest
to be runnable under py.test.
The last patch does touch Declarative, but keeps compatibility with Nose.

How to test:
- have a ticket
- do NOT have integration tests configured (using $MASTER or $IPATEST_*_CONFIG)
# yum install pytest
$ IPA_UNIT_TEST_MODE=cli_test py.test

(note: the command is `py.test`, for historical reasons in the pytest project)

--
PetrĀ³
From 3ed569a74fb9006b0503e71ec7fbdb92745dcb1c Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Tue, 7 Oct 2014 12:48:22 +0200
Subject: [PATCH] tests: Use PEP8-compliant setup/teardown method names

The setUp/dearDown names are used in the unittest module, but there is no reason
to use them in non-`unittest` test cases.
Nose supports both styles (but mixing them can cause trouble when
calling super()'s methods).
Pytest only supports the new ones.
---
 ipatests/test_cmdline/cmdline.py                         |  8 ++++----
 ipatests/test_integration/test_caless.py                 | 12 +++++-------
 .../test_integration/test_forced_client_reenrollment.py  |  4 ++--
 ipatests/test_ipalib/test_rpc.py                         |  4 ++--
 ipatests/test_ipalib/test_text.py                        |  4 ++--
 ipatests/test_ipapython/test_ipavalidate.py              |  6 ------
 ipatests/test_ipapython/test_keyring.py                  |  2 +-
 ipatests/test_ipaserver/test_changepw.py                 |  8 ++++----
 ipatests/test_ipaserver/test_ldap.py                     |  8 ++++----
 ipatests/test_pkcs10/test_pkcs10.py                      |  2 +-
 ipatests/test_webui/ui_driver.py                         |  6 +++---
 ipatests/test_xmlrpc/test_cert_plugin.py                 | 16 ++++++++--------
 ipatests/test_xmlrpc/test_dns_plugin.py                  |  8 ++++----
 ipatests/test_xmlrpc/test_external_members.py            |  4 ++--
 ipatests/test_xmlrpc/test_host_plugin.py                 |  2 +-
 ipatests/test_xmlrpc/test_permission_plugin.py           |  4 ++--
 ipatests/test_xmlrpc/test_range_plugin.py                |  8 ++++----
 ipatests/test_xmlrpc/test_trust_plugin.py                |  4 ++--
 ipatests/test_xmlrpc/test_user_plugin.py                 |  4 ++--
 ipatests/test_xmlrpc/xmlrpc_test.py                      |  6 +++---
 ipatests/util.py                                         |  4 ++--
 21 files changed, 58 insertions(+), 66 deletions(-)

diff --git a/ipatests/test_cmdline/cmdline.py b/ipatests/test_cmdline/cmdline.py
index e790f022ebea8a29123cb41b5f215675fccaa647..bcb71328adce37e0e7bf748f018bb5773d5cc497 100644
--- a/ipatests/test_cmdline/cmdline.py
+++ b/ipatests/test_cmdline/cmdline.py
@@ -52,7 +52,7 @@ class cmdline_test(XMLRPC_test):
     # some reasonable default command
     command = paths.LS
 
-    def setUp(self):
+    def setup(self):
         # Find the executable in $PATH
         # This is neded because ipautil.run resets the PATH to
         # a system default.
@@ -65,14 +65,14 @@ def setUp(self):
             raise AssertionError(
                 'Command %r not available' % original_command
             )
-        super(cmdline_test, self).setUp()
+        super(cmdline_test, self).setup()
         if not server_available:
             raise nose.SkipTest(
                 'Server not available: %r' % api.env.xmlrpc_uri
             )
 
-    def tearDown(self):
+    def teardown(self):
         """
         nose tear-down fixture.
         """
-        super(cmdline_test, self).tearDown()
+        super(cmdline_test, self).teardown()
diff --git a/ipatests/test_integration/test_caless.py b/ipatests/test_integration/test_caless.py
index 1bd8202c8c375e67df0cbc401c4b4724465f2996..d2b74b33228d9e42246b306fe616613c9eecc4dd 100644
--- a/ipatests/test_integration/test_caless.py
+++ b/ipatests/test_integration/test_caless.py
@@ -340,7 +340,7 @@ def verify_installation(self):
 class TestServerInstall(CALessBase):
     num_replicas = 0
 
-    def tearDown(self):
+    def teardown(self):
         self.uninstall_server()
 
         # Remove CA cert in /etc/pki/nssdb, in case of failed (un)install
@@ -750,7 +748,7 @@ def test_no_ds_password(self):
 class TestReplicaInstall(CALessBase):
     num_replicas = 1
 
-    def setUp(self):
+    def setup(self):
         # Install the master for every test
         self.export_pkcs12('ca1/server')
         with open(self.pem_filename, 'w') as f:
@@ -759,7 +757,7 @@ def setUp(self):
         result = self.install_server()
         assert result.returncode == 0
 
-    def tearDown(self):
+    def teardown(self):
         # Uninstall both master and replica
         replica = self.replicas[0]
         tasks.kinit_admin(self.master)
diff --git a/ipatests/test_integration/test_forced_client_reenrollment.py b/ipatests/test_integration/test_forced_client_reenrollment.py
index b1165218714b994d835bb63f37dc6f921627b168..826e70d24b71d3fefc2cb305dd9eb7cb6ddb0c30 100644
--- a/ipatests/test_integration/test_forced_client_reenrollment.py
+++ b/ipatests/test_integration/test_forced_client_reenrollment.py
@@ -44,11 +44,11 @@ def install(cls):
             'krb5.keytab'
         )
 
-    def setUp(self):
+    def setup(self):
         tasks.prepare_host(self.clients[0])
         tasks.install_client(self.master, self.clients[0])
 
-    def tearDown(self):
+    def teardown(self):
         tasks.uninstall_client(self.clients[0])
         self.delete_client_host_entry()
 
diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py
index 64e5f5e33d8767233ce9c36093fc209aeed783ad..74a7639c9eef27c93771bdbd235d03291423806e 100644
--- a/ipatests/test_ipalib/test_rpc.py
+++ b/ipatests/test_ipalib/test_rpc.py
@@ -248,7 +248,7 @@ class user_add(Command):
 
 class test_xml_introspection(object):
     @classmethod
-    def setUpClass(self):
+    def setup_class(self):
         try:
             api.Backend.xmlclient.connect(fallback=False)
         except (errors.NetworkError, IOError):
@@ -256,7 +256,7 @@ def setUpClass(self):
                                 (__name__, api.env.xmlrpc_uri))
 
     @classmethod
-    def tearDownClass(self):
+    def teardown_class(self):
         request.destroy_context()
 
     def test_list_methods(self):
diff --git a/ipatests/test_ipalib/test_text.py b/ipatests/test_ipalib/test_text.py
index 4d4ce35c89ee3c70f58464b69730236ce7fb90cf..c1140d2176205e32064bcc618443bc5046e2ed04 100644
--- a/ipatests/test_ipalib/test_text.py
+++ b/ipatests/test_ipalib/test_text.py
@@ -46,7 +46,7 @@ def test_create_translation():
 
 
 class test_TestLang(object):
-    def setUp(self):
+    def setup(self):
         self.tmp_dir = None
         self.saved_lang  = None
 
@@ -85,7 +85,7 @@ def setUp(self):
 
         self.po_file_iterate = po_file_iterate
 
-    def tearDown(self):
+    def teardown(self):
         if self.saved_lang is not None:
             os.environ['LANG'] = self.saved_lang
 
diff --git a/ipatests/test_ipapython/test_ipavalidate.py b/ipatests/test_ipapython/test_ipavalidate.py
index 3393de00ed194b2ee4658703fc9647d1ad5266e6..b912797dd09628d5bc1c02913e966f5d82f2c046 100644
--- a/ipatests/test_ipapython/test_ipavalidate.py
+++ b/ipatests/test_ipapython/test_ipavalidate.py
@@ -25,12 +25,6 @@
 from ipapython import ipavalidate
 
 class TestValidate(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
     def test_validEmail(self):
         self.assertEqual(True, ipavalidate.Email("t...@freeipa.org"))
         self.assertEqual(True, ipavalidate.Email("", notEmpty=False))
diff --git a/ipatests/test_ipapython/test_keyring.py b/ipatests/test_ipapython/test_keyring.py
index 568fd5ee1b507dfc5ff2ff344f473c6b28763373..e92b1b465bada98e7fdf325b09d51fe680b6e362 100644
--- a/ipatests/test_ipapython/test_keyring.py
+++ b/ipatests/test_ipapython/test_keyring.py
@@ -36,7 +36,7 @@ class test_keyring(object):
     Test the kernel keyring interface
     """
 
-    def setUp(self):
+    def setup(self):
         try:
             kernel_keyring.del_key(TEST_KEY)
         except ValueError:
diff --git a/ipatests/test_ipaserver/test_changepw.py b/ipatests/test_ipaserver/test_changepw.py
index 040c9cd36e8b922d37034db421435ed5853310e0..65bf5a023a4d84f4db3c725bebc7499e6065d7f0 100644
--- a/ipatests/test_ipaserver/test_changepw.py
+++ b/ipatests/test_ipaserver/test_changepw.py
@@ -33,8 +33,8 @@
 class test_changepw(XMLRPC_test, Unauthorized_HTTP_test):
     app_uri = '/ipa/session/change_password'
 
-    def setUp(self):
-        super(test_changepw, self).setUp()
+    def setup(self):
+        super(test_changepw, self).setup()
         try:
             api.Command['user_add'](uid=testuser, givenname=u'Test', sn=u'User')
             api.Command['passwd'](testuser, password=u'old_password')
@@ -43,12 +43,12 @@ def setUp(self):
                 'Cannot set up test user: %s' % e
             )
 
-    def tearDown(self):
+    def teardown(self):
         try:
             api.Command['user_del']([testuser])
         except errors.NotFound:
             pass
-        super(test_changepw, self).tearDown()
+        super(test_changepw, self).teardown()
 
     def _changepw(self, user, old_password, new_password):
         return self.send_request(params={'user': str(user),
diff --git a/ipatests/test_ipaserver/test_ldap.py b/ipatests/test_ipaserver/test_ldap.py
index 46182dbea4d2d18d448f97b1607d33b5a50d1cf9..8b4e5005864249c8742a60de382e570bd4024345 100644
--- a/ipatests/test_ipaserver/test_ldap.py
+++ b/ipatests/test_ipaserver/test_ldap.py
@@ -44,7 +44,7 @@ class test_ldap(object):
     Test various LDAP client bind methods.
     """
 
-    def setUp(self):
+    def setup(self):
         self.conn = None
         self.ldapuri = 'ldap://%s' % ipautil.format_netloc(api.env.host)
         self.ccache = paths.TMP_KRB5CC % os.getuid()
@@ -52,7 +52,7 @@ def setUp(self):
         self.dn = DN(('krbprincipalname','ldap/%s@%s' % (api.env.host, api.env.realm)),
                      ('cn','services'),('cn','accounts'),api.env.basedn)
 
-    def tearDown(self):
+    def teardown(self):
         if self.conn and self.conn.isconnected():
             self.conn.disconnect()
 
@@ -158,14 +158,14 @@ class test_LDAPEntry(object):
     dn1 = DN(('cn', cn1[0]))
     dn2 = DN(('cn', cn2[0]))
 
-    def setUp(self):
+    def setup(self):
         self.ldapuri = 'ldap://%s' % ipautil.format_netloc(api.env.host)
         self.conn = ldap2(shared_instance=False, ldap_uri=self.ldapuri)
         self.conn.connect()
 
         self.entry = self.conn.make_entry(self.dn1, cn=self.cn1)
 
-    def tearDown(self):
+    def teardown(self):
         if self.conn and self.conn.isconnected():
             self.conn.disconnect()
 
diff --git a/ipatests/test_pkcs10/test_pkcs10.py b/ipatests/test_pkcs10/test_pkcs10.py
index c56c8d4741ffeeabed9d2842c02a714553d3f9e9..8a45327d31a0e4c48e6148536a3bfbbbfb0ad9f3 100644
--- a/ipatests/test_pkcs10/test_pkcs10.py
+++ b/ipatests/test_pkcs10/test_pkcs10.py
@@ -34,7 +34,7 @@ class test_update(object):
     Test the PKCS#10 Parser.
     """
 
-    def setUp(self):
+    def setup(self):
         nss.nss_init_nodb()
         if ipautil.file_exists("test0.csr"):
             self.testdir="./"
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index bf78fcb5798f5f17f2d76650da0c0327bb4c6d71..e706a68e0e55024a835e5be3071cccfeee312a1f 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -113,7 +113,7 @@ class UI_driver(object):
     """
 
     @classmethod
-    def setUpClass(cls):
+    def setup_class(cls):
         if NO_SELENIUM:
             raise nose.SkipTest('Selenium not installed')
 
@@ -161,7 +161,7 @@ def load_config(self):
         if 'type' not in c:
             c['type'] = DEFAULT_TYPE
 
-    def setUp(self):
+    def setup(self):
         """
         Test setup
         """
@@ -169,7 +169,7 @@ def setUp(self):
             self.driver = self.get_driver()
             self.driver.maximize_window()
 
-    def tearDown(self):
+    def teardown(self):
         """
         Test clean up
         """
diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py
index af9994430867a02d8672f7334d9b8a23b91192fb..a19032503ef9c63cd337038fcaf8e7c98b5d5f08 100644
--- a/ipatests/test_xmlrpc/test_cert_plugin.py
+++ b/ipatests/test_xmlrpc/test_cert_plugin.py
@@ -70,8 +70,8 @@ def is_db_configured():
 class test_cert(XMLRPC_test):
 
     @classmethod
-    def setUpClass(cls):
-        super(test_cert, cls).setUpClass()
+    def setup_class(cls):
+        super(test_cert, cls).setup_class()
 
         if 'cert_request' not in api.Command:
             raise nose.SkipTest('cert_request not registered')
@@ -83,8 +83,8 @@ def run_certutil(self, args, stdin=None):
         new_args = new_args + args
         return ipautil.run(new_args, stdin)
 
-    def setUp(self):
-        super(test_cert, self).setUp()
+    def setup(self):
+        super(test_cert, self).setup()
         self.reqdir = tempfile.mkdtemp(prefix = "tmp-")
         self.reqfile = self.reqdir + "/test.csr"
         self.pwname = self.reqdir + "/pwd"
@@ -99,8 +99,8 @@ def setUp(self):
 
         self.subject = DN(('CN', self.host_fqdn), x509.subject_base())
 
-    def tearDown(self):
-        super(test_cert, self).tearDown()
+    def teardown(self):
+        super(test_cert, self).teardown()
         shutil.rmtree(self.reqdir, ignore_errors=True)
 
     def generateCSR(self, subject):
@@ -204,8 +204,8 @@ def test_0007_cleanup(self):
 class test_cert_find(XMLRPC_test):
 
     @classmethod
-    def setUpClass(cls):
-        super(test_cert_find, cls).setUpClass()
+    def setup_class(cls):
+        super(test_cert_find, cls).setup_class()
 
         if 'cert_find' not in api.Command:
             raise nose.SkipTest('cert_find not registered')
diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py
index b5df897fcbde509e2fd727c79797fd4e76d6dd61..ab6313280f0f379e358e2588fa1dc356332a60af 100644
--- a/ipatests/test_xmlrpc/test_dns_plugin.py
+++ b/ipatests/test_xmlrpc/test_dns_plugin.py
@@ -334,8 +334,8 @@ def get_nameservers():
 class test_dns(Declarative):
 
     @classmethod
-    def setUpClass(cls):
-        super(test_dns, cls).setUpClass()
+    def setup_class(cls):
+        super(test_dns, cls).setup_class()
 
         if not api.Backend.rpcclient.isconnected():
             api.Backend.rpcclient.connect(fallback=False)
@@ -3697,8 +3697,8 @@ def setUpClass(cls):
 class test_root_zone(Declarative):
 
     @classmethod
-    def setUpClass(cls):
-        super(test_root_zone, cls).setUpClass()
+    def setup_class(cls):
+        super(test_root_zone, cls).setup_class()
 
         if not api.Backend.rpcclient.isconnected():
             api.Backend.rpcclient.connect(fallback=False)
diff --git a/ipatests/test_xmlrpc/test_external_members.py b/ipatests/test_xmlrpc/test_external_members.py
index a2128cb77df707285d089517d2bf05b92cc9533a..83d4d134f23745ef87cddf78c594b003496e95c2 100644
--- a/ipatests/test_xmlrpc/test_external_members.py
+++ b/ipatests/test_xmlrpc/test_external_members.py
@@ -43,8 +43,8 @@ def get_trusted_group_name():
 
 class test_external_members(Declarative):
     @classmethod
-    def setUpClass(cls):
-        super(test_external_members, cls).setUpClass()
+    def setup_class(cls):
+        super(test_external_members, cls).setup_class()
         if not api.Backend.rpcclient.isconnected():
             api.Backend.rpcclient.connect(fallback=False)
 
diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py
index 479afd100e974d1380fc7d940782d4bd5a2f158f..c49899f86735a4531e4bba9e01075d3b34100727 100644
--- a/ipatests/test_xmlrpc/test_host_plugin.py
+++ b/ipatests/test_xmlrpc/test_host_plugin.py
@@ -971,7 +971,7 @@ class test_host_false_pwd_change(XMLRPC_test):
     command = "ipa-client/ipa-join"
 
     @classmethod
-    def setUpClass(cls):
+    def setup_class(cls):
         [cls.keytabfd,cls.keytabname] = tempfile.mkstemp()
         os.close(cls.keytabfd)
 
diff --git a/ipatests/test_xmlrpc/test_permission_plugin.py b/ipatests/test_xmlrpc/test_permission_plugin.py
index f58fa88ca731596a0e60e416d38eacefc273e03a..9946378fb6a28a710cfd4bd6cd728d97bd307197 100644
--- a/ipatests/test_xmlrpc/test_permission_plugin.py
+++ b/ipatests/test_xmlrpc/test_permission_plugin.py
@@ -3164,8 +3164,8 @@ class test_managed_permissions(Declarative):
     ]
 
     @classmethod
-    def setUpClass(cls):
-        super(test_managed_permissions, cls).setUpClass()
+    def setup_class(cls):
+        super(test_managed_permissions, cls).setup_class()
 
         if not have_ldap2:
             raise nose.SkipTest('server plugin not available')
diff --git a/ipatests/test_xmlrpc/test_range_plugin.py b/ipatests/test_xmlrpc/test_range_plugin.py
index 349fb73649650f97c3a9464f7e49bbd44863e869..5271b607d4f535cc6a2b0495002d7d4c46ba34e7 100644
--- a/ipatests/test_xmlrpc/test_range_plugin.py
+++ b/ipatests/test_xmlrpc/test_range_plugin.py
@@ -335,9 +335,9 @@ def get_trusted_dom_dict(name, sid):
 
 class test_range(Declarative):
     @classmethod
-    def setUpClass(cls):
-        super(test_range, cls).setUpClass()
-        cls.tearDownClass()
+    def setup_class(cls):
+        super(test_range, cls).setup_class()
+        cls.teardown_class()
         cls.mockldap = MockLDAP()
         cls.mockldap.add_entry(trust_container_dn, trust_container_add)
 
@@ -358,7 +358,7 @@ def setUpClass(cls):
         cls.mockldap.unbind()
 
     @classmethod
-    def tearDownClass(cls):
+    def teardown_class(cls):
         cls.mockldap = MockLDAP()
 
         cls.mockldap.del_entry(domain2_dn)
diff --git a/ipatests/test_xmlrpc/test_trust_plugin.py b/ipatests/test_xmlrpc/test_trust_plugin.py
index 5260b4061888c605383f277b89cba517de31855c..94e4efc93d1893c3cafefcbfb5ef5439001e4b36 100644
--- a/ipatests/test_xmlrpc/test_trust_plugin.py
+++ b/ipatests/test_xmlrpc/test_trust_plugin.py
@@ -39,8 +39,8 @@
 class test_trustconfig(Declarative):
 
     @classmethod
-    def setUpClass(cls):
-        super(test_trustconfig, cls).setUpClass()
+    def setup_class(cls):
+        super(test_trustconfig, cls).setup_class()
         if not api.Backend.rpcclient.isconnected():
             api.Backend.rpcclient.connect(fallback=False)
         try:
diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
index dfca104ebf39beaf7d42afb6b06c2100981df75e..304a6d99288b1ccc72cddc45e7f4150402975972 100644
--- a/ipatests/test_xmlrpc/test_user_plugin.py
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
@@ -1607,8 +1607,8 @@ class test_denied_bind_with_expired_principal(XMLRPC_test):
     password = u'random'
 
     @classmethod
-    def setUpClass(cls):
-        super(test_denied_bind_with_expired_principal, cls).setUpClass()
+    def setup_class(cls):
+        super(test_denied_bind_with_expired_principal, cls).setup_class()
 
         cls.connection = ldap.initialize('ldap://{host}'
                                          .format(host=api.env.host))
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index f60e30412d1e3cd9281ba7a5581064f7dfe4aae2..2030f1cb2d95e1f012e72009b119249131db7a50 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -168,16 +168,16 @@ class XMLRPC_test(object):
     """
 
     @classmethod
-    def setUpClass(cls):
+    def setup_class(cls):
         if not server_available:
             raise nose.SkipTest('%r: Server not available: %r' %
                                 (cls.__module__, api.env.xmlrpc_uri))
 
-    def setUp(self):
+    def setup(self):
         if not api.Backend.rpcclient.isconnected():
             api.Backend.rpcclient.connect(fallback=False)
 
-    def tearDown(self):
+    def teardown(self):
         """
         nose tear-down fixture.
         """
diff --git a/ipatests/util.py b/ipatests/util.py
index 30fafdc76c3a139d954c6d7a5ad4c05360fe6de6..9d9562c584b3bbba1ec8a0dd199358177721e786 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -448,7 +448,7 @@ def get_subcls(self):
             'get_subcls()'
         )
 
-    def tearDown(self):
+    def teardown(self):
         """
         nose tear-down fixture.
         """
@@ -533,7 +533,7 @@ def instance(self, namespace, *plugins, **kw):
         o = api[namespace][self.plugin.__name__]
         return (o, api, home)
 
-    def tearDown(self):
+    def teardown(self):
         """
         nose tear-down fixture.
         """
-- 
2.1.0

From 8d4359711442f6fa08a807ff792d48c0d03bdf73 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Tue, 7 Oct 2014 16:13:17 +0200
Subject: [PATCH] tests: Add configuration for pytest

By default, pytest considers test classes only if they're named
'Test*'; Nose also allows 'test_*'.
Configure pytest to allow the non-pep8 names as well.
---
 ipatests/pytest.ini | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 ipatests/pytest.ini

diff --git a/ipatests/pytest.ini b/ipatests/pytest.ini
new file mode 100644
index 0000000000000000000000000000000000000000..d2355d9616a2aea000d14fa27c9b35d0ad5fb353
--- /dev/null
+++ b/ipatests/pytest.ini
@@ -0,0 +1,2 @@
+[pytest]
+python_classes = test_ Test
-- 
2.1.0

From b84c08bb0b1c460eb57b6b6e455a6002851050a5 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Tue, 7 Oct 2014 15:22:59 +0200
Subject: [PATCH] ipatests.util.ClassChecker: Raise AttributeError in
 get_subcls

Pytest considers NotImplementedError on attribute access an error.
---
 ipatests/util.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipatests/util.py b/ipatests/util.py
index 9d9562c584b3bbba1ec8a0dd199358177721e786..522952b00a88a1277c2e8f6df1e906addd1f278e 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -443,7 +443,7 @@ def __get_subcls(self):
     subcls = property(__get_subcls)
 
     def get_subcls(self):
-        raise NotImplementedError(
+        raise AttributeError(
             self.__class__.__name__,
             'get_subcls()'
         )
-- 
2.1.0

From 1cd0dd7ef67f4f5c7e1acb578848aca8170ee90d Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Wed, 8 Oct 2014 09:15:20 +0200
Subject: [PATCH] test_automount_plugin: Fix test ordering

Nose ran the `test_a_*` and `test_a2_*` tests in opposite order
than the source suggested. Fix this.
---
 ipatests/test_xmlrpc/test_automount_plugin.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_automount_plugin.py b/ipatests/test_xmlrpc/test_automount_plugin.py
index 759fa8dcc7083404cc4da91279b980001dfd6766..90e32073048bb5fa3bae80a6b3666a8cb767364b 100644
--- a/ipatests/test_xmlrpc/test_automount_plugin.py
+++ b/ipatests/test_xmlrpc/test_automount_plugin.py
@@ -222,7 +222,7 @@ def test_9_automountkey_mod(self):
         assert_attr_equal(res, 'automountinformation', self.newinfo)
         assert_attr_equal(res, 'automountkey', self.keyname_rename)
 
-    def test_a_automountmap_mod(self):
+    def test_a1_automountmap_mod(self):
         """
         Test the `xmlrpc.automountmap_mod` method.
         """
@@ -244,7 +244,7 @@ def test_a2_automountmap_tofiles(self):
                     dn=DN(('automountmapname', self.mapname),
                           ('cn', self.locname),
                           ('cn', 'automount'), api.env.basedn),
-                    description=(u'description of map',),
+                    description=(u'new description',),
                     automountmapname=(u'testmap',)),),
                 orphankeys=[(
                     dict(
-- 
2.1.0

From bcf3856f10052861776d4fb0f70e88e84cd36939 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Wed, 8 Oct 2014 09:42:52 +0200
Subject: [PATCH] Use setup_class/teardown_class in Declarative tests

Pytest will consider each Declarative test individually, running
setup/teardown for each one.
Move the setup and teardown to the class level.
---
 ipatests/test_cmdline/cmdline.py         | 19 +++++++------------
 ipatests/test_ipaserver/test_changepw.py |  6 ++----
 ipatests/test_xmlrpc/test_cert_plugin.py |  2 --
 ipatests/test_xmlrpc/xmlrpc_test.py      |  8 ++------
 4 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/ipatests/test_cmdline/cmdline.py b/ipatests/test_cmdline/cmdline.py
index bcb71328adce37e0e7bf748f018bb5773d5cc497..81d3301b2c41fe53a0dad68f0e439e2c573345db 100644
--- a/ipatests/test_cmdline/cmdline.py
+++ b/ipatests/test_cmdline/cmdline.py
@@ -52,27 +52,22 @@ class cmdline_test(XMLRPC_test):
     # some reasonable default command
     command = paths.LS
 
-    def setup(self):
+    @classmethod
+    def setup_class(cls):
         # Find the executable in $PATH
         # This is neded because ipautil.run resets the PATH to
         # a system default.
-        original_command = self.command
-        if not os.path.isabs(self.command):
-            self.command = distutils.spawn.find_executable(self.command)
+        original_command = cls.command
+        if not os.path.isabs(cls.command):
+            cls.command = distutils.spawn.find_executable(cls.command)
         # raise an error if the command is missing even if the remote
         # server is not available.
-        if not self.command:
+        if not cls.command:
             raise AssertionError(
                 'Command %r not available' % original_command
             )
-        super(cmdline_test, self).setup()
+        super(cmdline_test, cls).setup_class()
         if not server_available:
             raise nose.SkipTest(
                 'Server not available: %r' % api.env.xmlrpc_uri
             )
-
-    def teardown(self):
-        """
-        nose tear-down fixture.
-        """
-        super(cmdline_test, self).teardown()
diff --git a/ipatests/test_ipaserver/test_changepw.py b/ipatests/test_ipaserver/test_changepw.py
index 65bf5a023a4d84f4db3c725bebc7499e6065d7f0..e4197fa878f3d78080e92e8c75ba02d806b64ae3 100644
--- a/ipatests/test_ipaserver/test_changepw.py
+++ b/ipatests/test_ipaserver/test_changepw.py
@@ -33,8 +33,7 @@
 class test_changepw(XMLRPC_test, Unauthorized_HTTP_test):
     app_uri = '/ipa/session/change_password'
 
-    def setup(self):
-        super(test_changepw, self).setup()
+    def setup(cls):
         try:
             api.Command['user_add'](uid=testuser, givenname=u'Test', sn=u'User')
             api.Command['passwd'](testuser, password=u'old_password')
@@ -43,12 +42,11 @@ def setup(self):
                 'Cannot set up test user: %s' % e
             )
 
-    def teardown(self):
+    def teardown(cls):
         try:
             api.Command['user_del']([testuser])
         except errors.NotFound:
             pass
-        super(test_changepw, self).teardown()
 
     def _changepw(self, user, old_password, new_password):
         return self.send_request(params={'user': str(user),
diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py
index a19032503ef9c63cd337038fcaf8e7c98b5d5f08..c878504b2a831970ab421ef286b145d276402164 100644
--- a/ipatests/test_xmlrpc/test_cert_plugin.py
+++ b/ipatests/test_xmlrpc/test_cert_plugin.py
@@ -84,7 +84,6 @@ def run_certutil(self, args, stdin=None):
         return ipautil.run(new_args, stdin)
 
     def setup(self):
-        super(test_cert, self).setup()
         self.reqdir = tempfile.mkdtemp(prefix = "tmp-")
         self.reqfile = self.reqdir + "/test.csr"
         self.pwname = self.reqdir + "/pwd"
@@ -100,7 +99,6 @@ def setup(self):
         self.subject = DN(('CN', self.host_fqdn), x509.subject_base())
 
     def teardown(self):
-        super(test_cert, self).teardown()
         shutil.rmtree(self.reqdir, ignore_errors=True)
 
     def generateCSR(self, subject):
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index 2030f1cb2d95e1f012e72009b119249131db7a50..1f44f7794bdd390153317b08b396ac3dfc09e150 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -172,15 +172,11 @@ def setup_class(cls):
         if not server_available:
             raise nose.SkipTest('%r: Server not available: %r' %
                                 (cls.__module__, api.env.xmlrpc_uri))
-
-    def setup(self):
         if not api.Backend.rpcclient.isconnected():
             api.Backend.rpcclient.connect(fallback=False)
 
-    def teardown(self):
-        """
-        nose tear-down fixture.
-        """
+    @classmethod
+    def teardown_class(cls):
         request.destroy_context()
 
     def failsafe_add(self, obj, pk, **options):
-- 
2.1.0

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to