1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
26 from indico
.core
.config
import Config
27 from indico
.core
.logger
import Logger
30 pytest_plugins
= ('indico.testing.fixtures.app', 'indico.testing.fixtures.database', 'indico.testing.fixtures.disallow',
31 'indico.testing.fixtures.user', 'indico.testing.fixtures.event', 'indico.testing.fixtures.smtp',
32 'indico.testing.fixtures.util', 'indico.testing.fixtures.registration')
35 def pytest_configure(config
):
36 # Load all the plugins defined in pytest_plugins
37 config
.pluginmanager
.consider_module(sys
.modules
[__name__
])
38 config
.indico_temp_dir
= py
.path
.local(tempfile
.mkdtemp(prefix
='indicotesttmp.'))
39 plugins
= filter(None, [x
.strip() for x
in re
.split(r
'[\s,;]+', config
.getini('indico_plugins'))])
40 # Throw away all indico.conf options early
41 Config
.getInstance().reset({
42 'DBConnectionParams': ('localhost', 0), # invalid port - just so we never connect to a real ZODB!
43 'SmtpServer': ('localhost', 0), # invalid port - just in case so we NEVER send emails!
44 'CacheBackend': 'null',
46 'UploadedFilesTempDir': config
.indico_temp_dir
.strpath
,
47 'XMLCacheDir': config
.indico_temp_dir
.strpath
,
48 'ArchiveDir': config
.indico_temp_dir
.strpath
,
50 'SecretKey': os
.urandom(16)
52 # Make sure we don't write any log files (or worse: send emails)
54 del logging
.root
.handlers
[:]
55 logging
.root
.addHandler(logging
.NullHandler())
58 def pytest_unconfigure(config
):
59 config
.indico_temp_dir
.remove(rec
=True)
62 def pytest_addoption(parser
):
63 parser
.addini('indico_plugins', 'List of indico plugins to load')