-
Notifications
You must be signed in to change notification settings - Fork 13
/
conftest.py
37 lines (27 loc) · 1.36 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# (C) Copyright 2018- ECMWF.
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.
"""
Local pytest plugin to add bespoke pytest extensions for Loki
See the pytest documentation for more details:
https://docs.pytest.org/en/stable/how-to/writing_plugins.html#local-conftest-plugins
"""
from loki.config import config as loki_config
def pytest_addoption(parser, pluginmanager): # pylint: disable=unused-argument
"""
Add options to the pytest CLI
Additional options can be specified via ``parser.addoption`` using the same signature as
:any:`argparse.ArgumentParser.add_argument`.
For Loki, we add ``--loki-log-level`` to overwrite the log level in :any:`loki.logging`.
"""
parser.addoption('--loki-log-level', dest='LOKI_LOG_LEVEL', default='INFO',
help='Change the Loki log level (ERROR, WARNING, INFO, PERF, DETAIL, DEBUG)')
def pytest_configure(config):
"""
Apply configuration changes
This function is invoked after all command line options have been processed
"""
loki_config['log-level'] = config.option.LOKI_LOG_LEVEL