aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Skultety <eskultet@redhat.com>2023-04-27 12:01:20 +0200
committerDaniel P. Berrangé <berrange@redhat.com>2023-04-28 10:05:23 +0000
commit073c7beb53d1174fec9620433adacee850ddd3ed (patch)
treecbbfbe41b55b87132910bdf7638ddd7d43ec8bae
parent9f2ce838fcb65721534b5e4201a260c1f03030f1 (diff)
downloadlibvirt-ci-073c7beb53d1174fec9620433adacee850ddd3ed.zip
libvirt-ci-073c7beb53d1174fec9620433adacee850ddd3ed.tar.gz
libvirt-ci-073c7beb53d1174fec9620433adacee850ddd3ed.tar.bz2
tests: commands: Consolidate the installed package/run from git tests
In order to support both use cases of lcitool (running from git, using an installed package) there were two test cases one of which was properly skipped by pytest if the package wasn't installed. That however wasn't optimal, as in local environments the same tests ran twice. Consolidate the logic so that pytest figures this out dynamically and only run the test case once. Signed-off-by: Erik Skultety <eskultet@redhat.com>
-rw-r--r--tests/test_commands.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py
index f23b81f..f289de7 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -4,7 +4,6 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
-import os
import pytest
import subprocess
import sys
@@ -24,17 +23,12 @@ cli_args = [
@pytest.mark.parametrize("test_cli_args", cli_args)
def test_commands(test_cli_args):
- pybase = Path(__file__).parent.parent
- lcitool = pybase.joinpath("bin", "lcitool")
- subenv = os.environ
- subenv["PYTHONPATH"] = str(pybase)
- subprocess.check_call([lcitool] + test_cli_args, stdout=subprocess.DEVNULL)
+ if sys.prefix == sys.base_prefix:
+ # we're running the tests directly from git using the lcitool wrapper
+ lcitool_path = Path(__file__).parent.parent.joinpath("bin", "lcitool")
+ else:
+ # we're running the tests in a virtual env
+ lcitool_path = Path(sys.prefix, "bin/lcitool")
-
-@pytest.mark.skipif(sys.prefix == sys.base_prefix,
- reason="lcitool package not installed")
-@pytest.mark.parametrize("test_cli_args", cli_args)
-def test_commands_installed(test_cli_args):
- lcitool_venv_path = Path(sys.prefix, "bin/lcitool")
- subprocess.check_call([lcitool_venv_path] + test_cli_args,
+ subprocess.check_call([lcitool_path] + test_cli_args,
stdout=subprocess.DEVNULL)