# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2016-03-27 20:27:44 # Node ID f452c1cf7a8f06a4084de2049a7d801c4bde7498 # Parent c226e9b69bac92eeb32942eac140329997121bab 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,7 +117,6 @@ 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 @@ -303,6 +302,5 @@ tests/test-ui-verbosity.py: invalid syntax: Missing parentheses in call to 'print' (, line *) (glob) tests/test-walkrepo.py: invalid syntax: invalid syntax (, line *) (glob) tests/test-wireproto.py: invalid syntax: invalid syntax (, line *) (glob) - tests/tinyproxy.py: invalid syntax: Missing parentheses in call to 'print' (, line *) (glob) #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 @@ class ProxyHandler (BaseHTTPServer.BaseH 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 @@ class ProxyHandler (BaseHTTPServer.BaseH 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 @@ class ProxyHandler (BaseHTTPServer.BaseH soc.send("\r\n") self._read_write(soc) finally: - print "\t" "bye" + print("\t" "bye") soc.close() self.connection.close() @@ -122,7 +122,7 @@ class ProxyHandler (BaseHTTPServer.BaseH out.send(data) count = 0 else: - print "\t" "idle", count + print("\t" "idle", count) if count == max_idling: break @@ -142,16 +142,16 @@ class ThreadingHTTPServer (SocketServer. 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)