aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Skultety <eskultet@redhat.com>2023-03-29 16:15:01 +0200
committerDaniel P. Berrangé <berrange@redhat.com>2023-03-30 08:00:42 +0000
commitcce2e7f910e93d45e11147648e973319532eab32 (patch)
tree8c6c293a2c6ffe2b7a8962711c9aec0458016055
parent21c30c59671c319e41a6c9f129d0f6b9d07286a5 (diff)
downloadlibvirt-ci-cce2e7f910e93d45e11147648e973319532eab32.zip
libvirt-ci-cce2e7f910e93d45e11147648e973319532eab32.tar.gz
libvirt-ci-cce2e7f910e93d45e11147648e973319532eab32.tar.bz2
tests: Convert tests to the new assert_equal fixture
With all the 'diff' bits in place, we can now convert all but one (test_manifest) tests to using this new fixture. Signed-off-by: Erik Skultety <eskultet@redhat.com>
-rw-r--r--tests/test_config.py4
-rw-r--r--tests/test_containers.py20
-rw-r--r--tests/test_formatters.py24
-rw-r--r--tests/test_packages.py9
4 files changed, 27 insertions, 30 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 9a2fa7f..b8ce649 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -21,11 +21,11 @@ from lcitool.config import ValidationError
"unknown_key.yml",
],
)
-def test_config(config, config_filename):
+def test_config(assert_equal, config, config_filename):
expected_path = Path(test_utils.test_data_outdir(__file__), config_filename)
actual = config.values
- test_utils.assert_yaml_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
@pytest.mark.parametrize(
diff --git a/tests/test_containers.py b/tests/test_containers.py
index a10b21f..36b23ae 100644
--- a/tests/test_containers.py
+++ b/tests/test_containers.py
@@ -3,7 +3,6 @@ import pytest
from pathlib import Path
from io import TextIOBase
-from test_utils.utils import assert_equal_list
from lcitool.containers import ContainerError, Docker, Podman
@@ -76,8 +75,8 @@ class TestPodmanExtraArgs:
pytest.param("user", id_mapping, id="testuser-string-id")
]
)
- def test_podman_extra_args(self, user, args, mock_pwd, podman):
- assert_equal_list(podman._extra_args(user), args, [], "item")
+ def test_podman_extra_args(self, assert_equal, user, args, mock_pwd, podman):
+ assert_equal(podman._extra_args(user), args)
@pytest.mark.parametrize(
"user, exception",
@@ -182,7 +181,8 @@ class TestEngineOptions:
)
]
)
- def test_options(self, args, options, docker, podman, mock_pwd, tmp_path):
+ def test_options(self, assert_equal, args, options, docker, podman,
+ mock_pwd, tmp_path):
args["tempdir"] = tmp_path
uid, gid, _, workdir = get_pwuid(args.get("user"))[2:6]
template = [
@@ -204,18 +204,14 @@ class TestEngineOptions:
]
# test docker options
- assert_equal_list(
- docker._build_args(**args),
- template + extra_option + options,
- [], "item"
+ assert_equal(
+ docker._build_args(**args), template + extra_option + options
)
if args.get("user") == 1 or args.get("user") == "user":
options += id_mapping
# test podman options
- assert_equal_list(
- podman._build_args(**args),
- template + extra_option + options,
- [], "item"
+ assert_equal(
+ podman._build_args(**args), template + extra_option + options
)
diff --git a/tests/test_formatters.py b/tests/test_formatters.py
index 49b4a3c..b208f7b 100644
--- a/tests/test_formatters.py
+++ b/tests/test_formatters.py
@@ -40,51 +40,51 @@ layer_scenarios = [
@pytest.mark.parametrize("project,target,arch", scenarios)
-def test_dockerfiles(packages, projects, targets, project, target, arch, request):
+def test_dockerfiles(assert_equal, packages, projects, targets, project, target, arch, request):
gen = DockerfileFormatter(projects)
target_obj = BuildTarget(targets, packages, target, arch)
actual = gen.format(target_obj, [project])
expected_path = Path(test_utils.test_data_outdir(__file__), request.node.callspec.id + ".Dockerfile")
- test_utils.assert_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
@pytest.mark.parametrize("project,target,arch,base,layers", layer_scenarios)
-def test_dockerfile_layers(packages, projects, targets, project, target, arch, base, layers, request):
+def test_dockerfile_layers(assert_equal, packages, projects, targets, project, target, arch, base, layers, request):
gen = DockerfileFormatter(projects, base, layers)
target_obj = BuildTarget(targets, packages, target, arch)
actual = gen.format(target_obj, [project])
expected_path = Path(test_utils.test_data_outdir(__file__), request.node.callspec.id + ".Dockerfile")
- test_utils.assert_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
@pytest.mark.parametrize("project,target,arch", scenarios)
-def test_variables_shell(packages, projects, targets, project, target, arch, request):
+def test_variables_shell(assert_equal, packages, projects, targets, project, target, arch, request):
gen = ShellVariablesFormatter(projects)
target_obj = BuildTarget(targets, packages, target, arch)
actual = gen.format(target_obj, [project])
expected_path = Path(test_utils.test_data_outdir(__file__), request.node.callspec.id + ".vars")
- test_utils.assert_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
@pytest.mark.parametrize("project,target,arch", scenarios)
-def test_variables_json(packages, projects, targets, project, target, arch, request):
+def test_variables_json(assert_equal, packages, projects, targets, project, target, arch, request):
gen = JSONVariablesFormatter(projects)
target_obj = BuildTarget(targets, packages, target, arch)
actual = gen.format(target_obj, [project])
expected_path = Path(test_utils.test_data_outdir(__file__), request.node.callspec.id + ".json")
- test_utils.assert_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
@pytest.mark.parametrize("project,target,arch", scenarios)
-def test_prepbuildenv(packages, projects, targets, project, target, arch, request):
+def test_prepbuildenv(assert_equal, packages, projects, targets, project, target, arch, request):
gen = ShellBuildEnvFormatter(projects)
target_obj = BuildTarget(targets, packages, target, arch)
actual = gen.format(target_obj, [project])
expected_path = Path(test_utils.test_data_outdir(__file__), request.node.callspec.id + ".sh")
- test_utils.assert_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
-def test_all_projects_dockerfiles(packages, projects, targets):
+def test_all_projects_dockerfiles(assert_equal, packages, projects, targets):
all_projects = projects.names
for target in sorted(targets.targets):
@@ -98,4 +98,4 @@ def test_all_projects_dockerfiles(packages, projects, targets):
gen = DockerfileFormatter(projects)
actual = gen.format(target_obj, all_projects)
expected_path = Path(test_utils.test_data_outdir(__file__), f"{target}-all-projects.Dockerfile")
- test_utils.assert_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
diff --git a/tests/test_packages.py b/tests/test_packages.py
index 8947531..a7811f7 100644
--- a/tests/test_packages.py
+++ b/tests/test_packages.py
@@ -48,11 +48,11 @@ def test_project(projects):
Path(test_utils.test_data_indir(__file__), "packages.yml"))
-def test_verify_all_mappings_and_packages(packages):
+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())}
- test_utils.assert_yaml_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
native_params = [
@@ -66,7 +66,8 @@ cross_params = [
@pytest.mark.parametrize("target,arch", native_params + cross_params)
-def test_package_resolution(targets, packages, test_project, target, arch):
+def test_package_resolution(assert_equal, targets, packages, test_project,
+ target, arch,):
if arch is None:
outfile = f"{target}.yml"
else:
@@ -76,7 +77,7 @@ def test_package_resolution(targets, packages, test_project, target, arch):
pkgs = test_project.get_packages(target_obj)
actual = packages_as_dict(pkgs)
- test_utils.assert_yaml_matches_file(actual, expected_path)
+ assert_equal(actual, expected_path)
def test_resolution_override(targets, test_project):