On Thu, Feb 09, 2017 at 05:45:35PM +0000, Iain Lane wrote: > On Thu, Feb 09, 2017 at 11:52:50AM +0100, Mattia Rizzolo wrote: > > E ImportError: No module named 'debian' > > Hmm, looks like skip_unless_module_exists() needs to catch the > exception. Patch attached - I don't like the "skip" variable, so if you > know of a nicer way (the function needs to return a callable so you > can't use mark.skip AFAICS) then please do it. > > The way I read the docs is that it should return None here; not sure why > it doesn't - bug in python?
No, it says "If name is for a submodule (contains a dot), the parent module is automatically imported." But that means my patch is a bit wrong - try this version. -- Iain Lane [ i...@orangesquash.org.uk ] Debian Developer [ la...@debian.org ] Ubuntu Developer [ la...@ubuntu.com ]
From 9d6214228e41adc5b120ff7c36563765fc0c2b21 Mon Sep 17 00:00:00 2001 From: Iain Lane <i...@orangesquash.org.uk> Date: Thu, 9 Feb 2017 17:36:36 +0000 Subject: [PATCH] tests: Catch ImportError when looking to see if a module is installed importlib.util.find_spec raises this exception when the module isn't there. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=854670 --- tests/comparators/utils/tools.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/comparators/utils/tools.py b/tests/comparators/utils/tools.py index f0a0113..d49e178 100644 --- a/tests/comparators/utils/tools.py +++ b/tests/comparators/utils/tools.py @@ -62,7 +62,13 @@ def get_supported_elf_formats(): ).decode('utf-8').splitlines()) def skip_unless_module_exists(name): + try: + found = importlib.util.find_spec(name) + skip = found is None + except ImportError: + skip = True + return pytest.mark.skipif( - importlib.util.find_spec(name) is None, + skip, reason="requires {} module".format(name), ) -- 2.10.2
signature.asc
Description: PGP signature
_______________________________________________ Reproducible-builds mailing list Reproducible-builds@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds