From 48a9c389c58ba2bf90b3b075416b4d878466b77f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 30 Nov 2018 08:18:13 -0500 Subject: [PATCH] Add loglevel support to tests --- tests/conftest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index f7688a9d..76a8ddee 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,20 @@ 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