[PATCH osinfo-db 1/3] tests: conftest: add pytest_configure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a standard function to do post option parsing configuration,
like setting our environment variable

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 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

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux