[diffoscope] 01/03: Add a "skip_unless_module_exists" test decorator.
Chris Lamb
chris at chris-lamb.co.uk
Wed Feb 8 22:34:55 CET 2017
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit 4c70ea790c7c3a9415c6f5e999cf7c9af04fa2ec
Author: Chris Lamb <lamby at debian.org>
Date: Thu Feb 9 10:06:43 2017 +1300
Add a "skip_unless_module_exists" test decorator.
Signed-off-by: Chris Lamb <lamby at debian.org>
---
tests/comparators/utils/tools.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/comparators/utils/tools.py b/tests/comparators/utils/tools.py
index d949aa1..f0a0113 100644
--- a/tests/comparators/utils/tools.py
+++ b/tests/comparators/utils/tools.py
@@ -20,6 +20,7 @@
import pytest
import functools
+import importlib
import subprocess
from distutils.spawn import find_executable
@@ -59,3 +60,9 @@ def get_supported_elf_formats():
return set(subprocess.check_output(
('objdump', '--info'),
).decode('utf-8').splitlines())
+
+def skip_unless_module_exists(name):
+ return pytest.mark.skipif(
+ importlib.util.find_spec(name) is None,
+ reason="requires {} module".format(name),
+ )
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list