[Libosinfo] [PATCH osinfo-db 2/3] tests: conftest: handle default log-level setting

Cole Robinson crobinso at redhat.com
Thu Mar 28 20:55:33 UTC 2019


This makes log-level=info the default for direct pytest-3 invocations,
and lets us drop the fallback detection in Makefile

Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
 Makefile          | 4 +---
 tests/conftest.py | 5 +++++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 9d7f109..b3e06d5 100644
--- a/Makefile
+++ b/Makefile
@@ -34,8 +34,6 @@ ZANATA = zanata
 
 PYTHON = python3
 
-PYTEST_LOG_LEVEL = $(shell $(PYTHON) -m pytest --help | grep log-level >/dev/null && echo "--log-level=info")
-
 V = 0
 
 V_I18N = $(V_I18N_$(V))
@@ -123,4 +121,4 @@ update-po:
         done
 
 check: $(DATA_FILES) $(SCHEMA_FILES)
-	LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8 $(PYTHON) -m pytest $(PYTEST_LOG_LEVEL)
+	LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8 $(PYTHON) -m pytest
diff --git a/tests/conftest.py b/tests/conftest.py
index 67b3a6f..4a16a04 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -16,6 +16,11 @@ def pytest_configure(config):
         os.environ[key] = os.path.realpath(os.path.join(
             os.path.dirname(__file__), "..", "data"))
 
+    # Default to --log-level=info if not otherwise specified
+    if (hasattr(config.option, "log_level") and
+        config.option.log_level is None):
+        config.option.log_level = "info"
+
     # This will trigger some DATA_DIR validation
     from . import util
     dummy = util
-- 
2.21.0




More information about the Libosinfo mailing list