[Reproducible-commits] [diffoscope] 05/07: Properly skip tests when the required tools are not available
Jérémy Bobbio
lunar at moszumanska.debian.org
Thu Nov 12 14:34:05 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 397bff50d813e9579cb8cdf49a1e4085f201c839
Author: Jérémy Bobbio <lunar at debian.org>
Date: Wed Nov 11 14:11:47 2015 +0100
Properly skip tests when the required tools are not available
---
tests/comparators/test_binary.py | 5 +++++
tests/comparators/test_cpio.py | 5 +++++
tests/comparators/test_epub.py | 1 +
tests/comparators/test_gettext.py | 4 ++++
tests/comparators/test_iso9660.py | 1 +
tests/comparators/test_java.py | 3 +++
tests/comparators/test_rpm.py | 1 +
tests/comparators/test_squashfs.py | 1 +
tests/comparators/test_zip.py | 1 +
9 files changed, 22 insertions(+)
diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py
index 680afe9..1174465 100644
--- a/tests/comparators/test_binary.py
+++ b/tests/comparators/test_binary.py
@@ -25,6 +25,7 @@ import diffoscope.comparators.binary
from diffoscope.comparators.binary import File, FilesystemFile, NonExistingFile
from diffoscope.difference import Difference
from diffoscope import RequiredToolNotFound, tool_required
+from conftest import tool_missing
TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/binary1')
TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/binary2')
@@ -65,6 +66,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')
def test_compare_with_xxd(binary1, binary2):
difference = binary1.compare_bytes(binary2)
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/binary_expected_diff')).read()
@@ -97,6 +99,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')
def test_with_compare_details_and_fallback():
class MockFile(FilesystemFile):
def compare_details(self, other, source=None):
@@ -113,6 +116,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')
def test_with_compare_details_and_failed_process():
output = 'Free Jeremy Hammond'
class MockFile(FilesystemFile):
@@ -125,6 +129,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')
def test_with_compare_details_and_tool_not_found(monkeypatch):
monkeypatch.setattr('diffoscope.RequiredToolNotFound.get_package', lambda _: 'some-package')
class MockFile(FilesystemFile):
diff --git a/tests/comparators/test_cpio.py b/tests/comparators/test_cpio.py
index 44ab085..7fc0853 100644
--- a/tests/comparators/test_cpio.py
+++ b/tests/comparators/test_cpio.py
@@ -23,6 +23,7 @@ from diffoscope.comparators import specialize
from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
from diffoscope.comparators.cpio import CpioFile
from diffoscope.config import Config
+from conftest import tool_missing
TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.cpio')
TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.cpio')
@@ -46,22 +47,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')
def test_listing(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/cpio_listing_expected_diff')).read()
assert differences[0].unified_diff == expected_diff
+ at pytest.mark.skipif(tool_missing('cpio'), reason='missing cpio')
def test_symlink(differences):
assert differences[1].source1 == 'dir/link'
assert differences[1].comment == 'symlink'
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/symlink_expected_diff')).read()
assert differences[1].unified_diff == expected_diff
+ at pytest.mark.skipif(tool_missing('cpio'), reason='missing cpio')
def test_compressed_files(differences):
assert differences[2].source1 == 'dir/text'
assert differences[2].source2 == 'dir/text'
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
assert differences[2].unified_diff == expected_diff
+ at pytest.mark.skipif(tool_missing('cpio'), reason='missing 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_epub.py b/tests/comparators/test_epub.py
index aa34e6f..7216617 100644
--- a/tests/comparators/test_epub.py
+++ b/tests/comparators/test_epub.py
@@ -60,6 +60,7 @@ def test_differences(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../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')
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_gettext.py b/tests/comparators/test_gettext.py
index 32bde78..e6fa8b7 100644
--- a/tests/comparators/test_gettext.py
+++ b/tests/comparators/test_gettext.py
@@ -24,6 +24,7 @@ from diffoscope.comparators import specialize
from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
from diffoscope.comparators.gettext import MoFile
from diffoscope.config import Config
+from conftest import tool_missing
TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.mo')
TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.mo')
@@ -47,6 +48,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')
def test_diff(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/mo_expected_diff')).read()
assert differences[0].unified_diff == expected_diff
@@ -59,11 +61,13 @@ def mo_no_charset():
def mo_iso8859_1():
return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/test_iso8859-1.mo')))
+ at pytest.mark.skipif(tool_missing('msgunfmt'), reason='missing msgunfmt')
def test_charsets(mo_no_charset, mo_iso8859_1):
difference = mo_no_charset.compare(mo_iso8859_1)
expected_diff = codecs.open(os.path.join(os.path.dirname(__file__), '../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')
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_iso9660.py b/tests/comparators/test_iso9660.py
index ba076a0..5d5fa6d 100644
--- a/tests/comparators/test_iso9660.py
+++ b/tests/comparators/test_iso9660.py
@@ -70,6 +70,7 @@ def test_compressed_files(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
assert differences[3].unified_diff == expected_diff
+ at pytest.mark.skipif(tool_missing('isoinfo'), reason='missing 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 46043bb..29f5949 100644
--- a/tests/comparators/test_java.py
+++ b/tests/comparators/test_java.py
@@ -23,6 +23,7 @@ from diffoscope.comparators import specialize
from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
from diffoscope.comparators.java import ClassFile
from diffoscope.config import Config
+from conftest import tool_missing
TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/Test1.class')
TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/Test2.class')
@@ -46,10 +47,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')
def test_diff(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/class_expected_diff')).read()
assert differences[0].unified_diff == expected_diff
+ at pytest.mark.skipif(tool_missing('javap'), reason='missing 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_rpm.py b/tests/comparators/test_rpm.py
index 5cc8d84..5e9a715 100644
--- a/tests/comparators/test_rpm.py
+++ b/tests/comparators/test_rpm.py
@@ -77,6 +77,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')
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_squashfs.py b/tests/comparators/test_squashfs.py
index c38dd15..25a3fc8 100644
--- a/tests/comparators/test_squashfs.py
+++ b/tests/comparators/test_squashfs.py
@@ -78,6 +78,7 @@ def test_compressed_files(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
assert differences[3].unified_diff == expected_diff
+ at pytest.mark.skipif(tool_missing('unsquashfs'), reason='missing 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_zip.py b/tests/comparators/test_zip.py
index 0dd75d1..d921b79 100644
--- a/tests/comparators/test_zip.py
+++ b/tests/comparators/test_zip.py
@@ -59,6 +59,7 @@ def test_compressed_files(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
assert differences[1].unified_diff == expected_diff
+ at pytest.mark.skipif(tool_missing('zipinfo'), reason='missing zip')
def test_compare_non_existing(monkeypatch, zip1):
monkeypatch.setattr(Config.general, 'new_file', True)
difference = zip1.compare(NonExistingFile('/nonexisting', zip1))
--
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