Mercurial > kallithea
view kallithea/tests/conftest.py @ 5228:f9367342412a
tests: hide database setup queries with pytest
Unlike nosetest, pytest would show the database setup queries at the
beginning of the test run, which don't bring added value.
Hide them by disabling logging during this time.
Note that this does not provide an easy method of enabling the logging on
demand (what could be done with the -s switch in nosetest).
author | Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> |
---|---|
date | Thu, 02 Jul 2015 12:07:19 +0200 |
parents | c2779dc2c1fb |
children | 19267f233d39 |
line wrap: on
line source
import os import sys import logging import pkg_resources from paste.deploy import loadapp import pylons.test from pylons.i18n.translation import _get_translator def pytest_configure(): path = os.getcwd() sys.path.insert(0, path) pkg_resources.working_set.add_entry(path) # Disable INFO logging of test database creation, restore with NOTSET logging.disable(logging.INFO) pylons.test.pylonsapp = loadapp('config:test.ini', relative_to=path) logging.disable(logging.NOTSET) # Setup the config and app_globals, only works if we can get # to the config object conf = getattr(pylons.test.pylonsapp, 'config') if conf: pylons.config._push_object(conf) if 'pylons.app_globals' in conf: pylons.app_globals._push_object(conf['pylons.app_globals']) # Initialize a translator for tests that utilize i18n translator = _get_translator(pylons.config.get('lang')) pylons.translator._push_object(translator) return pylons.test.pylonsapp