[PATCH 2 of 8] tests/get-with-headers.py: use absolute_import
Gregory Szorc
gregory.szorc at gmail.com
Mon Dec 7 21:35:02 CST 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1449469541 28800
# Sun Dec 06 22:25:41 2015 -0800
# Node ID 0b7acf1bf23f5a811fe2f452b14625c1c1c10496
# Parent 2fe38d974b16c5001daabc33579708337f7f9115
tests/get-with-headers.py: use absolute_import
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.
diff --git a/tests/get-with-headers.py b/tests/get-with-headers.py
--- a/tests/get-with-headers.py
+++ b/tests/get-with-headers.py
@@ -2,20 +2,17 @@
"""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:
pass
@@ -57,13 +54,8 @@ def request(host, path, show):
# 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)
lines = json.dumps(data, sort_keys=True, indent=2).splitlines()
diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -144,9 +144,8 @@
mercurial/windows.py not using absolute_import
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
tests/hghave.py not using absolute_import
More information about the Mercurial-devel
mailing list