Patchwork [06,of,10,V3] tests: use print_function in get-with-headers.py

login
register
mail settings
Submitter roby roby
Date April 2, 2016, 3:37 p.m.
Message ID <f504beb8c1c1af8061e1.1459611458@roby>
Download mbox | patch
Permalink /patch/14260/
State Accepted
Headers show

Comments

roby roby - April 2, 2016, 3:37 p.m.
# HG changeset patch
# User Robert Stanca <robert.stanca7@gmail.com>
# Date 1459609953 -10800
#      Sat Apr 02 18:12:33 2016 +0300
# Node ID f504beb8c1c1af8061e139eb9b337cfc9481bd3a
# Parent  46616de055613731c804b467971f04496b6014db
tests: use print_function in get-with-headers.py

Patch

diff -r 46616de05561 -r f504beb8c1c1 tests/get-with-headers.py
--- 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)
 
diff -r 46616de05561 -r f504beb8c1c1 tests/test-check-py3-compat.t
--- 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
@@ -42,7 +42,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
@@ -268,7 +267,6 @@ 
   mercurial/win32.py: error importing module: <ImportError> No module named 'msvcrt' (line 12)
   mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line 10)
   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)