[PATCH 2 of 2 STABLE?] run-tests: use a try/importerror ladder instead of looking for a specific version

Augie Fackler raf at durin42.com
Mon Nov 10 13:09:08 CST 2014


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1415643656 18000
#      Mon Nov 10 13:20:56 2014 -0500
# Branch stable
# Node ID d7bf05e9bcd70c042bc9053da796e38800c7dca3
# Parent  bf76ff2c2364a84def0ae2410d16b037409b5295
run-tests: use a try/importerror ladder instead of looking for a specific version

This ensures we get json instead of simplejson in as many places as possible.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -61,12 +61,12 @@ from xml.dom import minidom
 import unittest
 
 try:
-    if sys.version_info < (2, 7):
+    import json
+except ImportError:
+    try:
         import simplejson as json
-    else:
-        import json
-except ImportError:
-    json = None
+    except ImportError:
+        json = None
 
 processlock = threading.Lock()
 


More information about the Mercurial-devel mailing list