diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2024-01-04 10:36:03 +0000 |
---|---|---|
committer | Daniel P. Berrangé <dan-gitlab@berrange.com> | 2024-01-19 09:45:18 +0000 |
commit | c7555f241e173089391c6632d181146b652a5f13 (patch) | |
tree | 6f9b3a7d1bedb84c9a306db84c95fc1e405146e5 | |
parent | 31da418a08c5335f6e10926942c3a2ce7e916baa (diff) | |
download | libvirt-ci-c7555f241e173089391c6632d181146b652a5f13.zip libvirt-ci-c7555f241e173089391c6632d181146b652a5f13.tar.gz libvirt-ci-c7555f241e173089391c6632d181146b652a5f13.tar.bz2 |
tests: mock 'get_host_arch' in package resolution tests
The logic in 'test_package_resolution' will expand mappings for various
distros. The mapping expansion will vary depending on the host arch
and the expected output files were created on x86_64. Thus to ensure
the tests pass on other arches, we must mock the 'get_host_arch' method.
Fixes: https://gitlab.com/libvirt/libvirt-ci/-/issues/31
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | tests/test_packages.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/test_packages.py b/tests/test_packages.py index 4c8a0bf..1d44e6f 100644 --- a/tests/test_packages.py +++ b/tests/test_packages.py @@ -48,6 +48,15 @@ def test_project(projects): Path(test_utils.test_data_indir(__file__), "packages.yml")) +def mock_get_host_arch(): + return "x86_64" + + +@pytest.fixture(scope="module") +def mock_arch(monkeypatch_module_scope): + monkeypatch_module_scope.setattr(util, "get_host_arch", mock_get_host_arch) + + def test_verify_all_mappings_and_packages(assert_equal, packages): expected_path = Path(test_utils.test_data_indir(__file__), "packages.yml") actual = {"packages": sorted(packages.mappings.keys())} @@ -67,7 +76,7 @@ cross_params = [ @pytest.mark.parametrize("target,arch", native_params + cross_params) def test_package_resolution(assert_equal, targets, packages, test_project, - target, arch,): + target, arch, mock_arch): if arch is None: outfile = f"{target}.yml" else: |