[Libosinfo] [PATCH osinfo-db 1/3] tests: conftest: add pytest_configure
Cole Robinson
crobinso at redhat.com
Thu Mar 28 20:55:32 UTC 2019
This is a standard function to do post option parsing configuration,
like setting our environment variable
Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
tests/conftest.py | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index 5f9cd5b..67b3a6f 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -4,20 +4,21 @@
import os
-def _setup_env():
+def pytest_addoption(parser):
+ parser.addoption("--network-tests", action="store_true", default=False,
+ help=("Run osinfo-db network tests. Same tests as triggered "
+ "by setting env variable OSINFO_DB_NETWORK_TESTS"))
+
+
+def pytest_configure(config):
key = "INTERNAL_OSINFO_DB_DATA_DIR"
if key not in os.environ:
os.environ[key] = os.path.realpath(os.path.join(
os.path.dirname(__file__), "..", "data"))
-
-_setup_env()
-
-
-def pytest_addoption(parser):
- parser.addoption("--network-tests", action="store_true", default=False,
- help=("Run osinfo-db network tests. Same tests as triggered "
- "by setting env variable OSINFO_DB_NETWORK_TESTS"))
+ # This will trigger some DATA_DIR validation
+ from . import util
+ dummy = util
def pytest_ignore_collect(path, config):
@@ -28,8 +29,3 @@ def pytest_ignore_collect(path, config):
os.environ.get("OSINFO_DB_NETWORK_TESTS"))
if os.path.basename(str(path)) == "test_urls.py" and not run_network:
return True
-
-
-# This will trigger some DATA_DIR validation
-from . import util
-dummy = util
--
2.21.0
More information about the Libosinfo
mailing list