[Libosinfo] [osinfo-db-tools PATCH] test_osinfo_db_path: Don't fail if OSINFO_*_DIR are set
Fabiano Fidêncio
fidencio at redhat.com
Tue Apr 30 09:46:05 UTC 2019
In case OSINFO_{SYSTEM,DATA,USER}_DIR are set, let's just use those
values in test_osinfo_db_path.py instead of the pre-defined ones.
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
tests/test_osinfo_db_path.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/tests/test_osinfo_db_path.py b/tests/test_osinfo_db_path.py
index bc3c549..f9b69da 100755
--- a/tests/test_osinfo_db_path.py
+++ b/tests/test_osinfo_db_path.py
@@ -20,7 +20,9 @@ def test_osinfo_db_path_system():
"""
cmd = [util.Tools.db_path, util.ToolsArgs.SYSTEM]
output = util.get_output(cmd)
- expected_output = os.path.join(DATADIR, "osinfo\n")
+ expected_output = os.environ.get("OSINFO_SYSTEM_DIR") or \
+ os.path.join(DATADIR, "osinfo")
+ expected_output += "\n"
assert output == expected_output
@@ -30,7 +32,9 @@ def test_osinfo_db_path_local():
"""
cmd = [util.Tools.db_path, util.ToolsArgs.LOCAL]
output = util.get_output(cmd)
- expected_output = os.path.join(SYSCONFDIR, "osinfo\n")
+ expected_output = os.environ.get("OSINFO_DATA_DIR") or \
+ os.path.join(SYSCONFDIR, "osinfo")
+ expected_output += "\n"
assert output == expected_output
@@ -40,8 +44,9 @@ def test_osinfo_db_path_user():
"""
cmd = [util.Tools.db_path, util.ToolsArgs.USER]
output = util.get_output(cmd)
- expected_output = os.path.join(os.environ["HOME"], ".config",
- "osinfo\n")
+ expected_output = os.environ.get("OSINFO_USER_DIR") or \
+ os.path.join(os.environ["HOME"], ".config", "osinfo")
+ expected_output += "\n"
assert output == expected_output
@@ -62,7 +67,10 @@ def test_osinfo_db_path_root():
cmd = [util.Tools.db_path, util.ToolsArgs.ROOT, FOOBAR_DIR,
util.ToolsArgs.SYSTEM]
output = util.get_output(cmd)
- expected_output = os.path.join(FOOBAR_DIR, *DATADIR.split("/"), "osinfo\n")
+ systemdir = os.environ.get("OSINFO_SYSTEM_DIR")[1:] or \
+ os.path.join(DATADIR[1:], "osinfo")
+ systemdir += "\n"
+ expected_output = os.path.join(FOOBAR_DIR, systemdir)
assert output == expected_output
--
2.21.0
More information about the Libosinfo
mailing list