Patchwork [1,of,2] tests: load json with no fallback

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 14, 2016, 4:03 p.m.
Message ID <0c6fec72e0616985e26c.1455465814@mimosa>
Download mbox | patch
Permalink /patch/13186/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Yuya Nishihara - Feb. 14, 2016, 4:03 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1452313215 -32400
#      Sat Jan 09 13:20:15 2016 +0900
# Node ID 0c6fec72e0616985e26c69d4794531c9ed33c5e8
# Parent  4842cb7c4349183bbc1468dce963a845a9963439
tests: load json with no fallback

The json module should be available in Python 2.6 or newer.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -335,21 +335,6 @@  def has_pygments():
     except ImportError:
         return False
 
-@check("json", "some json module available")
-def has_json():
-    try:
-        import json
-        json.dumps
-        return True
-    except ImportError:
-        try:
-            import simplejson as json
-            json.dumps
-            return True
-        except ImportError:
-            pass
-    return False
-
 @check("outer-repo", "outer repo")
 def has_outer_repo():
     # failing for other reasons than 'no repo' imply that there is a repo
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -48,6 +48,7 @@  from __future__ import print_function
 from distutils import version
 import difflib
 import errno
+import json
 import optparse
 import os
 import shutil
@@ -69,15 +70,6 @@  from xml.dom import minidom
 import unittest
 
 osenvironb = getattr(os, 'environb', os.environ)
-
-try:
-    import json
-except ImportError:
-    try:
-        import simplejson as json
-    except ImportError:
-        json = None
-
 processlock = threading.Lock()
 
 if sys.version_info > (3, 5, 0):
@@ -1728,8 +1720,6 @@  class TextTestRunner(unittest.TextTestRu
                     xuf.write(doc.toprettyxml(indent='  ', encoding='utf-8'))
 
             if self._runner.options.json:
-                if json is None:
-                    raise ImportError("json module not installed")
                 jsonpath = os.path.join(self._runner._testdir, 'report.json')
                 with open(jsonpath, 'w') as fp:
                     timesd = {}
diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1,4 +1,3 @@ 
-#require json
 #require serve
 
   $ request() {
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -530,8 +530,6 @@  Missing skips or blacklisted skips don't
           "result": "skip"
       }
   } (no-eol)
-#if json
-
 test for --json
 ==================
 
@@ -634,8 +632,6 @@  Test that failed test accepted through i
   } (no-eol)
   $ mv backup test-failure.t
 
-#endif
-
 backslash on end of line with glob matching is handled properly
 
   $ cat > test-glob-backslash.t << EOF