[diffoscope] 05/05: tests: comparators: added test_containers.py

Juliana Oliveira R jwnx-guest at moszumanska.debian.org
Sat Sep 16 17:43:12 CEST 2017


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

jwnx-guest pushed a commit to branch jwnx_fix_different_container_type_comparison
in repository diffoscope.

commit 7ca74d2d37614bb514d932289c109b9a502be08e
Author: Juliana Oliveira Rodrigues <juliana.orod at gmail.com>
Date:   Sun Sep 10 22:18:44 2017 -0300

    tests: comparators: added test_containers.py
    
    This test file aims to check if Container objects are being compared
    properly. Initially only tar.bz2, tar.gz and tar.xz are being tested,
    but should be possible to extend to zip, rar.
---
 tests/comparators/test_containers.py               |  95 +++++++++++++++++++++
 tests/data/containers/a.tar.bz2                    | Bin 0 -> 348 bytes
 tests/data/containers/a.tar.gz                     | Bin 0 -> 335 bytes
 tests/data/containers/a.tar.xz                     | Bin 0 -> 404 bytes
 tests/data/containers/b.tar.bz2                    | Bin 0 -> 525 bytes
 tests/data/containers/b.tar.gz                     | Bin 0 -> 532 bytes
 tests/data/containers/b.tar.xz                     | Bin 0 -> 616 bytes
 .../different_files_expected_bzip2_xz_diff         |  45 ++++++++++
 .../different_files_expected_gzip_bzip2_diff       |  45 ++++++++++
 .../different_files_expected_gzip_bzip2_meta       |   3 +
 .../different_files_expected_gzip_xz_diff          |  45 ++++++++++
 .../different_files_expected_gzip_xz_meta          |   3 +
 .../containers/equal_files_expected_bzip_xz_diff   |   3 +
 .../equal_files_expected_gzip_bzip2_diff           |   3 +
 14 files changed, 242 insertions(+)

