Skip to content
Snippets Groups Projects
Commit 529d0ae3 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Actually test 7z support in the test_7z set of tests, not the lz4...

Actually test 7z support in the test_7z set of tests, not the lz4 functionality. (Closes: #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. :)
parent 18b86bc7
No related branches found
No related tags found
No related merge requests found
Pipeline #647030 failed
......@@ -3,7 +3,7 @@
#
# Copyright © 2014-2015 Jérémy Bobbio <lunar@debian.org>
# Copyright © 2015 Helmut Grohne <helmut@subdivi.de>
# Copyright © 2015-2023 Chris Lamb <lamby@debian.org>
# Copyright © 2015-2024 Chris Lamb <lamby@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: in-depth comparison of files, archives, and directories
#
# Copyright © 2023 Chris Lamb <lamby@debian.org>
# Copyright © 2024 Chris Lamb <lamby@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
......
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2023 Chris Lamb <lamby@debian.org>
# Copyright © 2024 Chris Lamb <lamby@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)
File added
File added
@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment