Add loglevel support to tests

kivy_mainline_and_py3.8
Tyler Goodlet 2018-11-30 08:18:13 -05:00
parent 288ea604af
commit 48a9c389c5
1 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,20 @@
import pytest import pytest
import tractor
from piker import log
def pytest_addoption(parser):
parser.addoption("--ll", action="store", dest='loglevel',
default=None, help="logging level to set when testing")
@pytest.fixture(scope='session', autouse=True)
def loglevel(request):
orig = tractor.log._default_loglevel
level = tractor.log._default_loglevel = request.config.option.loglevel
log.get_console_log(level)
yield level
tractor.log._default_loglevel = orig
@pytest.fixture @pytest.fixture