Changeset - b755464eff8d
[Not reviewed]
default
0 2 0
Thomas De Schampheleire - 10 years ago 2016-02-03 22:33:59
thomas.de.schampheleire@gmail.com
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
2 files changed with 9 insertions and 12 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/__init__.py
Show inline comments
 
@@ -41,7 +41,7 @@ from pylons.util import ContextObj
 

	
 
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 @@ if not is_windows:
 

	
 
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',
kallithea/tests/functional/test_admin_auth_settings.py
Show inline comments
 
@@ -21,10 +21,9 @@ class TestAuthSettingsController(TestCon
 
                                    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 @@ class TestAuthSettingsController(TestCon
 
        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 @@ class TestAuthSettingsController(TestCon
 
        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 @@ class TestAuthSettingsController(TestCon
 
        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-.*'})
0 comments (0 inline, 0 general)