[diffoscope] 08/09: Change the tests for nested containers so they reflect the latest changes.
Maria Glukhova
siamezzze-guest at moszumanska.debian.org
Mon Feb 13 20:39:59 CET 2017
This is an automated email from the git hooks/post-receive script.
siamezzze-guest pushed a commit to branch siamezzze/containers
in repository diffoscope.
commit 313dc77d3fd7028541d82f4af6a8d34d6ddd47cb
Author: Maria Glukhova <siamezzze at gmail.com>
Date: Mon Feb 13 15:07:39 2017 +0200
Change the tests for nested containers so they reflect the latest changes.
Change and expand the tests for containers -- test different
types and different levels of nested containers.
---
tests/comparators/test_containers.py | 76 ++++++++++++++++-----
.../data/nested_containers_filelist_expected_diff | 16 +++--
.../data/nested_containers_filelist_expected_diff1 | 5 ++
.../data/nested_containers_filelist_expected_diff2 | 8 +++
tests/data/nested_containers_types_expected_diff | 2 +-
tests/data/nested_containers_types_expected_diff1 | 3 +
tests/data/nested_containers_types_expected_diff2 | 3 +
tests/data/test1.tar.bz2 | Bin 986 -> 0 bytes
tests/data/test1.tar.gz | Bin 1000 -> 518 bytes
tests/data/test2.zip.bz2 | Bin 0 -> 822 bytes
10 files changed, 87 insertions(+), 26 deletions(-)
diff --git a/tests/comparators/test_containers.py b/tests/comparators/test_containers.py
index d9de749..fbc8c67 100644
--- a/tests/comparators/test_containers.py
+++ b/tests/comparators/test_containers.py
@@ -19,19 +19,14 @@
import pytest
-try:
- import tlsh
- tlsh_found = True
-except ImportError:
- tlsh_found = False
-
from diffoscope.comparators.utils.compare import compare_files
-from utils.data import data, load_fixture
+from utils.data import data, load_fixture, get_data
from utils.tools import skip_unless_tools_exist
test_tar_gz = load_fixture('test1.tar.gz')
-test_zip_bz2 = load_fixture('test1.tar.bz2')
+test_zip_bz2 = load_fixture('test2.zip.bz2')
+test_zip = load_fixture('test2.zip')
test_tar = load_fixture('test3.tar')
test_cpio = load_fixture('test3.cpio')
@@ -43,6 +38,10 @@ def differences_containers(test_tar, test_cpio):
def differences_nested(test_tar_gz, test_zip_bz2):
return compare_files(test_tar_gz, test_zip_bz2).details
+ at pytest.fixture
+def differences_different_levels(test_tar_gz, test_zip):
+ return compare_files(test_tar_gz, test_zip).details
+
@skip_unless_tools_exist('cpio')
def test_file_list(differences_containers):
expected_diff = open(data('containers_filelist_expected_diff')).read()
@@ -63,19 +62,60 @@ def test_content(differences_containers):
assert differences_containers[2].unified_diff == expected_diff
@skip_unless_tools_exist('bzip2', 'gzip', 'zipinfo')
- at pytest.mark.skipif(not tlsh_found, reason='tlsh is missing')
def test_types_nested(differences_nested):
- expected_diff = \
- open(data('nested_containers_types_expected_diff')).read()
+ expected_diff = get_data('nested_containers_types_expected_diff')
assert differences_nested[0].source1 == 'container type'
assert differences_nested[0].source2 == 'container type'
assert differences_nested[0].unified_diff == expected_diff
- at skip_unless_tools_exist('bzip2', 'gzip')
- at pytest.mark.skipif(not tlsh_found, reason='tlsh is missing')
+ at skip_unless_tools_exist('bzip2', 'gzip', 'zipinfo')
+def test_types_nested1(differences_nested):
+ expected_diff1 = get_data('nested_containers_types_expected_diff1')
+ assert differences_nested[2].details[0].source1 == 'container type'
+ assert differences_nested[2].details[0].source2 == 'container type'
+ assert differences_nested[2].details[0].unified_diff == expected_diff1
+
+ at skip_unless_tools_exist('bzip2', 'gzip', 'zipinfo')
+def test_file_list_nested(differences_nested):
+ expected_diff = get_data('nested_containers_filelist_expected_diff')
+ assert differences_nested[1].source1 == 'file list'
+ assert differences_nested[1].source2 == 'file list'
+ assert differences_nested[1].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('bzip2', 'gzip', 'zipinfo')
def test_file_list_nested2(differences_nested):
- expected_diff = \
- open(data('nested_containers_filelist_expected_diff')).read()
- assert differences_nested[1].details[0].source1 == 'file list'
- assert differences_nested[1].details[0].source2 == 'file list'
- assert differences_nested[1].details[0].unified_diff == expected_diff
+ expected_diff = get_data('nested_containers_filelist_expected_diff1')
+ assert differences_nested[2].details[1].source1 == 'file list'
+ assert differences_nested[2].details[1].source2 == 'file list'
+ assert differences_nested[2].details[1].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('bzip2', 'gzip', 'zipinfo')
+def test_content_diff_nested(differences_nested):
+ expected_diff = get_data('text_ascii_expected_diff')
+ assert differences_nested[2].details[2].source1 == 'dir/text'
+ assert differences_nested[2].details[2].source2 == 'dir/text'
+ assert differences_nested[2].details[2].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('gzip', 'zipinfo')
+def test_types_different_levels(differences_different_levels):
+ f = open(data('nested_containers_types_expected_diff2'), 'w')
+ f.write(differences_different_levels[0].unified_diff)
+ f.close()
+ expected_diff = get_data('nested_containers_types_expected_diff2')
+ assert differences_different_levels[0].source1 == 'container type'
+ assert differences_different_levels[0].source2 == 'container type'
+ assert differences_different_levels[0].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('gzip', 'zipinfo')
+def test_file_list_different_levels(differences_different_levels):
+ expected_diff = get_data('nested_containers_filelist_expected_diff2')
+ assert differences_different_levels[1].source1 == 'file list'
+ assert differences_different_levels[1].source2 == 'file list'
+ assert differences_different_levels[1].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('gzip', 'zipinfo')
+def test_content_diff_different_levels(differences_different_levels):
+ expected_diff = get_data('text_ascii_expected_diff')
+ assert differences_different_levels[2].source1 == 'dir/text'
+ assert differences_different_levels[2].source2 == 'dir/text'
+ assert differences_different_levels[2].unified_diff == expected_diff
diff --git a/tests/data/nested_containers_filelist_expected_diff b/tests/data/nested_containers_filelist_expected_diff
index 3d410a5..d972fb9 100644
--- a/tests/data/nested_containers_filelist_expected_diff
+++ b/tests/data/nested_containers_filelist_expected_diff
@@ -1,7 +1,9 @@
-@@ -1,5 +1,5 @@
- drwxr-xr-x 0 siamezzze (1000) siamezzze (1000) 0 2017-01-21 02:39:53.000000 t0/
- drwxr-xr-x 0 siamezzze (1000) siamezzze (1000) 0 2017-01-21 02:39:53.000000 t0/t00/
- -rw-r--r-- 0 siamezzze (1000) siamezzze (1000) 14 2017-01-21 02:39:53.000000 t0/t00/test2
- lrwxrwxrwx 0 siamezzze (1000) siamezzze (1000) 0 2017-01-21 02:39:53.000000 t0/test2.lnk -> t0/t00/test2
---rw-r--r-- 0 siamezzze (1000) siamezzze (1000) 1277 2017-01-21 02:39:53.000000 t0/test1
-+-rw-r--r-- 0 siamezzze (1000) siamezzze (1000) 1279 2017-01-21 02:39:53.000000 t0/test1
+@@ -1,5 +1,3 @@
+-test1.tar
+-[test1.tar] dir/
+-[test1.tar] dir/link
+-[test1.tar] dir/null
+-[test1.tar] dir/text
++test2.zip
++[test2.zip] dir/
++[test2.zip] dir/text
diff --git a/tests/data/nested_containers_filelist_expected_diff1 b/tests/data/nested_containers_filelist_expected_diff1
new file mode 100644
index 0000000..2701e53
--- /dev/null
+++ b/tests/data/nested_containers_filelist_expected_diff1
@@ -0,0 +1,5 @@
+@@ -1,4 +1,2 @@
+ dir/
+ dir/text
+-dir/null
+-dir/link
diff --git a/tests/data/nested_containers_filelist_expected_diff2 b/tests/data/nested_containers_filelist_expected_diff2
new file mode 100644
index 0000000..0e1321d
--- /dev/null
+++ b/tests/data/nested_containers_filelist_expected_diff2
@@ -0,0 +1,8 @@
+@@ -1,5 +1,2 @@
+-test1.tar
+-[test1.tar] dir/
+-[test1.tar] dir/link
+-[test1.tar] dir/null
+-[test1.tar] dir/text
++dir/
++dir/text
diff --git a/tests/data/nested_containers_types_expected_diff b/tests/data/nested_containers_types_expected_diff
index ee1acbe..35dba80 100644
--- a/tests/data/nested_containers_types_expected_diff
+++ b/tests/data/nested_containers_types_expected_diff
@@ -1,3 +1,3 @@
@@ -1 +1 @@
--gzip compressed data, was "test0.tar", last modified: Sat Jan 21 02:39:53 2017, from Unix
+-gzip compressed data, was "test1.tar", last modified: Tue Nov 8 19:44:06 2016, from Unix
+bzip2 compressed data, block size = 900k
diff --git a/tests/data/nested_containers_types_expected_diff1 b/tests/data/nested_containers_types_expected_diff1
new file mode 100644
index 0000000..192c410
--- /dev/null
+++ b/tests/data/nested_containers_types_expected_diff1
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-POSIX tar archive (GNU)
++Zip archive data, at least v1.0 to extract
diff --git a/tests/data/nested_containers_types_expected_diff2 b/tests/data/nested_containers_types_expected_diff2
new file mode 100644
index 0000000..44a2fb6
--- /dev/null
+++ b/tests/data/nested_containers_types_expected_diff2
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-gzip compressed data, was "test1.tar", last modified: Tue Nov 8 19:44:06 2016, from Unix
++Zip archive data, at least v1.0 to extract
diff --git a/tests/data/test1.tar.bz2 b/tests/data/test1.tar.bz2
deleted file mode 100644
index 8499693..0000000
Binary files a/tests/data/test1.tar.bz2 and /dev/null differ
diff --git a/tests/data/test1.tar.gz b/tests/data/test1.tar.gz
index 078af17..4e5a5f9 100644
Binary files a/tests/data/test1.tar.gz and b/tests/data/test1.tar.gz differ
diff --git a/tests/data/test2.zip.bz2 b/tests/data/test2.zip.bz2
new file mode 100644
index 0000000..a6d5969
Binary files /dev/null and b/tests/data/test2.zip.bz2 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