changeset 27296:8e86679d8acd

tests: use absolute_import in /get-with-headers.py While I was here, I removed condition code for failure to import json. This code was necessary to support Python < 2.6, which didn't include the json module.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 06 Dec 2015 22:25:41 -0800
parents a327a24acfea
children 4179d054b3e9
files tests/get-with-headers.py tests/test-check-py3-compat.t
diffstat 2 files changed, 7 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/tests/get-with-headers.py	Sun Dec 06 22:23:37 2015 -0800
+++ b/tests/get-with-headers.py	Sun Dec 06 22:25:41 2015 -0800
@@ -3,18 +3,15 @@
 """This does HTTP GET requests given a host:port and path and returns
 a subset of the headers plus the body of the result."""
 
-import httplib, sys
+from __future__ import absolute_import
+
+import httplib
+import json
+import os
+import sys
 
 try:
-    import json
-except ImportError:
-    try:
-        import simplejson as json
-    except ImportError:
-        json = None
-
-try:
-    import msvcrt, os
+    import msvcrt
     msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
     msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
 except ImportError:
@@ -58,11 +55,6 @@
         # Pretty print JSON. This also has the beneficial side-effect
         # of verifying emitted JSON is well-formed.
         if formatjson:
-            if not json:
-                print 'no json module not available'
-                print 'did you forget a #require json?'
-                sys.exit(1)
-
             # json.dumps() will print trailing newlines. Eliminate them
             # to make tests easier to write.
             data = json.loads(data)
--- a/tests/test-check-py3-compat.t	Sun Dec 06 22:23:37 2015 -0800
+++ b/tests/test-check-py3-compat.t	Sun Dec 06 22:25:41 2015 -0800
@@ -145,7 +145,6 @@
   setup.py not using absolute_import
   tests/filterpyflakes.py requires print_function
   tests/generate-working-copy-states.py requires print_function
-  tests/get-with-headers.py not using absolute_import
   tests/get-with-headers.py requires print_function
   tests/heredoctest.py not using absolute_import
   tests/heredoctest.py requires print_function