Commit a7528ca7 authored by Petr Špaček's avatar Petr Špaček

Merge branch 'pytest-xdist-logging' into 'master'

logging: exits if both verbose logging and xdist are on

See merge request !144
parents 839af390 8e9f5639
Pipeline #43180 failed with stage
in 1 minute and 23 seconds
from collections import namedtuple, OrderedDict from collections import namedtuple, OrderedDict
import glob import glob
import logging
import os import os
import re import re
import yaml import yaml
import pytest
Scenario = namedtuple("Scenario", ["path", "qmin", "config"]) Scenario = namedtuple("Scenario", ["path", "qmin", "config"])
...@@ -125,3 +128,22 @@ def pytest_generate_tests(metafunc): ...@@ -125,3 +128,22 @@ def pytest_generate_tests(metafunc):
if 'rpl_path' in metafunc.fixturenames: if 'rpl_path' in metafunc.fixturenames:
paths = metafunc.config.option.scenarios paths = metafunc.config.option.scenarios
metafunc.parametrize("rpl_path", rpls(paths), ids=str) metafunc.parametrize("rpl_path", rpls(paths), ids=str)
def check_log_level_xdist(level):
if level < logging.ERROR:
pytest.exit("Advanced logging not available while running with xdist "
"(try ommiting -n option)")
def pytest_configure(config):
# This means pytest-xdist is installed and enabled
if hasattr(config.option, "dist") and config.option.dist == "load":
log_level = config.option.log_level
if log_level is None:
log_level = int(log_level)
except ValueError:
log_level = logging.getLevelName(log_level)
...@@ -3,4 +3,5 @@ log_print = true ...@@ -3,4 +3,5 @@ log_print = true
norecursedirs=* norecursedirs=*
log_cli=true log_cli=true
...@@ -9,4 +9,4 @@ source "${MAKEDIR}/" ...@@ -9,4 +9,4 @@ source "${MAKEDIR}/"
# compatibility with old TESTS= env variable # compatibility with old TESTS= env variable
# add --scenarios= only if the variable TESTS is non-empty # add --scenarios= only if the variable TESTS is non-empty
python3 -m pytest -c "${MAKEDIR}/deckard_pytest.ini" --tb=short -q ${VERBOSE:-"--log-level=40"} ${VERBOSE:+"--log-level=10"} "${MAKEDIR}" ${DECKARDFLAGS:-} ${TESTS:+"--scenarios=${TESTS}"} "$@" python3 -m pytest -c "${MAKEDIR}/deckard_pytest.ini" --tb=short -q ${VERBOSE:+"--log-level=DEBUG"} "${MAKEDIR}" ${DECKARDFLAGS:-} ${TESTS:+"--scenarios=${TESTS}"} "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment