[diffoscope] 02/04: Rewrite lenghy "[..] skipIf [..] tool_missing" with @skip_unless_tool_exists.

Chris Lamb chris at chris-lamb.co.uk
Sat Aug 20 21:29:54 CEST 2016


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

lamby pushed a commit to branch master
in repository diffoscope.

commit 80f9244e812a28187c5be5a7e35674caf02e84ec
Author: Chris Lamb <lamby at debian.org>
Date:   Sat Aug 20 19:37:57 2016 +0100

    Rewrite lenghy "[..] skipIf [..] tool_missing" with @skip_unless_tool_exists.
---
 tests/comparators/conftest.py      |  8 +++++---
 tests/comparators/test_binary.py   | 10 +++++-----
 tests/comparators/test_bzip2.py    | 10 +++++-----
 tests/comparators/test_cbfs.py     | 14 +++++++-------
 tests/comparators/test_cpio.py     | 10 +++++-----
 tests/comparators/test_dex.py      | 14 +++++++-------
 tests/comparators/test_elf.py      | 16 ++++++++--------
 tests/comparators/test_epub.py     |  6 +++---
 tests/comparators/test_fonts.py    |  6 +++---
 tests/comparators/test_fsimage.py  |  8 ++++----
 tests/comparators/test_gettext.py  |  8 ++++----
 tests/comparators/test_haskell.py  |  6 +++---
 tests/comparators/test_icc.py      |  6 +++---
 tests/comparators/test_image.py    |  6 +++---
 tests/comparators/test_iso9660.py  | 12 ++++++------
 tests/comparators/test_java.py     |  6 +++---
 tests/comparators/test_macho.py    |  6 +++---
 tests/comparators/test_mono.py     |  6 +++---
 tests/comparators/test_pdf.py      | 11 ++++-------
 tests/comparators/test_png.py      |  6 +++---
 tests/comparators/test_ppu.py      |  8 ++++----
 tests/comparators/test_ps.py       |  8 ++++----
 tests/comparators/test_rlib.py     |  4 ++--
 tests/comparators/test_rpm.py      | 10 +++++-----
 tests/comparators/test_sqlite.py   |  6 +++---
 tests/comparators/test_squashfs.py | 10 +++++-----
 tests/comparators/test_utils.py    |  4 ++--
 tests/comparators/test_xz.py       | 10 +++++-----
 tests/comparators/test_zip.py      | 14 +++++++-------
 29 files changed, 124 insertions(+), 125 deletions(-)

diff --git a/tests/comparators/conftest.py b/tests/comparators/conftest.py
index 8b083ad..d8ea3e6 100644
--- a/tests/comparators/conftest.py
+++ b/tests/comparators/conftest.py
@@ -30,9 +30,11 @@ from distutils.version import StrictVersion
 def set_locale():
     diffoscope.set_locale()
 
-
-def tool_missing(cmd):
-    return find_executable(cmd) is None
+def skip_unless_tool_exists(*alternatives):
+    return pytest.mark.skipif(
+        not any(find_executable(x) for x in alternatives),
+        reason="missing {}".format(" or ".join(alternatives)),
+    )
 
 def data(filename):
     return os.path.join(
diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py
index 37d7ea2..8e51ede 100644
--- a/tests/comparators/test_binary.py
+++ b/tests/comparators/test_binary.py
@@ -28,7 +28,7 @@ from diffoscope.difference import Difference
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import File, FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('binary1')
 TEST_FILE2_PATH = data('binary2')
@@ -69,7 +69,7 @@ def test_no_differences_with_xxd(binary1):
     difference = binary1.compare_bytes(binary1)
     assert difference is None
 
- at pytest.mark.skipif(tool_missing('xxd'), reason='missing xxd')
+ at skip_unless_tool_exists('xxd')
 def test_compare_with_xxd(binary1, binary2):
     difference = binary1.compare_bytes(binary2)
     expected_diff = open(data('binary_expected_diff')).read()
@@ -102,7 +102,7 @@ def test_with_compare_details():
     difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE2_PATH), source='source')
     assert difference.details[0] == d
 
- at pytest.mark.skipif(tool_missing('xxd'), reason='missing xxd')
+ at skip_unless_tool_exists('xxd')
 def test_with_compare_details_and_fallback():
     class MockFile(FilesystemFile):
         def compare_details(self, other, source=None):
@@ -119,7 +119,7 @@ def test_with_compare_details_and_no_actual_differences():
     difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE1_PATH))
     assert difference is None
 
- at pytest.mark.skipif(tool_missing('xxd'), reason='missing xxd')
+ at skip_unless_tool_exists('xxd')
 def test_with_compare_details_and_failed_process():
     output = 'Free Jeremy Hammond'
     class MockFile(FilesystemFile):
@@ -132,7 +132,7 @@ def test_with_compare_details_and_failed_process():
     assert '42' in difference.comment
     assert difference.unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('xxd'), reason='missing xxd')
+ at skip_unless_tool_exists('xxd')
 def test_with_compare_details_and_tool_not_found(monkeypatch):
     monkeypatch.setattr('diffoscope.exc.RequiredToolNotFound.get_package', lambda _: 'some-package')
     class MockFile(FilesystemFile):
