[Reproducible-commits] [diffoscope] 01/01: Also skip tests when very common tools are unavailable

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Nov 13 18:39:44 UTC 2015


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

lunar pushed a commit to branch master
in repository diffoscope.

commit 0685265a4886d0fb611113b18737411204d967a1
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Fri Nov 13 19:38:58 2015 +0100

    Also skip tests when very common tools are unavailable
---
 tests/comparators/test_bzip2.py | 5 +++++
 tests/comparators/test_deb.py   | 9 +++++++++
 tests/comparators/test_elf.py   | 5 +++++
 tests/comparators/test_xz.py    | 5 +++++
 4 files changed, 24 insertions(+)

diff --git a/tests/comparators/test_bzip2.py b/tests/comparators/test_bzip2.py
index de6f82a..6b0a9c2 100644
--- a/tests/comparators/test_bzip2.py
+++ b/tests/comparators/test_bzip2.py
@@ -24,6 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.bzip2 import Bzip2File
 from diffoscope.config import Config
+from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.bz2')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.bz2')
@@ -49,10 +50,12 @@ def test_no_differences(bzip1):
 def differences(bzip1, bzip2):
     return bzip1.compare(bzip2).details
 
+ at pytest.mark.skipif(tool_missing('bzip2'), reason='missing bzip2')
 def test_content_source(differences):
     assert differences[0].source1 == 'test1'
     assert differences[0].source2 == 'test2'
 
+ at pytest.mark.skipif(tool_missing('bzip2'), reason='missing bzip2')
 def test_content_source_without_extension(tmpdir):
     path1 = str(tmpdir.join('test1'))
     path2 = str(tmpdir.join('test2'))
@@ -64,10 +67,12 @@ def test_content_source_without_extension(tmpdir):
     assert differences[0].source1 == 'test1-content'
     assert differences[0].source2 == 'test2-content'
 
+ at pytest.mark.skipif(tool_missing('bzip2'), reason='missing bzip2')
 def test_content_diff(differences):
     expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
+ at pytest.mark.skipif(tool_missing('bzip2'), reason='missing bzip2')
 def test_compare_non_existing(monkeypatch, bzip1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = bzip1.compare(NonExistingFile('/nonexisting', bzip1))
diff --git a/tests/comparators/test_deb.py b/tests/comparators/test_deb.py
index 9ed4cea..b0a5790 100644
--- a/tests/comparators/test_deb.py
+++ b/tests/comparators/test_deb.py
@@ -24,6 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.deb import DebFile, Md5sumsFile, DebDataTarFile
 from diffoscope.config import Config
+from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.deb')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.deb')
@@ -47,10 +48,12 @@ def test_no_differences(deb1):
 def differences(deb1, deb2):
     return deb1.compare(deb2).details
 
+ at pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_metadata(differences):
     expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/deb_metadata_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
+ at pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_compressed_files(differences):
     assert differences[1].source1 == 'control.tar.gz'
     assert differences[2].source1 == 'data.tar.gz'
@@ -61,6 +64,7 @@ def test_identification_of_md5sums_outside_deb(tmpdir):
     f = specialize(FilesystemFile(path))
     assert type(f) is FilesystemFile
 
+ at pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_identification_of_md5sums_in_deb(deb1, deb2, monkeypatch):
     orig_func = Md5sumsFile.recognizes
     @staticmethod
@@ -74,14 +78,17 @@ def test_identification_of_md5sums_in_deb(deb1, deb2, monkeypatch):
     deb1.compare(deb2)
     assert test_identification_of_md5sums_in_deb.found
 
+ at pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_md5sums(differences):
     assert differences[1].details[0].details[1].comment == 'Files in package differs'
 
+ at pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_identical_files_in_md5sums(deb1, deb2):
     deb1.compare(deb2)
     assert deb1.files_with_same_content_in_data == set(['./usr/share/doc/test/README.Debian',
                                                         './usr/share/doc/test/copyright'])
 
+ at pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_identification_of_data_tar(deb1, deb2, monkeypatch):
     orig_func = DebDataTarFile.recognizes
     @staticmethod
