[Git][reproducible-builds/diffoscope][master] Actually test 7z support in the test_7z set of tests, not the lz4...

Chris Lamb (@lamby) gitlab at salsa.debian.org
Fri Mar 1 16:29:58 UTC 2024



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
529d0ae3 by Chris Lamb at 2024-03-01T16:29:21+00:00
Actually test 7z support in the test_7z set of tests, not the lz4 functionality. (Closes: reproducible-builds/diffoscope#359)

We also needed to rename the 7z.zip module to sevenz.py so it was actually
importable in regular Python code. Thanks to Vagrant Cascadian for spotting
this and for pointing it out so cordially. :)

- - - - -


6 changed files:

- diffoscope/comparators/__init__.py
- diffoscope/comparators/7z.py → diffoscope/comparators/sevenz.py
- tests/comparators/test_7z.py → tests/comparators/test_sevenz.py
- + tests/data/test1.disk.gz
- + tests/data/test2.disk.gz
- + tests/data/text_sevenzmetadata_expected_diff


Changes:

=====================================
diffoscope/comparators/__init__.py
=====================================
@@ -3,7 +3,7 @@
 #
 # Copyright © 2014-2015 Jérémy Bobbio <lunar at debian.org>
 # Copyright ©      2015  Helmut Grohne <helmut at subdivi.de>
-# Copyright © 2015-2023 Chris Lamb <lamby at debian.org>
+# Copyright © 2015-2024 Chris Lamb <lamby at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -75,7 +75,7 @@ class ComparatorManager:
         ("ffprobe.FfprobeFile",),
         ("gnumeric.GnumericFile",),
         ("gzip.GzipFile",),
-        ("7z.SevenZFile",),
+        ("sevenz.SevenZFile",),
         ("haskell.HiFile",),
         ("icc.IccFile",),
         ("iso9660.Iso9660File",),


=====================================
diffoscope/comparators/7z.py → diffoscope/comparators/sevenz.py
=====================================
@@ -1,7 +1,7 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2023 Chris Lamb <lamby at debian.org>
+# Copyright © 2024 Chris Lamb <lamby at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by


=====================================
tests/comparators/test_7z.py → tests/comparators/test_sevenz.py
=====================================
@@ -1,7 +1,7 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2023 Chris Lamb <lamby at debian.org>
+# Copyright © 2024 Chris Lamb <lamby at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -19,7 +19,8 @@
 import shutil
 import pytest
 
-from diffoscope.comparators.lz4 import Lz4File
+from diffoscope.comparators.gzip import GzipFile
+from diffoscope.comparators.sevenz import SevenZFile
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
@@ -27,48 +28,51 @@ from ..utils.data import load_fixture, assert_diff
 from ..utils.tools import skip_unless_tools_exist
 from ..utils.nonexisting import assert_non_existing
 
-lz4a = load_fixture("test1.lz4")
-lz4b = load_fixture("test2.lz4")
+sevenza = load_fixture("test1.disk.gz")
+sevenzb = load_fixture("test2.disk.gz")
 
 
-def test_identification(lz4a):
-    assert isinstance(lz4a, Lz4File)
+def test_identification(sevenza):
+    assert isinstance(sevenza, GzipFile)
 
 
-def test_no_differences(lz4a):
-    difference = lz4a.compare(lz4a)
+def test_no_differences(sevenza):
+    difference = sevenza.compare(sevenza)
     assert difference is None
 
 
 @pytest.fixture
-def differences(lz4a, lz4b):
-    return lz4a.compare(lz4b).details
+def differences(sevenza, sevenzb):
+    return sevenza.compare(sevenzb).details
 
 
 @skip_unless_tools_exist("lz4")
 def test_content_source(differences):
-    assert differences[0].source1 == "test1"
-    assert differences[0].source2 == "test2"
+    # We gzip our test data image, so we need to go one level deeper.
+    assert differences[0].source1 == "test1.disk"
+    assert differences[0].source2 == "test2.disk"
+    assert differences[0].details[0].source1 == "7z l"
+    assert differences[0].details[0].source2 == "7z l"
 
 
 @skip_unless_tools_exist("lz4")
-def test_content_source_without_extension(tmpdir, lz4a, lz4b):
+def test_content_source_without_extension(tmpdir, sevenza, sevenzb):
     path1 = str(tmpdir.join("test1"))
     path2 = str(tmpdir.join("test2"))
-    shutil.copy(lz4a.path, path1)
-    shutil.copy(lz4b.path, path2)
-    lz4a = specialize(FilesystemFile(path1))
-    lz4b = specialize(FilesystemFile(path2))
-    difference = lz4a.compare(lz4b).details
+    shutil.copy(sevenza.path, path1)
+    shutil.copy(sevenzb.path, path2)
+    sevenza = specialize(FilesystemFile(path1))
+    sevenzb = specialize(FilesystemFile(path2))
+    difference = sevenza.compare(sevenzb).details
     assert difference[0].source1 == "test1-content"
     assert difference[0].source2 == "test2-content"
 
 
 @skip_unless_tools_exist("lz4")
-def test_content_diff(differences):
-    assert_diff(differences[0], "text_ascii_expected_diff")
+def test_metadata_diff(differences):
+    assert_diff(differences[0].details[0], "text_sevenzmetadata_expected_diff")
 
 
 @skip_unless_tools_exist("lz4")
-def test_compare_non_existing(monkeypatch, lz4a):
-    assert_non_existing(monkeypatch, lz4a)
+def test_compare_non_existing(monkeypatch, sevenza):
+    assert_non_existing(monkeypatch, sevenza)


=====================================
tests/data/test1.disk.gz
=====================================
Binary files /dev/null and b/tests/data/test1.disk.gz differ


=====================================
tests/data/test2.disk.gz
=====================================
Binary files /dev/null and b/tests/data/test2.disk.gz differ


=====================================
tests/data/text_sevenzmetadata_expected_diff
=====================================
@@ -0,0 +1,15 @@
+@@ -5,13 +5,13 @@
+ Scanning the drive for archives:
+ 1 file, 131072 bytes (128 KiB)
+ 
+ 
+ --
+ Type = GPT
+ Physical Size = 131072
+-ID = BEFEFA22-EED4-4977-8407-46CD48ABC5D9
++ID = A2E15781-E1B6-422C-BA65-9210D36BE3AA
+ 
+    Date      Time    Attr         Size   Compressed  Name
+ ------------------- ----- ------------ ------------  ------------------------
+ ------------------- ----- ------------ ------------  ------------------------
+                                      0            0  0 files



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/529d0ae3308749eb4de0d80f6ce4f51ea66b4012

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/529d0ae3308749eb4de0d80f6ce4f51ea66b4012
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20240301/b8068875/attachment.htm>


More information about the rb-commits mailing list