Changeset - acfd700770cc
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 10 years ago 2016-05-14 21:54:03
thomas.de.schampheleire@gmail.com
pytest migration: merge TestControllerPytest with BaseTestController

There is no need anymore for a separate BaseTestController class.
Simplify the code by removing it.
1 file changed with 7 insertions and 14 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/__init__.py
Show inline comments
 
@@ -167,21 +167,25 @@ def remove_all_notifications():
 
    # Because query().delete() does not (by default) trigger cascades.
 
    # http://docs.sqlalchemy.org/en/rel_0_7/orm/collections.html#passive-deletes
 
    UserNotification.query().delete()
 

	
 
    Session().commit()
 

	
 
class BaseTestController(object):
 
    """Base test controller used by pytest and unittest tests controllers."""
 
class TestControllerPytest(object):
 
    """Pytest-style test controller"""
 

	
 
    # Note: pytest base classes cannot have an __init__ method
 

	
 
    def init(self):
 
    @pytest.fixture(autouse=True)
 
    def app_fixture(self):
 
        self.wsgiapp = pylons.test.pylonsapp
 
        init_stack(self.wsgiapp.config)
 
        self.app = TestApp(self.wsgiapp)
 
        self.maxDiff = None
 
        self.index_location = config['app_conf']['index_dir']
 
        return self.app
 

	
 
    def log_user(self, username=TEST_USER_ADMIN_LOGIN,
 
                 password=TEST_USER_ADMIN_PASS):
 
        self._logged_username = username
 
        response = self.app.post(url(controller='login', action='index'),
 
                                 {'username': username,
 
@@ -222,17 +226,6 @@ class BaseTestController(object):
 
                           (msg, skip,
 
                            ', '.join('`%s`' % m for level, m in response.session['flash']))))
 

	
 
    def checkSessionFlashRegex(self, response, regex, skip=0):
 
        self.checkSessionFlash(response, regex, skip=skip, _matcher=re.search)
 

	
 
class TestControllerPytest(BaseTestController):
 
    """Pytest-style test controller"""
 

	
 
    # Note: pytest base classes cannot have an __init__ method
 

	
 
    @pytest.fixture(autouse=True)
 
    def app_fixture(self):
 
        self.wsgiapp = pylons.test.pylonsapp
 
        init_stack(self.wsgiapp.config)
 
        self.init()
 
        return self.app
0 comments (0 inline, 0 general)