def pytest_configure(config): # Load all the plugins defined in pytest_plugins config.pluginmanager.consider_module(sys.modules[__name__]) config.indico_temp_dir = py.path.local(tempfile.mkdtemp(prefix='indicotesttmp.')) plugins = filter(None, [x.strip() for x in re.split(r'[\s,;]+', config.getini('indico_plugins'))]) # Throw away all indico.conf options early Config.getInstance().reset({ 'DBConnectionParams': ('localhost', 0), # invalid port - just so we never connect to a real ZODB! 'SmtpServer': ('localhost', 0), # invalid port - just in case so we NEVER send emails! 'CacheBackend': 'null', 'Loggers': [], 'UploadedFilesTempDir': config.indico_temp_dir.strpath, 'XMLCacheDir': config.indico_temp_dir.strpath, 'ArchiveDir': config.indico_temp_dir.strpath, 'StorageBackends': {'default': config.indico_temp_dir}, 'AttachmentStorage': 'default', 'Plugins': plugins, 'SecretKey': os.urandom(16) }) # Make sure we don't write any log files (or worse: send emails) Logger.reset() del logging.root.handlers[:] logging.root.addHandler(logging.NullHandler()) # Silence the annoying pycountry logger import pycountry.db pycountry.db.logger.addHandler(logging.NullHandler())
def pytest_configure(config): # Load all the plugins defined in pytest_plugins config.pluginmanager.consider_module(sys.modules[__name__]) config.indico_temp_dir = py.path.local( tempfile.mkdtemp(prefix='indicotesttmp.')) plugins = filter(None, [ x.strip() for x in re.split(r'[\s,;]+', config.getini('indico_plugins')) ]) # Throw away all indico.conf options early Config.getInstance().reset({ 'DBConnectionParams': ('localhost', 0), # invalid port - just so we never connect to a real ZODB! 'SmtpServer': ('localhost', 0), # invalid port - just in case so we NEVER send emails! 'CacheBackend': 'null', 'Loggers': [], 'UploadedFilesTempDir': config.indico_temp_dir.strpath, 'XMLCacheDir': config.indico_temp_dir.strpath, 'ArchiveDir': config.indico_temp_dir.strpath, 'Plugins': plugins, 'SecretKey': os.urandom(16) }) # Make sure we don't write any log files (or worse: send emails) Logger.reset() del logging.root.handlers[:] logging.root.addHandler(logging.NullHandler())
def pytest_configure(config): # Load all the plugins defined in pytest_plugins config.pluginmanager.consider_module(sys.modules[__name__]) config.indico_temp_dir = py.path.local(tempfile.mkdtemp(prefix="indicotesttmp.")) plugins = filter(None, [x.strip() for x in re.split(r"[\s,;]+", config.getini("indico_plugins"))]) # Throw away all indico.conf options early Config.getInstance().reset( { "DBConnectionParams": ("localhost", 0), # invalid port - just so we never connect to a real ZODB! "SmtpServer": ("localhost", 0), # invalid port - just in case so we NEVER send emails! "CacheBackend": "null", "Loggers": [], "UploadedFilesTempDir": config.indico_temp_dir.strpath, "XMLCacheDir": config.indico_temp_dir.strpath, "ArchiveDir": config.indico_temp_dir.strpath, "StorageBackends": {"default": config.indico_temp_dir}, "AttachmentStorage": "default", "Plugins": plugins, "SecretKey": os.urandom(16), } ) # Make sure we don't write any log files (or worse: send emails) Logger.reset() del logging.root.handlers[:] logging.root.addHandler(logging.NullHandler()) # Silence the annoying pycountry logger import pycountry.db pycountry.db.logger.addHandler(logging.NullHandler())
def make_app(set_path=False, db_setup=True): # If you are reading this code and wonder how to access the app: # >>> from flask import current_app as app # This only works while inside an application context but you really shouldn't have any # reason to access it outside this method without being inside an application context. # When set_path is enabled, SERVER_NAME and APPLICATION_ROOT are set according to BaseURL # so URLs can be generated without an app context, e.g. in the indico shell if _app_ctx_stack.top: Logger.get('flask').warn('make_app({}) called within app context, using existing app'.format(set_path)) return _app_ctx_stack.top.app app = IndicoFlask('indico', static_folder=None, template_folder='web/templates') fix_root_path(app) configure_app(app, set_path) setup_jinja(app) setup_assets() if db_setup: configure_db(app) extend_url_map(app) add_handlers(app) add_blueprints(app) if app.config['INDICO_COMPAT_ROUTES']: add_compat_blueprints(app) add_plugin_blueprints(app) with app.app_context(): # re-establish loggers Logger.reset() return app
def pytest_configure(config): from indico.core.config import Config from indico.core.logger import Logger # Load all the plugins defined in pytest_plugins config.pluginmanager.consider_module(sys.modules[__name__]) config.indico_temp_dir = py.path.local(tempfile.mkdtemp(prefix='indicotesttmp.')) plugins = filter(None, [x.strip() for x in re.split(r'[\s,;]+', config.getini('indico_plugins'))]) # Throw away all indico.conf options early Config.getInstance().reset({ 'SmtpServer': ('localhost', 0), # invalid port - just in case so we NEVER send emails! 'CacheBackend': 'null', 'Loggers': [], 'TempDir': config.indico_temp_dir.strpath, 'CacheDir': config.indico_temp_dir.strpath, 'StorageBackends': {'default': config.indico_temp_dir}, 'AttachmentStorage': 'default', 'Plugins': plugins, 'SecretKey': os.urandom(16) }) # Make sure we don't write any log files (or worse: send emails) Logger.reset() del logging.root.handlers[:] logging.root.addHandler(logging.NullHandler()) # Silence the annoying pycountry logger import pycountry.db pycountry.db.logger.addHandler(logging.NullHandler())
def pytest_configure(config): config.indico_temp_dir = py.path.local(tempfile.mkdtemp(prefix='indicotesttmp.')) # Throw away all indico.conf options early Config.getInstance().reset({ 'DBConnectionParams': ('localhost', 0), # invalid port - just so we never connect to a real ZODB! 'SmtpServer': ('localhost', 0), # invalid port - just in case so we NEVER send emails! 'CacheBackend': 'null', 'Loggers': [], 'UploadedFilesTempDir': config.indico_temp_dir.strpath, 'XMLCacheDir': config.indico_temp_dir.strpath, 'ArchiveDir': config.indico_temp_dir.strpath }) # Make sure we don't write any log files (or worse: send emails) Logger.reset() del logging.root.handlers[:] logging.root.addHandler(logging.NullHandler())