jenkins-bot merged this change.

View Change

Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
[IMPR] use tools.has_module for checking installed modules

Change-Id: I45388a056ae2e2c79950a6b34f14c71e11663ce0
---
M tests/script_tests.py
1 file changed, 5 insertions(+), 9 deletions(-)

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


To view, visit change 433374. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I45388a056ae2e2c79950a6b34f14c71e11663ce0
Gerrit-Change-Number: 433374
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot