Mercurial > kallithea
changeset 5702:b755464eff8d
pytest migration: use pytest test skipping instead of nose's
While the nose test skipping still worked, we want to remove all remnants of
nose, so switch to the pytest equivalent.
Note: due to a bug in pytest-sugar (reported at [1]) the skipped tests are
not shown explicitly when using the 'skipif' approach, while they were with
the nose approach. Since pytest-sugar is not enabled yet in setup.py, this
is not deemed a problem.
[1] https://github.com/Frozenball/pytest-sugar/issues/75
author | Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> |
---|---|
date | Wed, 03 Feb 2016 22:33:59 +0100 |
parents | 2d2decce586f |
children | 2f14b4db0362 |
files | kallithea/tests/__init__.py kallithea/tests/functional/test_admin_auth_settings.py |
diffstat | 2 files changed, 9 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/tests/__init__.py Wed Feb 03 22:26:25 2016 +0100 +++ b/kallithea/tests/__init__.py Wed Feb 03 22:33:59 2016 +0100 @@ -41,7 +41,7 @@ from routes.util import URLGenerator from webtest import TestApp -from nose.plugins.skip import SkipTest +import pytest from kallithea.lib.compat import unittest from kallithea import is_windows @@ -57,9 +57,11 @@ log = logging.getLogger(__name__) +skipif = pytest.mark.skipif + __all__ = [ - 'parameterized', 'environ', 'url', 'TestController', - 'SkipTest', 'ldap_lib_installed', 'pam_lib_installed', 'BaseTestCase', 'init_stack', + 'skipif', 'parameterized', 'environ', 'url', 'TestController', + 'ldap_lib_installed', 'pam_lib_installed', 'BaseTestCase', 'init_stack', 'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS', 'TEST_USER_ADMIN_EMAIL', 'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS',
--- a/kallithea/tests/functional/test_admin_auth_settings.py Wed Feb 03 22:26:25 2016 +0100 +++ b/kallithea/tests/functional/test_admin_auth_settings.py Wed Feb 03 22:33:59 2016 +0100 @@ -21,10 +21,9 @@ action='index')) response.mustcontain('Authentication Plugins') + @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib') def test_ldap_save_settings(self): self.log_user() - if not ldap_lib_installed: - raise SkipTest('skipping due to missing ldap lib') params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap') params.update({'auth_ldap_host': u'dc.example.com', @@ -51,10 +50,9 @@ self.assertEqual(new_settings['auth_ldap_host'], u'dc.example.com', 'fail db write compare') + @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib') def test_ldap_error_form_wrong_port_number(self): self.log_user() - if not ldap_lib_installed: - raise SkipTest('skipping due to missing ldap lib') params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap') params.update({'auth_ldap_host': '', @@ -78,10 +76,9 @@ response.mustcontain("""<span class="error-message">""" """Please enter a number</span>""") + @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib') def test_ldap_error_form(self): self.log_user() - if not ldap_lib_installed: - raise SkipTest('skipping due to missing ldap lib') params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap') params.update({'auth_ldap_host': 'Host', @@ -245,12 +242,10 @@ self.assertEqual(new_settings['auth_crowd_host'], u'hostname', 'fail db write compare') + @skipif(not pam_lib_installed, reason='skipping due to missing pam lib') def test_pam_save_settings(self): self.log_user() - if not pam_lib_installed: - raise SkipTest('skipping due to missing pam lib') - params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_pam') params.update({'auth_pam_service': 'kallithea', 'auth_pam_gecos': '^foo-.*'})