jenkins-bot has submitted this change and it was merged.
Change subject: Add ordereddict dependency for Python 2.6 ......................................................................
Add ordereddict dependency for Python 2.6
For Python2.6, add dependency on the ordereddict module in setup.py, and report an error in pwb.py and tests.__init__ if the ordereddict module is not available.
Change-Id: I09388eee1ceccd9d95c34fef4dbd2e3d421c162c --- M pwb.py M setup.py M tests/__init__.py 3 files changed, 36 insertions(+), 0 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py index c8f0cf8..31a585a 100644 --- a/pwb.py +++ b/pwb.py @@ -125,6 +125,15 @@ "Try running 'git submodule update --init'.") sys.exit(1)
+if sys.version_info[0] == 2 and sys.version_info[1] == 6: + try: + import ordereddict + except ImportError as e: + print("ImportError: %s" % e) + print("pywikibot depends on module ordereddict in Python 2.6.") + print("Upgrade to Python 2.7, or run 'pip install ordereddict'") + sys.exit(1) + if "PYWIKIBOT2_DIR" not in os.environ: os.environ["PYWIKIBOT2_DIR"] = os.path.split(__file__)[0]
diff --git a/setup.py b/setup.py index 6682b3f..4dfcbce 100644 --- a/setup.py +++ b/setup.py @@ -42,6 +42,7 @@ test_deps.append('unittest2') script_deps['replicate_wiki.py'] = ['argparse'] testcollector = "tests.utils.collector" + dependencies.append('ordereddict')
if sys.version_info[0] == 3: if not os.environ.get('PY3', False): diff --git a/tests/__init__.py b/tests/__init__.py index a7fc7fc..6f85ad7 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -7,6 +7,32 @@ __version__ = '$Id$'
import os +import sys + +# Verify that the unit tests have a base working environment: +# - httplib2 is mandatory +# - ordereddict is only needed as a fallback for python 2.6 +# - mwparserfromhell is optional, so is only imported in textlib_tests +try: + import httplib2 +except ImportError as e: + print("ImportError: %s" % e) + sys.exit(1) + +try: + from collections import OrderedDict +except ImportError: + try: + from ordereddict import OrderedDict + except ImportError as e: + print("ImportError: %s" % e) + if sys.version_info[0] == 2 and sys.version_info[1] == 6: + print( + "pywikibot depends on module ordereddict in Python 2.6.\n" + "Run 'pip install ordereddict' to run these tests under " + "Python 2.6") + sys.exit(1) + import pywikibot.data.api from pywikibot.data.api import Request as _original_Request from pywikibot.data.api import CachedRequest