[PATCH] tests: make tinyproxy.py use print_function

Pulkit Goyal 7895pulkit at gmail.com
Sun Mar 27 16:28:30 EDT 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1459110464 -19800
#      Mon Mar 28 01:57:44 2016 +0530
# Node ID 74738ec9101cb0a881a1245eb4ecd9b58f601b36
# Parent  345f4fa4cc8912bb722ad3e35d68858487420bc6
tests: make tinyproxy.py use print_function

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
@@ -117,16 +117,14 @@
   tests/test-url.py requires print_function
   tests/test-walkrepo.py requires print_function
   tests/test-wireproto.py requires print_function
-  tests/tinyproxy.py requires print_function
 
 #if py3exe
   $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py
   contrib/check-code.py: invalid syntax: (unicode error) 'unicodeescape' codec can't decode bytes in position 18-19: malformed \N character escape (<unknown>, line 106)
   contrib/import-checker.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line 569)
-  contrib/revsetbenchmarks.py: invalid syntax: invalid syntax (<unknown>, line 186)
   doc/hgmanpage.py: invalid syntax: invalid syntax (<unknown>, line 286)
   hgext/acl.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  hgext/automv.py: error importing module: <SyntaxError> invalid syntax (commands.py, line 3324) (line 29)
+  hgext/automv.py: error importing module: <SyntaxError> invalid syntax (commands.py, line 3326) (line 29)
   hgext/blackbox.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/bugzilla.py: error importing module: <ImportError> No module named 'urlparse' (line 284)
   hgext/censor.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
@@ -152,7 +150,7 @@
   hgext/eol.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/extdiff.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/factotum.py: error importing: <ImportError> No module named 'cStringIO' (error at url.py:13)
-  hgext/fetch.py: error importing module: <SyntaxError> invalid syntax (commands.py, line 3324) (line 12)
+  hgext/fetch.py: error importing module: <SyntaxError> invalid syntax (commands.py, line 3326) (line 12)
   hgext/fsmonitor/state.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/fsmonitor/watchmanclient.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/gpg.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
@@ -195,7 +193,7 @@
   mercurial/changegroup.py: error importing: <ImportError> No module named 'Queue' (error at scmutil.py:10)
   mercurial/changelog.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
   mercurial/cmdutil.py: error importing module: <ImportError> No module named 'cStringIO' (line 10)
-  mercurial/commands.py: invalid syntax: invalid syntax (<unknown>, line 3324)
+  mercurial/commands.py: invalid syntax: invalid syntax (<unknown>, line 3326)
   mercurial/commandserver.py: error importing module: <ImportError> No module named 'SocketServer' (line 10)
   mercurial/config.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/context.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
@@ -304,6 +302,5 @@
   tests/test-ui-verbosity.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line 9)
   tests/test-walkrepo.py: invalid syntax: invalid syntax (<unknown>, line 37)
   tests/test-wireproto.py: invalid syntax: invalid syntax (<unknown>, line 55)
-  tests/tinyproxy.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line 53)
 
 #endif
diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 __doc__ = """Tiny HTTP Proxy.
 
@@ -50,7 +50,7 @@
             host_port = netloc[:i], int(netloc[i + 1:])
         else:
             host_port = netloc, 80
-        print "\t" "connect to %s:%d" % host_port
+        print("\t" "connect to %s:%d" % host_port)
         try: soc.connect(host_port)
         except socket.error as arg:
             try: msg = arg[1]
@@ -70,7 +70,7 @@
                 self.wfile.write("\r\n")
                 self._read_write(soc, 300)
         finally:
-            print "\t" "bye"
+            print("\t" "bye")
             soc.close()
             self.connection.close()
 
@@ -95,7 +95,7 @@
                 soc.send("\r\n")
                 self._read_write(soc)
         finally:
-            print "\t" "bye"
+            print("\t" "bye")
             soc.close()
             self.connection.close()
 
@@ -122,7 +122,7 @@
                         out.send(data)
                         count = 0
             else:
-                print "\t" "idle", count
+                print("\t" "idle", count)
             if count == max_idling:
                 break
 
@@ -142,16 +142,16 @@
 if __name__ == '__main__':
     from sys import argv
     if argv[1:] and argv[1] in ('-h', '--help'):
-        print argv[0], "[port [allowed_client_name ...]]"
+        print(argv[0], "[port [allowed_client_name ...]]")
     else:
         if argv[2:]:
             allowed = []
             for name in argv[2:]:
                 client = socket.gethostbyname(name)
                 allowed.append(client)
-                print "Accept: %s (%s)" % (client, name)
+                print("Accept: %s (%s)" % (client, name))
             ProxyHandler.allowed_clients = allowed
             del argv[2:]
         else:
-            print "Any clients will be served..."
+            print("Any clients will be served...")
         BaseHTTPServer.test(ProxyHandler, ThreadingHTTPServer)


More information about the Mercurial-devel mailing list