jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/433374 )
Change subject: [IMPR] use tools.has_module for checking installed modules ......................................................................
[IMPR] use tools.has_module for checking installed modules
Change-Id: I45388a056ae2e2c79950a6b34f14c71e11663ce0 --- M tests/script_tests.py 1 file changed, 5 insertions(+), 9 deletions(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py index cf539c1..22d1593 100644 --- a/tests/script_tests.py +++ b/tests/script_tests.py @@ -10,10 +10,7 @@ import os import sys
-from pywikibot.tools import ( - PY2, - StringTypes, -) +from pywikibot.tools import has_module, PY2, StringTypes
from tests import join_root_path, unittest_print from tests.aspects import (unittest, DefaultSiteTestCase, MetaTestCaseClass, @@ -49,11 +46,10 @@ """Detect whether all dependencies are installed.""" if script_name in script_deps: for package_name in script_deps[script_name]: - try: - __import__(package_name) - except ImportError as e: - unittest_print('%s depends on %s, which isnt available:\n%s' - % (script_name, package_name, e)) + if not has_module(package_name): + unittest_print( + "{} depends on {}, which isn't available" + .format(script_name, package_name)) return False return True
pywikibot-commits@lists.wikimedia.org