changeset 28726:f4b31fcd5e72

py3: use print_function in get-with-headers.py
author Robert Stanca <robert.stanca7@gmail.com>
date Sat, 02 Apr 2016 18:12:33 +0300
parents 3cf1995dbdd5
children f33280667aa5
files tests/get-with-headers.py tests/test-check-py3-compat.t
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/tests/get-with-headers.py	Sat Apr 02 17:36:59 2016 +0300
+++ b/tests/get-with-headers.py	Sat Apr 02 18:12:33 2016 +0300
@@ -3,7 +3,7 @@
 """This does HTTP GET requests given a host:port and path and returns
 a subset of the headers plus the body of the result."""
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import httplib
 import json
@@ -41,15 +41,15 @@
     conn = httplib.HTTPConnection(host)
     conn.request("GET", '/' + path, None, headers)
     response = conn.getresponse()
-    print response.status, response.reason
+    print(response.status, response.reason)
     if show[:1] == ['-']:
         show = sorted(h for h, v in response.getheaders()
                       if h.lower() not in show)
     for h in [h.lower() for h in show]:
         if response.getheader(h, None) is not None:
-            print "%s: %s" % (h, response.getheader(h))
+            print("%s: %s" % (h, response.getheader(h)))
     if not headeronly:
-        print
+        print()
         data = response.read()
 
         # Pretty print JSON. This also has the beneficial side-effect
@@ -60,7 +60,7 @@
             data = json.loads(data)
             lines = json.dumps(data, sort_keys=True, indent=2).splitlines()
             for line in lines:
-                print line.rstrip()
+                print(line.rstrip())
         else:
             sys.stdout.write(data)
 
--- a/tests/test-check-py3-compat.t	Sat Apr 02 17:36:59 2016 +0300
+++ b/tests/test-check-py3-compat.t	Sat Apr 02 18:12:33 2016 +0300
@@ -40,7 +40,6 @@
   i18n/check-translation.py not using absolute_import
   i18n/polib.py not using absolute_import
   setup.py not using absolute_import
-  tests/get-with-headers.py requires print_function
   tests/heredoctest.py requires print_function
   tests/hypothesishelpers.py not using absolute_import
   tests/hypothesishelpers.py requires print_function
@@ -257,7 +256,6 @@
   mercurial/win*.py: error importing module: <ImportError> No module named 'msvcrt' (line *) (glob)
   mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)
   mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
-  tests/get-with-headers.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/silenttestrunner.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/test-batching.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)