[diffoscope] 02/02: Importing submodules (ie. ``parent.child``) will attempt to import ``parent`` so we must catch that. (Closes: #854670)

Chris Lamb chris at chris-lamb.co.uk
Thu Feb 9 21:23:32 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 541de9e1f69f2fec5451584359c5f0c2aad1f172
Author: Chris Lamb <lamby at debian.org>
Date:   Fri Feb 10 09:22:55 2017 +1300

    Importing submodules (ie. ``parent.child``) will attempt to import ``parent`` so we must catch that. (Closes: #854670)
---
 tests/comparators/utils/tools.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/comparators/utils/tools.py b/tests/comparators/utils/tools.py
index 0b07a44..1e324cb 100644
--- a/tests/comparators/utils/tools.py
+++ b/tests/comparators/utils/tools.py
@@ -63,7 +63,12 @@ def get_supported_elf_formats():
 
 def skip_unless_module_exists(name):
     def module_exists(x):
-        return importlib.util.find_spec(x) is None
+        try:
+            return importlib.util.find_spec(x) is None
+        except ImportError:
+            # Probing for submodules (eg. ``debian.deb822``) will attempt to
+            # import ``debian`` so we must handle that failing.
+            return False
 
     return pytest.mark.skipif(
         module_exists(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