Commit b7fd746d authored by Stefan Behnel's avatar Stefan Behnel

Print test dependency versions to help with test failure debugging.

parent 9f03226c
......@@ -1843,12 +1843,34 @@ class MissingDependencyExcluder(object):
def __init__(self, deps):
# deps: { matcher func : module name }
self.exclude_matchers = []
for matcher, mod in deps.items():
for matcher, module_name in deps.items():
try:
__import__(mod)
module = __import__(module_name)
except ImportError:
self.exclude_matchers.append(string_selector(matcher))
print("Test dependency not found: '%s'" % module_name)
else:
version = self.find_dep_version(module_name, module)
print("Test dependency found: '%s' version %s" % (module_name, version))
self.tests_missing_deps = []
def find_dep_version(self, name, module):
try:
version = module.__version__
except AttributeError:
stdlib_dir = os.path.dirname(shutil.__file__) + os.sep
module_path = getattr(module, '__file__', stdlib_dir) # no __file__? => builtin stdlib module
if module_path.startswith(stdlib_dir):
# stdlib module
version = sys.version.partition(' ')[0]
elif '.' in name:
# incrementally look for a parent package with version
name = name.rpartition('.')[0]
return self.find_dep_version(name, __import__(name))
else:
version = '?.?'
return version
def __call__(self, testname, tags=None):
for matcher in self.exclude_matchers:
if matcher(testname, tags):
......
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