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

login
register
mail settings
Submitter Augie Fackler
Date Nov. 10, 2014, 7:09 p.m.
Message ID <d7bf05e9bcd70c042bc9.1415646548@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/6666/
State Accepted
Headers show

Comments

Augie Fackler - Nov. 10, 2014, 7:09 p.m.
# HG changeset patch
# User Augie Fackler <raf@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.
Pierre-Yves David - Nov. 11, 2014, 9:43 p.m.
On 11/10/2014 07:09 PM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@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

queued these two with a fix to the commit message (line too long).

Patch

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()