test: factor out a tools_missing() function

parent c506dd2a
......@@ -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
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
def test_skip_unless_tools_exist_empty():
pytest.xfail("Test should always be skipped")
......@@ -36,9 +36,12 @@ from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
def 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),
reason="requires {}".format(" and ".join(required)),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment