2018-11-04 19:23:11 +00:00
|
|
|
"""
|
|
|
|
This file is part of nucypher.
|
|
|
|
|
|
|
|
nucypher is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
nucypher is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
"""
|
2018-11-03 21:48:11 +00:00
|
|
|
|
2018-11-09 15:25:20 +00:00
|
|
|
import pytest
|
2018-11-17 19:27:53 +00:00
|
|
|
from twisted.logger import globalLogPublisher, LogLevel
|
2018-11-09 15:25:20 +00:00
|
|
|
|
2018-11-09 17:29:49 +00:00
|
|
|
from nucypher.cli import NucypherClickConfig
|
2018-11-17 19:27:53 +00:00
|
|
|
from nucypher.utilities.logging import SimpleObserver
|
2018-11-09 15:25:20 +00:00
|
|
|
|
|
|
|
# Logger Configuration
|
2018-11-05 23:13:45 +00:00
|
|
|
NucypherClickConfig.log_to_sentry = False
|
2018-08-05 20:09:05 +00:00
|
|
|
|
2018-11-09 15:25:20 +00:00
|
|
|
# Pytest configuration
|
|
|
|
pytest_plugins = [
|
|
|
|
'tests.fixtures',
|
|
|
|
]
|
2018-06-04 18:00:08 +00:00
|
|
|
|
|
|
|
|
2018-05-07 02:11:20 +00:00
|
|
|
def pytest_addoption(parser):
|
2018-09-13 20:07:14 +00:00
|
|
|
parser.addoption("--runslow",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
2018-09-20 19:51:41 +00:00
|
|
|
help="run tests even if they are marked as slow")
|
2018-05-07 02:11:20 +00:00
|
|
|
|
2018-06-04 18:00:08 +00:00
|
|
|
|
2018-05-07 02:11:20 +00:00
|
|
|
def pytest_collection_modifyitems(config, items):
|
2018-11-17 19:27:53 +00:00
|
|
|
|
|
|
|
if not config.getoption("--runslow"): # --runslow given in cli: do not skip slow tests
|
|
|
|
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
|
|
|
|
for item in items:
|
|
|
|
if "slow" in item.keywords:
|
|
|
|
item.add_marker(skip_slow)
|
|
|
|
log_level_name = config.getoption("--log-level", "info", skip=True)
|
|
|
|
observer = SimpleObserver(log_level_name)
|
|
|
|
globalLogPublisher.addObserver(observer)
|