[diffoscope] 01/03: test: factor out a tools_missing() function
Mattia Rizzolo
mattia at debian.org
Mon Aug 22 15:23:54 CEST 2016
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch master
in repository diffoscope.
commit 3b98ffebc65dd08b68180ad12e40adc1a795d6b7
Author: Mattia Rizzolo <mattia at debian.org>
Date: Mon Aug 22 12:02:51 2016 +0000
test: factor out a tools_missing() function
---
tests/comparators/test_utils.py | 8 +++++++-
tests/comparators/utils.py | 5 ++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tests/comparators/test_utils.py b/tests/comparators/test_utils.py
index fda5ae9..d723e7e 100644
--- a/tests/comparators/test_utils.py
+++ b/tests/comparators/test_utils.py
@@ -24,7 +24,7 @@ from diffoscope.config import Config
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils import tools_missing, skip_unless_tools_exist, data, load_fixture
try:
import tlsh # noqa
@@ -36,6 +36,12 @@ fuzzy_tar1 = load_fixture(data('fuzzy1.tar'))
fuzzy_tar2 = load_fixture(data('fuzzy2.tar'))
fuzzy_tar3 = load_fixture(data('fuzzy3.tar'))
+def test_tools_missing():
+ assert tools_missing() is True
+ assert tools_missing('/missing') is True
+ for x in ['cat', 'sh']:
+ assert tools_missing(x) is False
+
@skip_unless_tools_exist()
def test_skip_unless_tools_exist_empty():
pytest.xfail("Test should always be skipped")
diff --git a/tests/comparators/utils.py b/tests/comparators/utils.py
index 5a18cfb..d9e01a7 100644
--- a/tests/comparators/utils.py
+++ b/tests/comparators/utils.py
@@ -36,9 +36,12 @@ from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
def set_locale():
diffoscope.set_locale()
+def tools_missing(*required):
+ return not required or any(find_executable(x) is None for x in required)
+
def skip_unless_tools_exist(*required):
return pytest.mark.skipif(
- not required or any(find_executable(x) is None for x in required),
+ tools_missing(*required),
reason="requires {}".format(" and ".join(required)),
)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list