[diffoscope] 03/03: Fix and add test for meaningless "1234-content" metadata when introspecting files within archives. This was a regression since #854723 due to the use of auto-incrementing on-disk filenames. (Closes: #858223)

Chris Lamb chris at chris-lamb.co.uk
Sun Mar 19 23:57:56 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch experimental
in repository diffoscope.

commit 3b6050bf80a68de72909055e429c99e61f3c11ea
Author: Chris Lamb <lamby at debian.org>
Date:   Sun Mar 19 22:57:24 2017 +0000

    Fix and add test for meaningless "1234-content" metadata when introspecting files within archives. This was a regression since #854723 due to the use of auto-incrementing on-disk filenames. (Closes: #858223)
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/comparators/utils/archive.py |   2 +-
 tests/comparators/test_archive.py       |  34 ++++++++++++++++++++++++++++++++
 tests/data/archive1.tar                 | Bin 0 -> 10240 bytes
 tests/data/archive2.tar                 | Bin 0 -> 10240 bytes
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/diffoscope/comparators/utils/archive.py b/diffoscope/comparators/utils/archive.py
index 00ee6a6..510dff0 100644
--- a/diffoscope/comparators/utils/archive.py
+++ b/diffoscope/comparators/utils/archive.py
@@ -72,7 +72,7 @@ class Archive(Container, metaclass=abc.ABCMeta):
         return ArchiveMember(self, member_name)
 
     def get_compressed_content_name(self, expected_extension):
-        basename = os.path.basename(self.source.path)
+        basename = os.path.basename(self.source.name)
 
         if not basename.endswith(expected_extension):
             return "%s-content" % basename
diff --git a/tests/comparators/test_archive.py b/tests/comparators/test_archive.py
new file mode 100644
index 0000000..89d3eb3
--- /dev/null
+++ b/tests/comparators/test_archive.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2017 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# diffoscope is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
+
+import pytest
+
+from utils.data import load_fixture
+
+
+archive1 = load_fixture('archive1.tar')
+archive2 = load_fixture('archive2.tar')
+
+ at pytest.fixture
+def differences(archive1, archive2):
+    return archive1.compare(archive2).details
+
+def test_compressed_content_name(differences):
+    assert differences[1].details[1].source1 == 'compressed'
+    assert differences[1].details[1].source2 == 'compressed'
diff --git a/tests/data/archive1.tar b/tests/data/archive1.tar
new file mode 100644
index 0000000..d9103cd
Binary files /dev/null and b/tests/data/archive1.tar differ
diff --git a/tests/data/archive2.tar b/tests/data/archive2.tar
new file mode 100644
index 0000000..78c1fd3
Binary files /dev/null and b/tests/data/archive2.tar differ

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list