@@ -95,6 +102,7 @@ def test_identification_of_data_tar(deb1, deb2, monkeypatch):
     deb1.compare(deb2)
     assert test_identification_of_data_tar.found
 
+ at pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_skip_comparison_of_known_identical_files(deb1, deb2, monkeypatch):
     compared = set()
     orig_func = diffoscope.comparators.compare_files
@@ -105,6 +113,7 @@ def test_skip_comparison_of_known_identical_files(deb1, deb2, monkeypatch):
     deb1.compare(deb2)
     assert './usr/share/doc/test/README.Debian' not in compared
 
+ at pytest.mark.skipif(tool_missing('ar'), reason='missing ar')
 def test_compare_non_existing(monkeypatch, deb1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = deb1.compare(NonExistingFile('/nonexisting', deb1))
diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py
index 2c227eb..33d6261 100644
--- a/tests/comparators/test_elf.py
+++ b/tests/comparators/test_elf.py
@@ -23,6 +23,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.elf import ElfFile, StaticLibFile
 from diffoscope.config import Config
+from conftest import tool_missing
 
 TEST_OBJ1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.o')
 TEST_OBJ2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.o')
@@ -46,11 +47,13 @@ def test_obj_no_differences(obj1):
 def obj_differences(obj1, obj2):
     return obj1.compare(obj2).details
 
+ at pytest.mark.skipif(tool_missing('readelf'), reason='missing readelf')
 def test_obj_compare_non_existing(monkeypatch, obj1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = obj1.compare(NonExistingFile('/nonexisting', obj1))
     assert difference.source2 == '/nonexisting'
 
+ at pytest.mark.skipif(tool_missing('readelf'), reason='missing readelf')
 def test_diff(obj_differences):
     assert len(obj_differences) == 1
     expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/elf_obj_expected_diff')).read()
@@ -78,6 +81,7 @@ def test_lib_no_differences(lib1):
 def lib_differences(lib1, lib2):
     return lib1.compare(lib2).details
 
+ at pytest.mark.skipif(tool_missing('readelf'), reason='missing readelf')
 def test_lib_differences(lib_differences):
     assert len(lib_differences) == 2
     assert lib_differences[0].source1 == 'metadata'
@@ -87,6 +91,7 @@ def test_lib_differences(lib_differences):
     expected_objdump_diff = open(os.path.join(os.path.dirname(__file__), '../data/elf_lib_objdump_expected_diff')).read()
     assert lib_differences[1].unified_diff == expected_objdump_diff
 
+ at pytest.mark.skipif(tool_missing('readelf'), reason='missing readelf')
 def test_lib_compare_non_existing(monkeypatch, lib1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = lib1.compare(NonExistingFile('/nonexisting', lib1))
diff --git a/tests/comparators/test_xz.py b/tests/comparators/test_xz.py
index d996fab..a940ffd 100644
--- a/tests/comparators/test_xz.py
+++ b/tests/comparators/test_xz.py
@@ -24,6 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.xz import XzFile
 from diffoscope.config import Config
+from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.xz')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.xz')
@@ -47,10 +48,12 @@ def test_no_differences(xz1):
 def differences(xz1, xz2):
     return xz1.compare(xz2).details
 
+ at pytest.mark.skipif(tool_missing('xz'), reason='missing xz')
 def test_content_source(differences):
     assert differences[0].source1 == 'test1'
     assert differences[0].source2 == 'test2'
 
+ at pytest.mark.skipif(tool_missing('xz'), reason='missing xz')
 def test_content_source_without_extension(tmpdir):
     path1 = str(tmpdir.join('test1'))
     path2 = str(tmpdir.join('test2'))
@@ -62,10 +65,12 @@ def test_content_source_without_extension(tmpdir):
     assert difference[0].source1 == 'test1-content'
     assert difference[0].source2 == 'test2-content'
 
+ at pytest.mark.skipif(tool_missing('xz'), reason='missing xz')
 def test_content_diff(differences):
     expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
+ at pytest.mark.skipif(tool_missing('xz'), reason='missing xz')
 def test_compare_non_existing(monkeypatch, xz1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = xz1.compare(NonExistingFile('/nonexisting', xz1))

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



More information about the Reproducible-commits mailing list