tests: Add a `db` fixture that initializes the database.
This is quite useful if tests only need the database and not the whole app. Then only this fixture is needed instead of the full blown pylonsapp/app fixtures.
This commit is contained in:
parent
ae2b380d5b
commit
7eeedebf7b
1 changed files with 13 additions and 1 deletions
|
|
@ -218,7 +218,7 @@ def app(request, pylonsapp, http_environ):
|
|||
return app
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture(scope='session')
|
||||
def app_settings(pylonsapp, pylons_config):
|
||||
"""
|
||||
Settings dictionary used to create the app.
|
||||
|
|
@ -234,6 +234,18 @@ def app_settings(pylonsapp, pylons_config):
|
|||
return settings
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def db(app_settings):
|
||||
"""
|
||||
Initializes the database connection.
|
||||
|
||||
It uses the same settings which are used to create the ``pylonsapp`` or
|
||||
``app`` fixtures.
|
||||
"""
|
||||
from rhodecode.config.utils import initialize_database
|
||||
initialize_database(app_settings)
|
||||
|
||||
|
||||
LoginData = collections.namedtuple('LoginData', ('csrf_token', 'user'))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue