diff options
author | Erik Skultety <eskultet@redhat.com> | 2023-03-29 16:16:32 +0200 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2023-03-30 08:00:42 +0000 |
commit | bd9b208e36556d72e9ab68b603252aa79f1cf3f1 (patch) | |
tree | 2bbe98ceab4ab15231ccbd1ca1ad8d1f945981a4 | |
parent | cce2e7f910e93d45e11147648e973319532eab32 (diff) | |
download | libvirt-ci-bd9b208e36556d72e9ab68b603252aa79f1cf3f1.zip libvirt-ci-bd9b208e36556d72e9ab68b603252aa79f1cf3f1.tar.gz libvirt-ci-bd9b208e36556d72e9ab68b603252aa79f1cf3f1.tar.bz2 |
tests: manifest: Convert to assert_equal fixture usage
Unlike with the other tests, this wasn't a completely straightforward
conversion as the asserts are wrapped by multiple helpers which
naturally don't have access to fixtures, so we need to pass the fixture
over kwargs to the very leaf doing the actual equality check.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
-rw-r--r-- | tests/test_manifest.py | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/tests/test_manifest.py b/tests/test_manifest.py index c47201c..d3a44b5 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -14,7 +14,7 @@ from lcitool import util from lcitool.manifest import Manifest -def test_generate(targets, packages, projects, monkeypatch): +def test_generate(assert_equal, targets, packages, projects, monkeypatch): manifest_path = Path(test_utils.test_data_indir(__file__), "manifest.yml") # Squish the header that contains argv with paths we don't @@ -84,16 +84,14 @@ def test_generate(targets, packages, projects, monkeypatch): assert key in unlinks unlinks.remove(key) - def assert_write(filename): + def assert_write(filename, assert_func): actual_path = Path(filename) expected_path = Path(test_utils.test_data_outdir(__file__), filename) - test_utils.assert_matches_file(writes[actual_path.as_posix()], - expected_path, - allow_regenerate=False) + assert_func(writes[actual_path.as_posix()], expected_path) del writes[actual_path.as_posix()] - def assert_operations(): + def assert_operations(**kwargs): # Verify which directories we expect to be created assert_mkdir(Path("ci", "gitlab")) assert_mkdir(Path("ci", "containers")) @@ -105,27 +103,31 @@ def test_generate(targets, packages, projects, monkeypatch): assert_unlink(Path("ci", "containers", "almalinux-8.Dockerfile")) # Verify content of files we expect to be created - assert_write(Path("ci", "gitlab.yml")) - assert_write(Path("ci", "gitlab", "container-templates.yml")) - assert_write(Path("ci", "gitlab", "containers.yml")) - assert_write(Path("ci", "gitlab", "build-templates.yml")) - assert_write(Path("ci", "gitlab", "builds.yml")) - assert_write(Path("ci", "gitlab", "sanity-checks.yml")) - assert_write(Path("ci", "cirrus", "freebsd-current.vars")) - assert_write(Path("ci", "cirrus", "macos-12.vars")) - assert_write(Path("ci", "cirrus", "macos-13.vars")) - assert_write(Path("ci", "containers", "centos-stream-9.Dockerfile")) - assert_write(Path("ci", "containers", "fedora-rawhide.Dockerfile")) - assert_write(Path("ci", "containers", "fedora-rawhide-cross-mingw32.Dockerfile")) - assert_write(Path("ci", "containers", "debian-10.Dockerfile")) - assert_write(Path("ci", "containers", "debian-sid-cross-ppc64le.Dockerfile")) - assert_write(Path("ci", "containers", "debian-sid-cross-i686.Dockerfile")) - assert_write(Path("ci", "buildenv", "centos-stream-9.sh")) - assert_write(Path("ci", "buildenv", "fedora-rawhide.sh")) - assert_write(Path("ci", "buildenv", "fedora-rawhide-cross-mingw32.sh")) - assert_write(Path("ci", "buildenv", "debian-10.sh")) - assert_write(Path("ci", "buildenv", "debian-sid-cross-ppc64le.sh")) - assert_write(Path("ci", "buildenv", "debian-sid-cross-i686.sh")) + assert_writes = [ + Path("ci", "gitlab.yml"), + Path("ci", "gitlab", "container-templates.yml"), + Path("ci", "gitlab", "containers.yml"), + Path("ci", "gitlab", "build-templates.yml"), + Path("ci", "gitlab", "builds.yml"), + Path("ci", "gitlab", "sanity-checks.yml"), + Path("ci", "cirrus", "freebsd-current.vars"), + Path("ci", "cirrus", "macos-12.vars"), + Path("ci", "cirrus", "macos-13.vars"), + Path("ci", "containers", "centos-stream-9.Dockerfile"), + Path("ci", "containers", "fedora-rawhide.Dockerfile"), + Path("ci", "containers", "fedora-rawhide-cross-mingw32.Dockerfile"), + Path("ci", "containers", "debian-10.Dockerfile"), + Path("ci", "containers", "debian-sid-cross-ppc64le.Dockerfile"), + Path("ci", "containers", "debian-sid-cross-i686.Dockerfile"), + Path("ci", "buildenv", "centos-stream-9.sh"), + Path("ci", "buildenv", "fedora-rawhide.sh"), + Path("ci", "buildenv", "fedora-rawhide-cross-mingw32.sh"), + Path("ci", "buildenv", "debian-10.sh"), + Path("ci", "buildenv", "debian-sid-cross-ppc64le.sh"), + Path("ci", "buildenv", "debian-sid-cross-i686.sh"), + ] + for path in assert_writes: + assert_write(path, kwargs["assert_func"]) # Verify nothing else unexpected was created/deleted/written assert len(mkdirs) == 0 @@ -133,7 +135,7 @@ def test_generate(targets, packages, projects, monkeypatch): assert len(writes) == 0 try: - assert_operations() + assert_operations(assert_func=assert_equal) finally: if pytest.custom_args["regenerate_output"]: with open(manifest_path, "r") as fp: |