diff --git a/tests/comparators/test_containers.py b/tests/comparators/test_containers.py
new file mode 100644
index 0000000..662a106
--- /dev/null
+++ b/tests/comparators/test_containers.py
@@ -0,0 +1,95 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2017 Juliana Oliveira R <juliana.orod at gmail.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 shutil
+import pytest
+
+from ..utils.data import load_fixture, get_data
+
+gzip1 = load_fixture('containers/a.tar.gz')
+gzip2 = load_fixture('containers/b.tar.gz')
+
+xz1 = load_fixture('containers/a.tar.xz')
+xz2 = load_fixture('containers/b.tar.xz')
+
+bzip1 = load_fixture('containers/a.tar.bz2')
+bzip2 = load_fixture('containers/b.tar.bz2')
+
+ at pytest.fixture
+def differences_equal_gzip_xz(gzip1, xz1):
+    return gzip1.compare(xz1).details
+
+ at pytest.fixture
+def differences_equal_gzip_bzip2(gzip1, bzip1):
+    return gzip1.compare(bzip1).details
+
+ at pytest.fixture
+def differences_equal_bzip2_xz(bzip1, xz1):
+    return bzip1.compare(xz1).details
+
+ at pytest.fixture
+def differences_different_gzip_xz(gzip1, xz2):
+    return gzip1.compare(xz2).details
+
+ at pytest.fixture
+def differences_different_gzip_bzip2(gzip1, bzip2):
+    return gzip1.compare(bzip2).details
+
+ at pytest.fixture
+def differences_different_bzip2_xz(bzip1, xz2):
+    return bzip1.compare(xz2).details
+
+# Compares same content files, but with different extensions
+def test_equal_content_gzip_xz_diff(differences_equal_gzip_xz):
+    expected_diff = get_data('containers/equal_files_expected_bzip_xz_diff')
+    assert differences_equal_gzip_xz[0].unified_diff == expected_diff
+
+def test_equal_content_gzip_bzip2_diff(differences_equal_gzip_bzip2):
+    expected_diff = get_data('containers/equal_files_expected_gzip_bzip2_diff')
+    assert differences_equal_gzip_bzip2[0].unified_diff == expected_diff
+
+ at pytest.mark.skip(reason="Behavior not matching previous containers. Check needed.")
+def test_equal_content_bzip2_xz_diff(differences_equal_bzip2_xz):
+    assert differences_equal_bzip2_xz == []
+
+# Compares different content files with different extensions
+def test_different_content_gzip_xz_meta(differences_different_gzip_xz):
+    expected_diff = get_data('containers/different_files_expected_gzip_xz_meta')
+    assert differences_different_gzip_xz[0].unified_diff == expected_diff
+
+def test_different_content_gzip_xz_diff(differences_different_gzip_xz):
+    expected_diff = get_data('containers/different_files_expected_gzip_xz_diff')
+    assert differences_different_gzip_xz[1].details[1].unified_diff == expected_diff
+
+def test_different_content_gzip_bzip2_meta(differences_different_gzip_bzip2):
+    expected_diff = get_data('containers/different_files_expected_gzip_bzip2_meta')
+    assert differences_different_gzip_bzip2[0].unified_diff == expected_diff
+
+def test_different_content_gzip_bzip2_diff(differences_different_gzip_bzip2):
+    expected_diff = get_data('containers/different_files_expected_gzip_bzip2_diff')
+    assert differences_different_gzip_bzip2[1].details[1].unified_diff == expected_diff
+
+ at pytest.mark.skip(reason="Behavior not matching previous containers. Check needed.")
+def test_different_content_bzip2_xz_meta(differences_different_bzip2_xz):
+    expected_diff = get_data('containers/different_files_expected_bzip2_xz_meta')
+    assert differences_different_bzip2_xz[0].unified_diff == expected_diff
+
+def test_different_content_bzip2_xz_diff(differences_different_bzip2_xz):
+    expected_diff = get_data('containers/different_files_expected_bzip2_xz_diff')
+    assert differences_different_bzip2_xz[0].details[1].unified_diff == expected_diff
diff --git a/tests/data/containers/a.tar.bz2 b/tests/data/containers/a.tar.bz2
new file mode 100644
index 0000000..d117196
Binary files /dev/null and b/tests/data/containers/a.tar.bz2 differ
diff --git a/tests/data/containers/a.tar.gz b/tests/data/containers/a.tar.gz
new file mode 100644
index 0000000..d67cd19
Binary files /dev/null and b/tests/data/containers/a.tar.gz differ
diff --git a/tests/data/containers/a.tar.xz b/tests/data/containers/a.tar.xz
new file mode 100644
index 0000000..6c85ea9
Binary files /dev/null and b/tests/data/containers/a.tar.xz differ
diff --git a/tests/data/containers/b.tar.bz2 b/tests/data/containers/b.tar.bz2
new file mode 100644
index 0000000..f3888db
Binary files /dev/null and b/tests/data/containers/b.tar.bz2 differ
diff --git a/tests/data/containers/b.tar.gz b/tests/data/containers/b.tar.gz
new file mode 100644
index 0000000..e268938
Binary files /dev/null and b/tests/data/containers/b.tar.gz differ
diff --git a/tests/data/containers/b.tar.xz b/tests/data/containers/b.tar.xz
new file mode 100644
index 0000000..8447493
Binary files /dev/null and b/tests/data/containers/b.tar.xz differ
diff --git a/tests/data/containers/different_files_expected_bzip2_xz_diff b/tests/data/containers/different_files_expected_bzip2_xz_diff
new file mode 100644
index 0000000..e06800c
--- /dev/null
+++ b/tests/data/containers/different_files_expected_bzip2_xz_diff
@@ -0,0 +1,45 @@
+@@ -1,14 +1,32 @@
+-Cat's foot iron claw
+-Neuro-surgeons scream for more
+-At paranoia's poison door
+-Twenty first century schizoid man
++Living on a lighted stage
++Approaches the unreal
++For those who think and feel
++In touch with some reality
++Beyond the gilded cage
+ 
+-Blood rack barbed wire
+-Politicians' funeral pyre
+-Innocents raped with napalm fire
+-Twenty first century schizoid man
++Cast in this unlikely role
++Ill-equipped to act
++With insufficient tact
++One must put up barriers
++To keep oneself intact
+ 
+-Death seed blind man's greed
+-Poets' starving children bleed
+-Nothing he's got he really needs
+-Twenty first century schizoid man
++Living in the limelight
++The universal dream
++For those who wish to seem
++Those who wish to be
++Must put aside the alienation
++Get on with the fascination
++The real relation
++The underlying theme
++
++Living in a fish eye lens
++Caught in the camera eye
++I have no heart to lie
++I can't pretend a stranger
++Is a long-awaited friend
++
++All the world's indeed a stage
++And we are merely players
++Performers and portrayers
++Each another's audience
++Outside the gilded cage
diff --git a/tests/data/containers/different_files_expected_gzip_bzip2_diff b/tests/data/containers/different_files_expected_gzip_bzip2_diff
new file mode 100644
index 0000000..e06800c
--- /dev/null
+++ b/tests/data/containers/different_files_expected_gzip_bzip2_diff
@@ -0,0 +1,45 @@
+@@ -1,14 +1,32 @@
+-Cat's foot iron claw
+-Neuro-surgeons scream for more
+-At paranoia's poison door
+-Twenty first century schizoid man
++Living on a lighted stage
++Approaches the unreal
++For those who think and feel
++In touch with some reality
++Beyond the gilded cage
+ 
+-Blood rack barbed wire
+-Politicians' funeral pyre
+-Innocents raped with napalm fire
+-Twenty first century schizoid man
++Cast in this unlikely role
++Ill-equipped to act
++With insufficient tact
++One must put up barriers
++To keep oneself intact
+ 
+-Death seed blind man's greed
+-Poets' starving children bleed
+-Nothing he's got he really needs
+-Twenty first century schizoid man
++Living in the limelight
++The universal dream
++For those who wish to seem
++Those who wish to be
++Must put aside the alienation
++Get on with the fascination
++The real relation
++The underlying theme
++
++Living in a fish eye lens
++Caught in the camera eye
++I have no heart to lie
++I can't pretend a stranger
++Is a long-awaited friend
++
++All the world's indeed a stage
++And we are merely players
++Performers and portrayers
++Each another's audience
++Outside the gilded cage
diff --git a/tests/data/containers/different_files_expected_gzip_bzip2_meta b/tests/data/containers/different_files_expected_gzip_bzip2_meta
new file mode 100644
index 0000000..33e2cce
--- /dev/null
+++ b/tests/data/containers/different_files_expected_gzip_bzip2_meta
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix
++bzip2 compressed data, block size = 900k
diff --git a/tests/data/containers/different_files_expected_gzip_xz_diff b/tests/data/containers/different_files_expected_gzip_xz_diff
new file mode 100644
index 0000000..e06800c
--- /dev/null
+++ b/tests/data/containers/different_files_expected_gzip_xz_diff
@@ -0,0 +1,45 @@
+@@ -1,14 +1,32 @@
+-Cat's foot iron claw
+-Neuro-surgeons scream for more
+-At paranoia's poison door
+-Twenty first century schizoid man
++Living on a lighted stage
++Approaches the unreal
++For those who think and feel
++In touch with some reality
++Beyond the gilded cage
+ 
+-Blood rack barbed wire
+-Politicians' funeral pyre
+-Innocents raped with napalm fire
+-Twenty first century schizoid man
++Cast in this unlikely role
++Ill-equipped to act
++With insufficient tact
++One must put up barriers
++To keep oneself intact
+ 
+-Death seed blind man's greed
+-Poets' starving children bleed
+-Nothing he's got he really needs
+-Twenty first century schizoid man
++Living in the limelight
++The universal dream
++For those who wish to seem
++Those who wish to be
++Must put aside the alienation
++Get on with the fascination
++The real relation
++The underlying theme
++
++Living in a fish eye lens
++Caught in the camera eye
++I have no heart to lie
++I can't pretend a stranger
++Is a long-awaited friend
++
++All the world's indeed a stage
++And we are merely players
++Performers and portrayers
++Each another's audience
++Outside the gilded cage
diff --git a/tests/data/containers/different_files_expected_gzip_xz_meta b/tests/data/containers/different_files_expected_gzip_xz_meta
new file mode 100644
index 0000000..f281ee3
--- /dev/null
+++ b/tests/data/containers/different_files_expected_gzip_xz_meta
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix
++XZ compressed data
diff --git a/tests/data/containers/equal_files_expected_bzip_xz_diff b/tests/data/containers/equal_files_expected_bzip_xz_diff
new file mode 100644
index 0000000..f281ee3
--- /dev/null
+++ b/tests/data/containers/equal_files_expected_bzip_xz_diff
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix
++XZ compressed data
diff --git a/tests/data/containers/equal_files_expected_gzip_bzip2_diff b/tests/data/containers/equal_files_expected_gzip_bzip2_diff
new file mode 100644
index 0000000..33e2cce
--- /dev/null
+++ b/tests/data/containers/equal_files_expected_gzip_bzip2_diff
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix
++bzip2 compressed data, block size = 900k

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


More information about the diffoscope mailing list