diff --git a/tests/comparators/test_bzip2.py b/tests/comparators/test_bzip2.py
index 34fe575..ad53a0a 100644
--- a/tests/comparators/test_bzip2.py
+++ b/tests/comparators/test_bzip2.py
@@ -25,7 +25,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.bzip2 import Bzip2File
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.bz2')
 TEST_FILE2_PATH = data('test2.bz2')
@@ -50,12 +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')
+ at skip_unless_tool_exists('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')
+ at skip_unless_tool_exists('bzip2')
 def test_content_source_without_extension(tmpdir):
     path1 = str(tmpdir.join('test1'))
     path2 = str(tmpdir.join('test2'))
@@ -67,12 +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')
+ at skip_unless_tool_exists('bzip2')
 def test_content_diff(differences):
     expected_diff = open(data('text_ascii_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('bzip2'), reason='missing bzip2')
+ at skip_unless_tool_exists('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_cbfs.py b/tests/comparators/test_cbfs.py
index 400216a..f27cdaf 100644
--- a/tests/comparators/test_cbfs.py
+++ b/tests/comparators/test_cbfs.py
@@ -27,7 +27,7 @@ from diffoscope.presenters.text import output_text
 from diffoscope.comparators.cbfs import CbfsFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('text_ascii1')
 TEST_FILE2_PATH = data('text_ascii2')
@@ -55,15 +55,15 @@ def rom2(tmpdir):
         f.write(buf[:-4])
     return specialize(FilesystemFile(path))
 
- at pytest.mark.skipif(tool_missing('cbfstool'), reason='missing cbfstool')
+ at skip_unless_tool_exists('cbfstool')
 def test_identification_using_offset(rom1):
     assert isinstance(rom1, CbfsFile)
 
- at pytest.mark.skipif(tool_missing('cbfstool'), reason='missing cbfstool')
+ at skip_unless_tool_exists('cbfstool')
 def test_identification_without_offset(rom2):
     assert isinstance(rom2, CbfsFile)
 
- at pytest.mark.skipif(tool_missing('cbfstool'), reason='missing cbfstool')
+ at skip_unless_tool_exists('cbfstool')
 def test_no_differences(rom1):
     difference = rom1.compare(rom1)
     assert difference is None
@@ -74,19 +74,19 @@ def differences(rom1, rom2):
     output_text(difference, print_func=print)
     return difference.details
 
- at pytest.mark.skipif(tool_missing('cbfstool'), reason='missing cbfstool')
+ at skip_unless_tool_exists('cbfstool')
 def test_listing(differences):
     expected_diff = open(data('cbfs_listing_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('cbfstool'), reason='missing cbfstool')
+ at skip_unless_tool_exists('cbfstool')
 def test_content(differences):
     assert differences[1].source1 == 'text'
     assert differences[1].source2 == 'text'
     expected_diff = open(data('text_ascii_expected_diff')).read()
     assert differences[1].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('cbfstool'), reason='missing cbfstool')
+ at skip_unless_tool_exists('cbfstool')
 def test_compare_non_existing(monkeypatch, rom1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = rom1.compare(NonExistingFile('/nonexisting', rom1))
diff --git a/tests/comparators/test_cpio.py b/tests/comparators/test_cpio.py
index 139d4a1..dfcb977 100644
--- a/tests/comparators/test_cpio.py
+++ b/tests/comparators/test_cpio.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.cpio import CpioFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.cpio')
 TEST_FILE2_PATH = data('test2.cpio')
@@ -48,26 +48,26 @@ def test_no_differences(cpio1):
 def differences(cpio1, cpio2):
     return cpio1.compare(cpio2).details
 
- at pytest.mark.skipif(tool_missing('cpio'), reason='missing cpio')
+ at skip_unless_tool_exists('cpio')
 def test_listing(differences):
     expected_diff = open(data('cpio_listing_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('cpio'), reason='missing cpio')
+ at skip_unless_tool_exists('cpio')
 def test_symlink(differences):
     assert differences[1].source1 == 'dir/link'
     assert differences[1].comment == 'symlink'
     expected_diff = open(data('symlink_expected_diff')).read()
     assert differences[1].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('cpio'), reason='missing cpio')
+ at skip_unless_tool_exists('cpio')
 def test_compressed_files(differences):
     assert differences[2].source1 == 'dir/text'
     assert differences[2].source2 == 'dir/text'
     expected_diff = open(data('text_ascii_expected_diff')).read()
     assert differences[2].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('cpio'), reason='missing cpio')
+ at skip_unless_tool_exists('cpio')
 def test_compare_non_existing(monkeypatch, cpio1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = cpio1.compare(NonExistingFile('/nonexisting', cpio1))
diff --git a/tests/comparators/test_dex.py b/tests/comparators/test_dex.py
index 54f19e7..ede2fff 100644
--- a/tests/comparators/test_dex.py
+++ b/tests/comparators/test_dex.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.dex import DexFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.dex')
 TEST_FILE2_PATH = data('test2.dex')
@@ -48,9 +48,9 @@ def test_no_differences(dex1):
 def differences(dex1, dex2):
     return dex1.compare(dex2).details
 
- at pytest.mark.skipif(tool_missing('enjarify'), reason='missing enjarify')
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zipinfo')
- at pytest.mark.skipif(tool_missing('javap'), reason='missing javap')
+ at skip_unless_tool_exists('enjarify')
+ at skip_unless_tool_exists('zipinfo')
+ at skip_unless_tool_exists('javap')
 def test_differences(differences):
     assert differences[0].source1 == 'test1.jar'
     assert differences[0].source2 == 'test2.jar'
@@ -64,9 +64,9 @@ def test_differences(differences):
     found_diff = zipinfo.unified_diff + classdiff.details[0].unified_diff
     assert expected_diff == found_diff
 
- at pytest.mark.skipif(tool_missing('enjarify'), reason='missing enjarify')
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zipinfo')
- at pytest.mark.skipif(tool_missing('javap'), reason='missing javap')
+ at skip_unless_tool_exists('enjarify')
+ at skip_unless_tool_exists('zipinfo')
+ at skip_unless_tool_exists('javap')
 def test_compare_non_existing(monkeypatch, dex1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = dex1.compare(NonExistingFile('/nonexisting', dex1))
diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py
index 2d47050..2fccff0 100644
--- a/tests/comparators/test_elf.py
+++ b/tests/comparators/test_elf.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+#, reason='missing zipinfo') -*- coding: utf-8 -*-
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
@@ -27,7 +27,7 @@ from diffoscope.comparators.elf import ElfFile, StaticLibFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.directory import FilesystemDirectory
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 try:
     import diffoscope.comparators.debian # noqa
@@ -57,14 +57,14 @@ 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')
+ at skip_unless_tool_exists('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'
     assert len(difference.details) > 0
 
- at pytest.mark.skipif(tool_missing('readelf'), reason='missing readelf')
+ at skip_unless_tool_exists('readelf')
 def test_diff(obj_differences):
     assert len(obj_differences) == 1
     expected_diff = open(data('elf_obj_expected_diff')).read()
@@ -92,7 +92,7 @@ def test_lib_no_differences(lib1):
 def lib_differences(lib1, lib2):
     return lib1.compare(lib2).details
 
- at pytest.mark.skipif(tool_missing('readelf') or tool_missing('objdump'), reason='missing readelf or objdump')
+ at skip_unless_tool_exists('readelf', 'objdump')
 def test_lib_differences(lib_differences):
     assert len(lib_differences) == 2
     assert lib_differences[0].source1 == 'file list'
@@ -102,7 +102,7 @@ def test_lib_differences(lib_differences):
     expected_objdump_diff = open(data('elf_lib_objdump_expected_diff')).read()
     assert lib_differences[1].unified_diff == expected_objdump_diff
 
- at pytest.mark.skipif(tool_missing('readelf') or tool_missing('objdump'), reason='missing readelf')
+ at skip_unless_tool_exists('readelf', 'objdump')
 def test_lib_compare_non_existing(monkeypatch, lib1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = lib1.compare(NonExistingFile('/nonexisting', lib1))
@@ -126,7 +126,7 @@ def dbgsym_dir2():
 def dbgsym_differences(dbgsym_dir1, dbgsym_dir2):
     return dbgsym_dir1.compare(dbgsym_dir2)
 
- at pytest.mark.skipif(any([tool_missing(tool) for tool in ['readelf', 'objdump', 'objcopy']]), reason='missing readelf, objdump, or objcopy')
+ at skip_unless_tool_exists('readelf', 'objdump', 'objcopy')
 @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed')
 def test_differences_with_dbgsym(dbgsym_differences):
     output_text(dbgsym_differences, print)
@@ -136,7 +136,7 @@ def test_differences_with_dbgsym(dbgsym_differences):
     assert bin_details.details[1].source1.startswith('objdump')
     assert 'test-cases/dbgsym/package/test.c:2' in bin_details.details[1].unified_diff
 
- at pytest.mark.skipif(any([tool_missing(tool) for tool in ['readelf', 'objdump', 'objcopy']]), reason='missing readelf, objdump, or objcopy')
+ at skip_unless_tool_exists('readelf', 'objdump', 'objcopy')
 @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed')
 def test_original_gnu_debuglink(dbgsym_differences):
     bin_details = dbgsym_differences.details[2].details[0].details[0]
diff --git a/tests/comparators/test_epub.py b/tests/comparators/test_epub.py
index 9526954..091683c 100644
--- a/tests/comparators/test_epub.py
+++ b/tests/comparators/test_epub.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.zip import ZipFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.epub')
 TEST_FILE2_PATH = data('test2.epub')
@@ -48,7 +48,7 @@ def test_no_differences(epub1):
 def differences(epub1, epub2):
     return epub1.compare(epub2).details
 
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
+ at skip_unless_tool_exists('zipinfo')
 def test_differences(differences):
     assert differences[0].source1 == 'zipinfo {}'
     assert differences[0].source2 == 'zipinfo {}'
@@ -61,7 +61,7 @@ def test_differences(differences):
     expected_diff = open(data('epub_expected_diffs')).read()
     assert expected_diff == "".join(map(lambda x: x.unified_diff, differences))
 
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
+ at skip_unless_tool_exists('zipinfo')
 def test_compare_non_existing(monkeypatch, epub1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = epub1.compare(NonExistingFile('/nonexisting', epub1))
diff --git a/tests/comparators/test_fonts.py b/tests/comparators/test_fonts.py
index 17a8ded..eb89123 100644
--- a/tests/comparators/test_fonts.py
+++ b/tests/comparators/test_fonts.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.fonts import TtfFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('Samyak-Malayalam1.ttf')
 TEST_FILE2_PATH = data('Samyak-Malayalam2.ttf')
@@ -48,12 +48,12 @@ def test_no_differences(ttf1):
 def differences(ttf1, ttf2):
     return ttf1.compare(ttf2).details
 
- at pytest.mark.skipif(tool_missing('showttf'), reason='missing showttf')
+ at skip_unless_tool_exists('showttf')
 def test_diff(differences):
     expected_diff = open(data('ttf_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('showttf'), reason='missing showttf')
+ at skip_unless_tool_exists('showttf')
 def test_compare_non_existing(monkeypatch, ttf1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = ttf1.compare(NonExistingFile('/nonexisting', ttf1))
diff --git a/tests/comparators/test_fsimage.py b/tests/comparators/test_fsimage.py
index ad41fd3..65ceeb8 100644
--- a/tests/comparators/test_fsimage.py
+++ b/tests/comparators/test_fsimage.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.fsimage import FsImageFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 try:
     import guestfs
@@ -58,7 +58,7 @@ def test_identification(img1):
     assert isinstance(img1, FsImageFile)
 
 @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system')
- at pytest.mark.skipif(tool_missing('qemu-img'), reason='missing qemu-img')
+ at skip_unless_tool_exists('qemu-img')
 @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing')
 def test_no_differences(img1):
     difference = img1.compare(img1)
@@ -69,7 +69,7 @@ def differences(img1, img2):
     return img1.compare(img2).details
 
 @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system')
- at pytest.mark.skipif(tool_missing('qemu-img'), reason='missing qemu-img')
+ at skip_unless_tool_exists('qemu-img')
 @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing')
 def test_differences(differences):
     assert differences[0].source1 == 'test1.ext4.tar'
@@ -87,7 +87,7 @@ def test_differences(differences):
     assert expected_diff == found_diff
 
 @pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system')
- at pytest.mark.skipif(tool_missing('qemu-img'), reason='missing qemu-img')
+ at skip_unless_tool_exists('qemu-img')
 @pytest.mark.skipif(miss_guestfs, reason='guestfs is missing')
 def test_compare_non_existing(monkeypatch, img1):
     monkeypatch.setattr(Config.general, 'new_file', True)
diff --git a/tests/comparators/test_gettext.py b/tests/comparators/test_gettext.py
index b399e61..d54aa90 100644
--- a/tests/comparators/test_gettext.py
+++ b/tests/comparators/test_gettext.py
@@ -25,7 +25,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.gettext import MoFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.mo')
 TEST_FILE2_PATH = data('test2.mo')
@@ -49,7 +49,7 @@ def test_no_differences(mo1):
 def differences(mo1, mo2):
     return mo1.compare(mo2).details
 
- at pytest.mark.skipif(tool_missing('msgunfmt'), reason='missing msgunfmt')
+ at skip_unless_tool_exists('msgunfmt')
 def test_diff(differences):
     expected_diff = open(data('mo_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
@@ -62,13 +62,13 @@ def mo_no_charset():
 def mo_iso8859_1():
     return specialize(FilesystemFile(data('test_iso8859-1.mo')))
 
- at pytest.mark.skipif(tool_missing('msgunfmt'), reason='missing msgunfmt')
+ at skip_unless_tool_exists('msgunfmt')
 def test_charsets(mo_no_charset, mo_iso8859_1):
     difference = mo_no_charset.compare(mo_iso8859_1)
     expected_diff = codecs.open(data('mo_charsets_expected_diff'), encoding='utf-8').read()
     assert difference.details[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('msgunfmt'), reason='missing msgunfmt')
+ at skip_unless_tool_exists('msgunfmt')
 def test_compare_non_existing(monkeypatch, mo1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = mo1.compare(NonExistingFile('/nonexisting', mo1))
diff --git a/tests/comparators/test_haskell.py b/tests/comparators/test_haskell.py
index 63e7803..6c42a46 100644
--- a/tests/comparators/test_haskell.py
+++ b/tests/comparators/test_haskell.py
@@ -23,7 +23,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.haskell import HiFile
 
-from conftest import data, tool_missing
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.hi')
 TEST_FILE2_PATH = data('test2.hi')
@@ -36,7 +36,7 @@ def haskell1():
 def haskell2():
     return specialize(FilesystemFile(TEST_FILE2_PATH))
 
- at pytest.mark.skipif(tool_missing('ghc'), reason='missing ghc')
+ at skip_unless_tool_exists('ghc')
 def test_identification(haskell1):
     assert isinstance(haskell1, HiFile)
 
@@ -47,7 +47,7 @@ def test_no_differences(haskell1):
 def differences(haskell1, haskell2):
     return haskell1.compare(haskell2).details
 
- at pytest.mark.skipif(tool_missing('ghc'), reason='missing ghc')
+ at skip_unless_tool_exists('ghc')
 def test_diff(differences):
     with open(data('haskell_expected_diff')) as f:
         expected_diff = f.read()
diff --git a/tests/comparators/test_icc.py b/tests/comparators/test_icc.py
index 080fc77..53c007a 100644
--- a/tests/comparators/test_icc.py
+++ b/tests/comparators/test_icc.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.icc import IccFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.icc')
 TEST_FILE2_PATH = data('test2.icc')
@@ -48,12 +48,12 @@ def test_no_differences(icc1):
 def differences(icc1, icc2):
     return icc1.compare(icc2).details
 
- at pytest.mark.skipif(tool_missing('cd-iccdump'), reason='missing cd-iccdump')
+ at skip_unless_tool_exists('cd-iccdump')
 def test_diff(differences):
     expected_diff = open(data('icc_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('cd-iccdump'), reason='missing cd-iccdump')
+ at skip_unless_tool_exists('cd-iccdump')
 def test_compare_non_existing(monkeypatch, icc1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = icc1.compare(NonExistingFile('/nonexisting', icc1))
diff --git a/tests/comparators/test_image.py b/tests/comparators/test_image.py
index c32dc36..0ff2f63 100644
--- a/tests/comparators/test_image.py
+++ b/tests/comparators/test_image.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.image import ImageFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.jpg')
 TEST_FILE2_PATH = data('test2.jpg')
@@ -48,12 +48,12 @@ def test_no_differences(image1):
 def differences(image1, image2):
     return image1.compare(image2).details
 
- at pytest.mark.skipif(tool_missing('img2txt'), reason='img2txt')
+ at skip_unless_tool_exists('img2txt')
 def test_diff(differences):
     expected_diff = open(data('image_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('img2txt'), reason='img2txt')
+ at skip_unless_tool_exists('img2txt')
 def test_compare_non_existing(monkeypatch, image1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = image1.compare(NonExistingFile('/nonexisting', image1))
diff --git a/tests/comparators/test_iso9660.py b/tests/comparators/test_iso9660.py
index 178e038..54bbfcd 100644
--- a/tests/comparators/test_iso9660.py
+++ b/tests/comparators/test_iso9660.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.iso9660 import Iso9660File
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.iso')
 TEST_FILE2_PATH = data('test2.iso')
@@ -48,30 +48,30 @@ def test_no_differences(iso1):
 def differences(iso1, iso2):
     return iso1.compare(iso2).details
 
- at pytest.mark.skipif(tool_missing('isoinfo'), reason='missing isoinfo')
+ at skip_unless_tool_exists('isoinfo')
 def test_iso9660_content(differences):
     expected_diff = open(data('iso9660_content_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('isoinfo'), reason='missing isoinfo')
+ at skip_unless_tool_exists('isoinfo')
 def test_iso9660_rockridge(differences):
     expected_diff = open(data('iso9660_rockridge_expected_diff')).read()
     assert differences[1].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('isoinfo'), reason='missing isoinfo')
+ at skip_unless_tool_exists('isoinfo')
 def test_symlink(differences):
     assert differences[3].comment == 'symlink'
     expected_diff = open(data('symlink_expected_diff')).read()
     assert differences[3].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('isoinfo'), reason='missing isoinfo')
+ at skip_unless_tool_exists('isoinfo')
 def test_compressed_files(differences):
     assert differences[2].source1 == 'text'
     assert differences[2].source2 == 'text'
     expected_diff = open(data('text_ascii_expected_diff')).read()
     assert differences[2].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('isoinfo'), reason='missing isoinfo')
+ at skip_unless_tool_exists('isoinfo')
 def test_compare_non_existing(monkeypatch, iso1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = iso1.compare(NonExistingFile('/nonexisting', iso1))
diff --git a/tests/comparators/test_java.py b/tests/comparators/test_java.py
index 254b2b2..1ead8c9 100644
--- a/tests/comparators/test_java.py
+++ b/tests/comparators/test_java.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.java import ClassFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('Test1.class')
 TEST_FILE2_PATH = data('Test2.class')
@@ -48,12 +48,12 @@ def test_no_differences(class1):
 def differences(class1, class2):
     return class1.compare(class2).details
 
- at pytest.mark.skipif(tool_missing('javap'), reason='missing javap')
+ at skip_unless_tool_exists('javap')
 def test_diff(differences):
     expected_diff = open(data('class_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('javap'), reason='missing javap')
+ at skip_unless_tool_exists('javap')
 def test_compare_non_existing(monkeypatch, class1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = class1.compare(NonExistingFile('/nonexisting', class1))
diff --git a/tests/comparators/test_macho.py b/tests/comparators/test_macho.py
index bb23561..1315145 100644
--- a/tests/comparators/test_macho.py
+++ b/tests/comparators/test_macho.py
@@ -26,7 +26,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.macho import MachoFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_OBJ1_PATH = data('test1.macho')
 TEST_OBJ2_PATH = data('test2.macho')
@@ -50,14 +50,14 @@ def test_obj_no_differences(obj1):
 def obj_differences(obj1, obj2):
     return obj1.compare(obj2).details
 
- at pytest.mark.skipif(tool_missing('otool') or tool_missing('lipo'), reason='missing otool or lipo')
+ at skip_unless_tool_exists('otool', 'lipo')
 def test_obj_compare_non_existing(monkeypatch, obj1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = obj1.compare(NonExistingFile('/nonexisting', obj1))
     assert difference.source2 == '/nonexisting'
     assert len(difference.details) > 0
 
- at pytest.mark.skipif(tool_missing('otool') or tool_missing('lipo'), reason='missing otool or lipo')
+ at skip_unless_tool_exists('otool', 'lipo')
 def test_diff(obj_differences):
     assert len(obj_differences) == 4
     l = ['macho_expected_diff_arch', 'macho_expected_diff_headers', 'macho_expected_diff_loadcommands', 'macho_expected_diff_disassembly']
diff --git a/tests/comparators/test_mono.py b/tests/comparators/test_mono.py
index 0afc1d0..ba42cbd 100644
--- a/tests/comparators/test_mono.py
+++ b/tests/comparators/test_mono.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.mono import MonoExeFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 # these were generated with:
 
@@ -53,12 +53,12 @@ def test_no_differences(exe1):
 def differences(exe1, exe2):
     return exe1.compare(exe2).details
 
- at pytest.mark.skipif(tool_missing('pedump'), reason='missing pedump')
+ at skip_unless_tool_exists('pedump')
 def test_diff(differences):
     expected_diff = open(data('pe_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('pedump'), reason='missing pedump')
+ at skip_unless_tool_exists('pedump')
 def test_compare_non_existing(monkeypatch, exe1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = exe1.compare(NonExistingFile('/nonexisting', exe1))
diff --git a/tests/comparators/test_pdf.py b/tests/comparators/test_pdf.py
index 18c1463..c9e69e2 100644
--- a/tests/comparators/test_pdf.py
+++ b/tests/comparators/test_pdf.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.pdf import PdfFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.pdf')
 TEST_FILE2_PATH = data('test2.pdf')
@@ -48,20 +48,17 @@ def test_no_differences(pdf1):
 def differences(pdf1, pdf2):
     return pdf1.compare(pdf2).details
 
- at pytest.mark.skipif(tool_missing('pdftk') or tool_missing('pdftotext'),
-                    reason='missing pdftk or pdftotext')
+ at skip_unless_tool_exists('pdftk', 'pdftotext')
 def test_text_diff(differences):
     expected_diff = open(data('pdf_text_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('pdftk') or tool_missing('pdftotext'),
-                    reason='missing pdftk or pdftotext')
+ at skip_unless_tool_exists('pdftk', 'pdftotext')
 def test_internal_diff(differences):
     expected_diff = open(data('pdf_internal_expected_diff')).read()
     assert differences[1].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('pdftk') or tool_missing('pdftotext'),
-                    reason='missing pdftk or pdftotext')
+ at skip_unless_tool_exists('pdftk', 'pdftotext')
 def test_compare_non_existing(monkeypatch, pdf1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = pdf1.compare(NonExistingFile('/nonexisting', pdf1))
diff --git a/tests/comparators/test_png.py b/tests/comparators/test_png.py
index 4223cd7..a03a36f 100644
--- a/tests/comparators/test_png.py
+++ b/tests/comparators/test_png.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.png import PngFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.png')
 TEST_FILE2_PATH = data('test2.png')
@@ -48,12 +48,12 @@ def test_no_differences(png1):
 def differences(png1, png2):
     return png1.compare(png2).details
 
- at pytest.mark.skipif(tool_missing('sng'), reason='missing sng')
+ at skip_unless_tool_exists('sng')
 def test_diff(differences):
     expected_diff = open(data('png_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('sng'), reason='missing sng')
+ at skip_unless_tool_exists('sng')
 def test_compare_non_existing(monkeypatch, png1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = png1.compare(NonExistingFile('/nonexisting', png1))
diff --git a/tests/comparators/test_ppu.py b/tests/comparators/test_ppu.py
index 13ff3e1..dd5d27d 100644
--- a/tests/comparators/test_ppu.py
+++ b/tests/comparators/test_ppu.py
@@ -25,7 +25,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.ppu import PpuFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 # These test files were taken from two different builds of the Debian package
 # fp-units-castle-game-engine (version 5.1.1-2 on amd64) on the Debian
@@ -44,7 +44,7 @@ def file1():
 def file2():
     return specialize(FilesystemFile(TEST_FILE2_PATH))
 
- at pytest.mark.skipif(tool_missing('ppudump'), reason='missing ppudump')
+ at skip_unless_tool_exists('ppudump')
 def test_identification(file1):
     assert isinstance(file1, PpuFile)
 
@@ -56,13 +56,13 @@ def test_no_differences(file1):
 def differences(file1, file2):
     return file1.compare(file2).details
 
- at pytest.mark.skipif(tool_missing('ppudump'), reason='missing ppudump')
+ at skip_unless_tool_exists('ppudump')
 def test_diff(differences):
     print(differences[0].unified_diff)
     expected_diff = open(data('ppu_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('ppudump'), reason='missing ppudump')
+ at skip_unless_tool_exists('ppudump')
 def test_compare_non_existing(monkeypatch, file1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = file1.compare(NonExistingFile('/nonexisting', file1))
diff --git a/tests/comparators/test_ps.py b/tests/comparators/test_ps.py
index 43cb910..8e02723 100644
--- a/tests/comparators/test_ps.py
+++ b/tests/comparators/test_ps.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.ps import PsFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.ps')
 TEST_FILE2_PATH = data('test2.ps')
@@ -48,17 +48,17 @@ def test_no_differences(ps1):
 def differences(ps1, ps2):
     return ps1.compare(ps2)
 
- at pytest.mark.skipif(tool_missing('ps2ascii'), reason='missing ps2ascii')
+ at skip_unless_tool_exists('ps2ascii')
 def test_internal_diff(differences):
     expected_diff = open(data('ps_internal_expected_diff')).read()
     assert differences.unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('ps2ascii'), reason='missing ps2ascii')
+ at skip_unless_tool_exists('ps2ascii')
 def test_text_diff(differences):
     expected_diff = open(data('ps_text_expected_diff')).read()
     assert differences.details[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('ps2ascii'), reason='missing ps2ascii')
+ at skip_unless_tool_exists('ps2ascii')
 def test_compare_non_existing(monkeypatch, ps1):
     monkeypatch.setattr(Config, 'new_file', True)
     difference = ps1.compare(NonExistingFile('/nonexisting', ps1))
diff --git a/tests/comparators/test_rlib.py b/tests/comparators/test_rlib.py
index 5aafaa0..3d1d854 100644
--- a/tests/comparators/test_rlib.py
+++ b/tests/comparators/test_rlib.py
@@ -26,7 +26,7 @@ from diffoscope.comparators.ar import ArFile
 from diffoscope.comparators.utils import diff_ignore_line_numbers
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, tool_older_than, data
+from conftest import skip_unless_tool_exists, tool_older_than, data
 
 TEST_FILE1_PATH = data('test1.rlib')
 TEST_FILE2_PATH = data('test2.rlib')
@@ -69,7 +69,7 @@ def test_item2_rust_metadata_bin(differences):
     assert differences[2].source1 == 'rust.metadata.bin'
     assert differences[2].source2 == 'rust.metadata.bin'
 
- at pytest.mark.skipif(tool_missing('llvm-dis'), reason='missing llvm-dis')
+ at skip_unless_tool_exists('llvm-dis')
 @pytest.mark.skipif(tool_older_than(['llvm-config', '--version'], '3.8'), reason='llvm version too low')
 def test_item3_deflate_llvm_bitcode(differences):
     assert differences[3].source1 == 'alloc_system-d16b8f0e.0.bytecode.deflate'
diff --git a/tests/comparators/test_rpm.py b/tests/comparators/test_rpm.py
index 3fb7981..dec79d0 100644
--- a/tests/comparators/test_rpm.py
+++ b/tests/comparators/test_rpm.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 try:
     from diffoscope.comparators.rpm import RpmFile
@@ -56,14 +56,14 @@ def differences(rpm1, rpm2):
     return rpm1.compare(rpm2).details
 
 @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed')
- at pytest.mark.skipif(tool_missing('rpm2cpio'), reason='missing rpm2cpio')
+ at skip_unless_tool_exists('rpm2cpio')
 def test_header(differences):
     assert differences[0].source1 == 'header'
     expected_diff = open(data('rpm_header_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
 @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed')
- at pytest.mark.skipif(tool_missing('rpm2cpio'), reason='missing rpm2cpio')
+ at skip_unless_tool_exists('rpm2cpio')
 def test_listing(differences):
     assert differences[1].source1 == 'content'
     assert differences[1].details[0].source1 == 'file list'
@@ -71,7 +71,7 @@ def test_listing(differences):
     assert differences[1].details[0].unified_diff == expected_diff
 
 @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed')
- at pytest.mark.skipif(tool_missing('rpm2cpio'), reason='missing rpm2cpio')
+ at skip_unless_tool_exists('rpm2cpio')
 def test_content(differences):
     assert differences[1].source1 == 'content'
     assert differences[1].details[1].source1 == './dir/text'
@@ -79,7 +79,7 @@ def test_content(differences):
     assert differences[1].details[1].unified_diff == expected_diff
 
 @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed')
- at pytest.mark.skipif(tool_missing('rpm2cpio'), reason='missing rpm2cpio')
+ at skip_unless_tool_exists('rpm2cpio')
 def test_compare_non_existing(monkeypatch, rpm1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = rpm1.compare(NonExistingFile('/nonexisting', rpm1))
diff --git a/tests/comparators/test_sqlite.py b/tests/comparators/test_sqlite.py
index cc13aac..30602ea 100644
--- a/tests/comparators/test_sqlite.py
+++ b/tests/comparators/test_sqlite.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.sqlite import Sqlite3Database
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.sqlite3')
 TEST_FILE2_PATH = data('test2.sqlite3')
@@ -48,12 +48,12 @@ def test_no_differences(sqlite3db1):
 def differences(sqlite3db1, sqlite3db2):
     return sqlite3db1.compare(sqlite3db2).details
 
- at pytest.mark.skipif(tool_missing('sqlite3'), reason='missing sqlite3')
+ at skip_unless_tool_exists('sqlite3')
 def test_diff(differences):
     expected_diff = open(data('sqlite3_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('sqlite3'), reason='missing sqlite3')
+ at skip_unless_tool_exists('sqlite3')
 def test_compare_non_existing(monkeypatch, sqlite3db1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = sqlite3db1.compare(NonExistingFile('/nonexisting', sqlite3db1))
diff --git a/tests/comparators/test_squashfs.py b/tests/comparators/test_squashfs.py
index 70648d9..87e8119 100644
--- a/tests/comparators/test_squashfs.py
+++ b/tests/comparators/test_squashfs.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.squashfs import SquashfsFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.squashfs')
 TEST_FILE2_PATH = data('test2.squashfs')
@@ -53,25 +53,25 @@ def test_no_warnings(capfd, squashfs1, squashfs2):
 def differences(squashfs1, squashfs2):
     return squashfs1.compare(squashfs2).details
 
- at pytest.mark.skipif(tool_missing('unsquashfs'), reason='missing unsquashfs')
+ at skip_unless_tool_exists('unsquashfs')
 def test_superblock(differences):
     expected_diff = open(data('squashfs_superblock_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('unsquashfs'), reason='missing unsquashfs')
+ at skip_unless_tool_exists('unsquashfs')
 def test_symlink(differences):
     assert differences[2].comment == 'symlink'
     expected_diff = open(data('symlink_expected_diff')).read()
     assert differences[2].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('unsquashfs'), reason='missing unsquashfs')
+ at skip_unless_tool_exists('unsquashfs')
 def test_compressed_files(differences):
     assert differences[3].source1 == '/text'
     assert differences[3].source2 == '/text'
     expected_diff = open(data('text_ascii_expected_diff')).read()
     assert differences[3].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('unsquashfs'), reason='missing unsquashfs')
+ at skip_unless_tool_exists('unsquashfs')
 def test_compare_non_existing(monkeypatch, squashfs1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = squashfs1.compare(NonExistingFile('/nonexisting', squashfs1))
diff --git a/tests/comparators/test_utils.py b/tests/comparators/test_utils.py
index 36bb83a..bda40e2 100644
--- a/tests/comparators/test_utils.py
+++ b/tests/comparators/test_utils.py
@@ -26,7 +26,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.utils import Command
 from diffoscope.comparators.binary import FilesystemFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 try:
     import tlsh # noqa
@@ -86,7 +86,7 @@ def test_no_fuzzy_matching_new_file(monkeypatch, fuzzy_tar_in_tar1, fuzzy_tar_in
     assert difference.details[1].source2 == '/dev/null'
     assert difference.details[2].source1 == '/dev/null'
 
- at pytest.mark.skipif(tool_missing('tee'), reason='missing tee')
+ at skip_unless_tool_exists('tee')
 def test_trim_stderr_in_command():
     class FillStderr(Command):
         def cmdline(self):
diff --git a/tests/comparators/test_xz.py b/tests/comparators/test_xz.py
index b711df3..e229bba 100644
--- a/tests/comparators/test_xz.py
+++ b/tests/comparators/test_xz.py
@@ -25,7 +25,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.xz import XzFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.xz')
 TEST_FILE2_PATH = data('test2.xz')
@@ -49,12 +49,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')
+ at skip_unless_tool_exists('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')
+ at skip_unless_tool_exists('xz')
 def test_content_source_without_extension(tmpdir):
     path1 = str(tmpdir.join('test1'))
     path2 = str(tmpdir.join('test2'))
@@ -66,12 +66,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')
+ at skip_unless_tool_exists('xz')
 def test_content_diff(differences):
     expected_diff = open(data('text_ascii_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('xz'), reason='missing xz')
+ at skip_unless_tool_exists('xz')
 def test_compare_non_existing(monkeypatch, xz1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = xz1.compare(NonExistingFile('/nonexisting', xz1))
diff --git a/tests/comparators/test_zip.py b/tests/comparators/test_zip.py
index 04f858f..2dfba82 100644
--- a/tests/comparators/test_zip.py
+++ b/tests/comparators/test_zip.py
@@ -24,7 +24,7 @@ from diffoscope.comparators import specialize
 from diffoscope.comparators.zip import ZipFile, MozillaZipFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
-from conftest import tool_missing, data
+from conftest import skip_unless_tool_exists, data
 
 TEST_FILE1_PATH = data('test1.zip')
 TEST_FILE2_PATH = data('test2.zip')
@@ -48,19 +48,19 @@ def test_no_differences(zip1):
 def differences(zip1, zip2):
     return zip1.compare(zip2).details
 
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
+ at skip_unless_tool_exists('zipinfo')
 def test_metadata(differences):
     expected_diff = open(data('zip_zipinfo_expected_diff')).read()
     assert differences[0].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
+ at skip_unless_tool_exists('zipinfo')
 def test_compressed_files(differences):
     assert differences[1].source1 == 'dir/text'
     assert differences[1].source2 == 'dir/text'
     expected_diff = open(data('text_ascii_expected_diff')).read()
     assert differences[1].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
+ at skip_unless_tool_exists('zipinfo')
 def test_compare_non_existing(monkeypatch, zip1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = zip1.compare(NonExistingFile('/nonexisting', zip1))
@@ -89,21 +89,21 @@ def test_mozzip_no_differences(mozzip1):
 def mozzip_differences(mozzip1, mozzip2):
     return mozzip1.compare(mozzip2).details
 
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
+ at skip_unless_tool_exists('zipinfo')
 def test_mozzip_metadata(mozzip_differences):
     expected_diff = open(data('mozzip_zipinfo_expected_diff')).read()
     diff = mozzip_differences[0].unified_diff
     assert (diff.replace(TEST_MOZZIP1_PATH, 'test1.mozzip')
                 .replace(TEST_MOZZIP2_PATH, 'test2.mozzip')) == expected_diff
 
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
+ at skip_unless_tool_exists('zipinfo')
 def test_mozzip_compressed_files(mozzip_differences):
     assert mozzip_differences[1].source1 == 'dir/text'
     assert mozzip_differences[1].source2 == 'dir/text'
     expected_diff = open(data('text_ascii_expected_diff')).read()
     assert mozzip_differences[1].unified_diff == expected_diff
 
- at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
+ at skip_unless_tool_exists('zipinfo')
 def test_mozzip_compare_non_existing(monkeypatch, mozzip1):
     monkeypatch.setattr(Config.general, 'new_file', True)
     difference = mozzip1.compare(NonExistingFile('/nonexisting', mozzip1))

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


More information about the diffoscope mailing list