You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jd...@apache.org on 2023/04/10 20:25:09 UTC

[qpid-python] branch main updated: QPID-8631: modernize `print` statement uses to the `print()` function form (#11)

This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-python.git


The following commit(s) were added to refs/heads/main by this push:
     new f84a72f  QPID-8631: modernize `print` statement uses to the `print()` function form (#11)
f84a72f is described below

commit f84a72f0c1f592642d713a6891c3afdaf22ef99e
Author: Jiri Daněk <jd...@redhat.com>
AuthorDate: Mon Apr 10 22:25:04 2023 +0200

    QPID-8631: modernize `print` statement uses to the `print()` function form (#11)
    
    This is the result of running
    
    ```
    python-modernize -wnf libmodernize.fixes.fix_print
    ```
---
 examples/api/drain                     |  5 +++--
 examples/api/hello                     |  5 +++--
 examples/api/hello_xml                 |  5 +++--
 examples/api/server                    |  5 +++--
 examples/api/spout                     |  5 +++--
 examples/api/statistics.py             |  7 ++++---
 examples/reservations/common.py        |  5 +++--
 examples/reservations/reserve          | 19 ++++++++++---------
 qpid-python-test                       | 19 ++++++++++---------
 qpid/debug.py                          | 11 ++++++-----
 qpid/delegate.py                       |  7 ++++---
 qpid/disp.py                           |  9 +++++----
 qpid/managementdata.py                 | 27 ++++++++++++++-------------
 qpid/ops.py                            |  3 ++-
 qpid/spec08.py                         |  3 ++-
 qpid/testlib.py                        |  5 +++--
 qpid/tests/__init__.py                 | 13 +++++++------
 qpid/tests/codec.py                    | 21 +++++++++++----------
 qpid/tests/messaging/implementation.py |  3 ++-
 qpid/tests/messaging/selector.py       |  3 ++-
 qpid_tests/broker_0_10/exchange.py     |  5 +++--
 qpid_tests/broker_0_10/lvq.py          |  3 ++-
 qpid_tests/broker_0_10/new_api.py      |  9 +++++----
 qpid_tests/broker_0_10/stats.py        | 13 +++++++------
 qpid_tests/broker_0_8/testlib.py       |  3 ++-
 25 files changed, 119 insertions(+), 94 deletions(-)

diff --git a/examples/api/drain b/examples/api/drain
index 97f644d..213cbf7 100755
--- a/examples/api/drain
+++ b/examples/api/drain
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse
 from qpid.messaging import *
 from qpid.util import URL
@@ -84,13 +85,13 @@ try:
   while not opts.count or count < opts.count:
     try:
       msg = rcv.fetch(timeout=timeout)
-      print opts.format % Formatter(msg)
+      print(opts.format % Formatter(msg))
       count += 1
       ssn.acknowledge()
     except Empty:
       break
 except ReceiverError as e:
-  print e
+  print(e)
 except KeyboardInterrupt:
   pass
 
diff --git a/examples/api/hello b/examples/api/hello
index 65b0edd..dffff88 100755
--- a/examples/api/hello
+++ b/examples/api/hello
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys
 from qpid.messaging import *
 
@@ -43,10 +44,10 @@ try:
   sender.send(Message("Hello world!"));
 
   message = receiver.fetch()
-  print message.content
+  print(message.content)
   session.acknowledge()
 
 except MessagingError as m:
-  print m
+  print(m)
 
 connection.close()
diff --git a/examples/api/hello_xml b/examples/api/hello_xml
index addeaef..1314825 100755
--- a/examples/api/hello_xml
+++ b/examples/api/hello_xml
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys
 from qpid.messaging import *
 
@@ -68,10 +69,10 @@ try:
 # Retrieve matching message from the receiver and print it
 
   message = receiver.fetch(timeout=1)
-  print message.content
+  print(message.content)
   session.acknowledge()
 
 except MessagingError as m:
-  print m
+  print(m)
 
 connection.close()
diff --git a/examples/api/server b/examples/api/server
index 23734cb..aee4747 100755
--- a/examples/api/server
+++ b/examples/api/server
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse, sys, traceback
 from qpid.messaging import *
 from qpid.util import URL
@@ -83,12 +84,12 @@ try:
       snd = ssn.sender(msg.reply_to)
       snd.send(response)
     except SendError as e:
-      print e
+      print(e)
     if snd is not None:
       snd.close()
     ssn.acknowledge()
 except ReceiverError as e:
-  print e
+  print(e)
 except KeyboardInterrupt:
   pass
 
diff --git a/examples/api/spout b/examples/api/spout
index c1b1622..ecf4ced 100755
--- a/examples/api/spout
+++ b/examples/api/spout
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse, time
 from qpid.messaging import *
 from qpid.util import URL
@@ -124,9 +125,9 @@ try:
 
     snd.send(msg)
     count += 1
-    print msg
+    print(msg)
 except SendError as e:
-  print e
+  print(e)
 except KeyboardInterrupt:
   pass
 
diff --git a/examples/api/statistics.py b/examples/api/statistics.py
index e095920..77f1e1f 100644
--- a/examples/api/statistics.py
+++ b/examples/api/statistics.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import time
 
 TS = "ts"
@@ -110,7 +111,7 @@ class ReporterBase:
             self.batchCount+=1
             if self.batchCount == self.batchSize:
                 self.header()
-                print self.batch.report()
+                print(self.batch.report())
                 self.create()
                 self.batchCount = 0
 
@@ -119,13 +120,13 @@ class ReporterBase:
         if self.overall == None:
             self.overall = self.create()
         self.header()
-        print self.overall.report()
+        print(self.overall.report())
 
     def header(self):
         if not self.headerPrinted:
             if self.overall == None:
                 self.overall = self.create()
-            print self.overall.header()
+            print(self.overall.header())
             self.headerPrinted = True
 
 
diff --git a/examples/reservations/common.py b/examples/reservations/common.py
index 7602fe1..85aeebc 100644
--- a/examples/reservations/common.py
+++ b/examples/reservations/common.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import traceback
 from fnmatch import fnmatch
 from qpid.messaging import *
@@ -25,7 +26,7 @@ from qpid.messaging import *
 class Dispatcher:
 
   def unhandled(self, msg):
-    print "UNHANDLED MESSAGE: %s" % msg
+    print("UNHANDLED MESSAGE: %s" % msg)
 
   def ignored(self, msg):
     return False
@@ -61,7 +62,7 @@ class Dispatcher:
           snd = session.sender(to)
           snd.send(r)
         except SendError as e:
-          print e
+          print(e)
         finally:
           snd.close()
 
diff --git a/examples/reservations/reserve b/examples/reservations/reserve
index 68e7fee..0290073 100755
--- a/examples/reservations/reserve
+++ b/examples/reservations/reserve
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import optparse, os, sys, time
 from uuid import uuid4
 from qpid.messaging import *
@@ -95,10 +96,10 @@ class Requester(Dispatcher):
     self.agents[id] = (status, owner)
 
     if opts.status:
-      print self.agent_status(id)
+      print(self.agent_status(id))
 
   def do_empty(self, msg):
-    print "no matching resources"
+    print("no matching resources")
 
   def candidates(self, candidate_status, candidate_owner):
     for id, (status, owner) in self.agents.items():
@@ -160,8 +161,8 @@ try:
                                           "identity": [cid]},
                             content = {"owner": opts.owner})
           if not requested:
-            print "requesting %s:" % request_type,
-          print cid,
+            print("requesting %s:" % request_type, end=' ')
+          print(cid, end=' ')
           sys.stdout.flush()
           req.correlation(req_msg.correlation_id)
           snd.send(req_msg)
@@ -170,7 +171,7 @@ try:
         discovering = False
 
   if requested:
-    print
+    print()
     owners = {}
     for id in requested:
       st, ow = req.agents[id]
@@ -183,14 +184,14 @@ try:
       owners[k].sort()
       v = ", ".join(owners[k])
       if k is None:
-        print "free: %s" % v
+        print("free: %s" % v)
       else:
-        print "owner %s: %s" % (k, v)
+        print("owner %s: %s" % (k, v))
   elif req.agents and not opts.status:
-    print "no available resources"
+    print("no available resources")
 
   if req.outstanding:
-    print "request timed out"
+    print("request timed out")
 except KeyboardInterrupt:
   pass
 finally:
diff --git a/qpid-python-test b/qpid-python-test
index dfe6a6f..fef140b 100755
--- a/qpid-python-test
+++ b/qpid-python-test
@@ -20,6 +20,7 @@
 
 # TODO: summarize, test harness preconditions (e.g. broker is alive)
 
+from __future__ import print_function
 import logging, optparse, os, struct, sys, time, traceback, types
 from fnmatch import fnmatchcase as match
 from getopt import GetoptError
@@ -401,9 +402,9 @@ def run_test(name, test, config):
     if interceptor.last != "\n":
       sys.stdout.write("\n")
     sys.stdout.write(output)
-  print " %s" % colorize_word(runner.status())
+  print(" %s" % colorize_word(runner.status()))
   if runner.failed() or runner.skipped():
-    print runner.get_formatted_exceptions()
+    print(runner.get_formatted_exceptions())
   root.setLevel(level)
   filter.patterns = patterns
   return TestResult(end - start, runner.passed(), runner.skipped(), runner.failed(), runner.get_formatted_exceptions())
@@ -579,7 +580,7 @@ skipped = 0
 start = time.time()
 for t in filtered:
   if list_only:
-    print t.name()
+    print(t.name())
   else:
     st = t.run()
     if xmlr:
@@ -613,22 +614,22 @@ if not list_only:
     skip = "skip"
   else:
     skip = "pass"
-  print colorize("Totals:", 1),
+  print(colorize("Totals:", 1), end=' ')
   totals = [colorize_word("total", "%s tests" % total),
             colorize_word(_pass, "%s passed" % passed),
             colorize_word(skip, "%s skipped" % skipped),
             colorize_word(ign, "%s ignored" % len(ignored)),
             colorize_word(outcome, "%s failed" % failed)]
-  print ", ".join(totals),
+  print(", ".join(totals), end=' ')
   if opts.hoe and failed > 0:
-    print " -- (halted after %s)" % run
+    print(" -- (halted after %s)" % run)
   else:
-    print
+    print()
   if opts.time and run > 0:
-    print colorize("Timing:", 1),
+    print(colorize("Timing:", 1), end=' ')
     timing = [colorize_word("elapsed", "%.2fs elapsed" % (end - start)),
               colorize_word("average", "%.2fs average" % ((end - start)/run))]
-    print ", ".join(timing)
+    print(", ".join(timing))
 
 if xmlr:
    xmlr.end()
diff --git a/qpid/debug.py b/qpid/debug.py
index b5dbd4d..423b03d 100644
--- a/qpid/debug.py
+++ b/qpid/debug.py
@@ -17,6 +17,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import threading, traceback, signal, sys, time
 
 def stackdump(sig, frm):
@@ -27,7 +28,7 @@ def stackdump(sig, frm):
       code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
       if line:
         code.append("  %s" % (line.strip()))
-  print "\n".join(code)
+  print("\n".join(code))
 
 signal.signal(signal.SIGQUIT, stackdump)
 
@@ -39,12 +40,12 @@ class LoudLock:
   def acquire(self, blocking=1):
     while not self.lock.acquire(blocking=0):
       time.sleep(1)
-      print >> sys.out, "TRYING"
+      print("TRYING", file=sys.out)
       traceback.print_stack(None, None, out)
-      print >> sys.out, "TRYING"
-    print >> sys.out, "ACQUIRED"
+      print("TRYING", file=sys.out)
+    print("ACQUIRED", file=sys.out)
     traceback.print_stack(None, None, out)
-    print >> sys.out, "ACQUIRED"
+    print("ACQUIRED", file=sys.out)
     return True
 
   def _is_owned(self):
diff --git a/qpid/delegate.py b/qpid/delegate.py
index b447c4a..579cf6c 100644
--- a/qpid/delegate.py
+++ b/qpid/delegate.py
@@ -21,6 +21,7 @@
 Delegate implementation intended for use with the peer module.
 """
 
+from __future__ import print_function
 import threading, inspect, traceback, sys
 from connection08 import Method, Request, Response
 
@@ -46,8 +47,8 @@ class Delegate:
     try:
       return handler(channel, frame)
     except:
-      print >> sys.stderr, "Error in handler: %s\n\n%s" % \
-            (_handler_name(method), traceback.format_exc())
+      print("Error in handler: %s\n\n%s" % \
+            (_handler_name(method), traceback.format_exc()), file=sys.stderr)
 
   def closed(self, reason):
-    print "Connection closed: %s" % reason
+    print("Connection closed: %s" % reason)
diff --git a/qpid/disp.py b/qpid/disp.py
index d1340b8..2bef08a 100644
--- a/qpid/disp.py
+++ b/qpid/disp.py
@@ -19,6 +19,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from time import strftime, gmtime
 
 class Header:
@@ -130,7 +131,7 @@ class Display:
       for idx in range(diff):
         row.append("")
 
-    print title
+    print(title)
     if len (rows) == 0:
       return
     colWidth = []
@@ -148,12 +149,12 @@ class Display:
         for i in range (colWidth[col] - len (head)):
           line = line + " "
       col = col + 1
-    print line
+    print(line)
     line = self.tablePrefix
     for width in colWidth:
       line = line + "=" * width
     line = line[:255]
-    print line
+    print(line)
 
     for row in rows:
       line = self.tablePrefix
@@ -164,7 +165,7 @@ class Display:
           for i in range (width - len (unicode (row[col]))):
             line = line + " "
         col = col + 1
-      print line
+      print(line)
 
   def do_setTimeFormat (self, fmt):
     """ Select timestamp format """
diff --git a/qpid/managementdata.py b/qpid/managementdata.py
index 66a39c6..23261cc 100644
--- a/qpid/managementdata.py
+++ b/qpid/managementdata.py
@@ -24,6 +24,7 @@
 ## This file is being obsoleted by qmf/console.py
 ###############################################################################
 
+from __future__ import print_function
 import qpid
 import re
 import socket
@@ -171,14 +172,14 @@ class ManagementData:
     try:
       line = "Call Result: " + self.methodsPending[sequence] + \
              "  " + str (status) + " (" + sText + ")"
-      print line, args
+      print(line, args)
       del self.methodsPending[sequence]
     finally:
       self.lock.release ()
 
   def closeHandler (self, context, reason):
     if self.operational:
-      print "Connection to broker lost:", reason
+      print("Connection to broker lost:", reason)
     self.operational = False
     if self.cli != None:
       self.cli.setPromptMessage ("Broker Disconnected")
@@ -458,21 +459,21 @@ class ManagementData:
         self.disp.table ("Management Object Types:",
                          ("ObjectType", "Active", "Deleted"), rows)
       else:
-        print "Waiting for next periodic update"
+        print("Waiting for next periodic update")
     finally:
       self.lock.release ()
 
   def listObjects (self, tokens):
     """ Generate a display of a list of objects in a class """
     if len(tokens) == 0:
-      print "Error - No class name provided"
+      print("Error - No class name provided")
       return
 
     self.lock.acquire ()
     try:
       classKey = self.getClassKey (tokens[0])
       if classKey == None:
-        print ("Object type %s not known" % tokens[0])
+        print(("Object type %s not known" % tokens[0]))
       else:
         rows = []
         if classKey in self.tables:
@@ -506,18 +507,18 @@ class ManagementData:
         classKey  = self.getClassForId (self.rawObjId (rootId))
         remaining = tokens
         if classKey == None:
-          print "Id not known: %d" % int (tokens[0])
+          print("Id not known: %d" % int (tokens[0]))
           raise ValueError ()
       else:
         classKey  = self.getClassKey (tokens[0])
         remaining = tokens[1:]
         if classKey not in self.tables:
-          print "Class not known: %s" % tokens[0]
+          print("Class not known: %s" % tokens[0])
           raise ValueError ()
 
       userIds = self.listOfIds (classKey, remaining)
       if len (userIds) == 0:
-        print "No object IDs supplied"
+        print("No object IDs supplied")
         raise ValueError ()
 
       ids = []
@@ -586,7 +587,7 @@ class ManagementData:
     try:
       classKey = self.getClassKey (className)
       if classKey == None:
-        print ("Class name %s not known" % className)
+        print(("Class name %s not known" % className))
         raise ValueError ()
 
       rows = []
@@ -665,7 +666,7 @@ class ManagementData:
         raise ValueError ()
 
       if methodName not in self.schema[classKey][2]:
-        print "Method '%s' not valid for class '%s'" % (methodName, self.displayClassName(classKey))
+        print("Method '%s' not valid for class '%s'" % (methodName, self.displayClassName(classKey)))
         raise ValueError ()
 
       schemaMethod = self.schema[classKey][2][methodName]
@@ -674,7 +675,7 @@ class ManagementData:
         if schemaMethod[1][arg][2].find("I") != -1:
           count += 1
       if len (args) != count:
-        print "Wrong number of method args: Need %d, Got %d" % (count, len (args))
+        print("Wrong number of method args: Need %d, Got %d" % (count, len (args)))
         raise ValueError ()
 
       namedArgs = {}
@@ -723,7 +724,7 @@ class ManagementData:
     else:
       row = self.makeIdRow (select)
       if row == None:
-        print "Display Id %d not known" % select
+        print("Display Id %d not known" % select)
         return
       rows.append(row)
     self.disp.table("Translation of Display IDs:",
@@ -754,7 +755,7 @@ class ManagementData:
     except:
       tokens = encTokens
     if len (tokens) < 2:
-      print "Not enough arguments supplied"
+      print("Not enough arguments supplied")
       return
     
     displayId  = long (tokens[0])
diff --git a/qpid/ops.py b/qpid/ops.py
index 390552b..2b07836 100644
--- a/qpid/ops.py
+++ b/qpid/ops.py
@@ -16,6 +16,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import os, mllib, cPickle as pickle, sys
 from util import fill
 
@@ -26,7 +27,7 @@ class Enum(object):
 
   # XXX: for backwards compatibility
   def values(cls):
-    print >> sys.stderr, "warning, please use .VALUES instead of .values()"
+    print("warning, please use .VALUES instead of .values()", file=sys.stderr)
     return cls.VALUES
   # we can't use the backport preprocessor here because this code gets
   # called by setup.py
diff --git a/qpid/spec08.py b/qpid/spec08.py
index 3a6f0ce..64ebdd6 100644
--- a/qpid/spec08.py
+++ b/qpid/spec08.py
@@ -29,6 +29,7 @@ class so that the generated code can be reused in a variety of
 situations.
 """
 
+from __future__ import print_function
 import re, new, mllib, qpid
 from util import fill
 
@@ -501,4 +502,4 @@ def test_summary():
     rows.append('<tr><td colspan="3">%s</td></tr>' % rule.text)
     rows.append('<tr><td colspan="3">&nbsp;</td></tr>')
 
-  print template % "\n".join(rows)
+  print(template % "\n".join(rows))
diff --git a/qpid/testlib.py b/qpid/testlib.py
index 94e0908..0a4ad48 100644
--- a/qpid/testlib.py
+++ b/qpid/testlib.py
@@ -21,6 +21,7 @@
 # Support library for qpid python tests.
 #
 
+from __future__ import print_function
 import string
 import random
 
@@ -71,8 +72,8 @@ class TestBase(unittest.TestCase):
             for ch, ex in self.exchanges:
                 ch.exchange_delete(exchange=ex)
         except:
-            print "Error on tearDown:"
-            print traceback.print_exc()
+            print("Error on tearDown:")
+            print(traceback.print_exc())
 
         self.client.close()
 
diff --git a/qpid/tests/__init__.py b/qpid/tests/__init__.py
index 85ab013..a9bbf85 100644
--- a/qpid/tests/__init__.py
+++ b/qpid/tests/__init__.py
@@ -17,6 +17,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 class Test:
 
   def __init__(self, name):
@@ -43,14 +44,14 @@ import qpid.tests.saslmech.finder
 class TestTestsXXX(Test):
 
   def testFoo(self):
-    print "this test has output"
+    print("this test has output")
 
   def testBar(self):
-    print "this test "*8
-    print "has"*10
-    print "a"*75
-    print "lot of"*10
-    print "output"*10
+    print("this test "*8)
+    print("has"*10)
+    print("a"*75)
+    print("lot of"*10)
+    print("output"*10)
 
   def testQux(self):
     import sys
diff --git a/qpid/tests/codec.py b/qpid/tests/codec.py
index 8a8236d..162b076 100644
--- a/qpid/tests/codec.py
+++ b/qpid/tests/codec.py
@@ -18,6 +18,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import unittest
 from qpid.codec import Codec
 from qpid.spec08 import load
@@ -704,25 +705,25 @@ if __name__ == '__main__':
     test_runner = unittest.TextTestRunner(run_output_stream, '', '')
     test_result = test_runner.run(codec_test_suite)
 
-    print '\n%d test run...' % (test_result.testsRun)
+    print('\n%d test run...' % (test_result.testsRun))
 
     if test_result.wasSuccessful():
-        print '\nAll tests successful\n'
+        print('\nAll tests successful\n')
 
     if test_result.failures:
-        print '\n----------'
-        print '%d FAILURES:' % (len(test_result.failures))
-        print '----------\n'
+        print('\n----------')
+        print('%d FAILURES:' % (len(test_result.failures)))
+        print('----------\n')
         for failure in test_result.failures:
-            print str(failure[0]) + ' ... FAIL'
+            print(str(failure[0]) + ' ... FAIL')
 
     if test_result.errors:
-        print '\n---------'
-        print '%d ERRORS:' % (len(test_result.errors))
-        print '---------\n'
+        print('\n---------')
+        print('%d ERRORS:' % (len(test_result.errors)))
+        print('---------\n')
 
         for error in test_result.errors:
-            print str(error[0]) + ' ... ERROR'
+            print(str(error[0]) + ' ... ERROR')
 
     f = open('codec_unit_test_output.txt', 'w')
     f.write(str(run_output_stream.getvalue()))
diff --git a/qpid/tests/messaging/implementation.py b/qpid/tests/messaging/implementation.py
index 553d06b..740dd27 100644
--- a/qpid/tests/messaging/implementation.py
+++ b/qpid/tests/messaging/implementation.py
@@ -16,13 +16,14 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import print_function
 import os
 if 'QPID_USE_SWIG_CLIENT' in os.environ and os.environ['QPID_USE_SWIG_CLIENT']:
   try:
     from qpid_messaging import *
     from qpid.datatypes import uuid4
   except ImportError as e:
-    print "Swigged client not found. Falling back to pure bindings, %s\n" % e
+    print("Swigged client not found. Falling back to pure bindings, %s\n" % e)
     from qpid.messaging import *
 else:
   from qpid.messaging import *
diff --git a/qpid/tests/messaging/selector.py b/qpid/tests/messaging/selector.py
index 3332894..013c413 100644
--- a/qpid/tests/messaging/selector.py
+++ b/qpid/tests/messaging/selector.py
@@ -17,6 +17,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 import sys, os
 from logging import getLogger
 from unittest import TestCase
@@ -86,7 +87,7 @@ class SelectorTests(TestCase):
         s.send("child")
         os._exit(0)
       except Exception as e:
-        print >>sys.stderr, "test child process error: %s" % e
+        print("test child process error: %s" % e, file=sys.stderr)
         os.exit(1)
       finally:
         os._exit(1)             # Hard exit from child to stop remaining tests running twice
diff --git a/qpid_tests/broker_0_10/exchange.py b/qpid_tests/broker_0_10/exchange.py
index e05b9f9..ee03ce3 100644
--- a/qpid_tests/broker_0_10/exchange.py
+++ b/qpid_tests/broker_0_10/exchange.py
@@ -23,6 +23,7 @@ Tests for exchange behaviour.
 Test classes ending in 'RuleTests' are derived from rules in amqp.xml.
 """
 
+from __future__ import print_function
 import Queue, logging, traceback
 from qpid.testlib import TestBase010
 from qpid.datatypes import Message
@@ -46,8 +47,8 @@ class TestHelper(TestBase010):
             for ssn, ex in self.exchanges:
                 ssn.exchange_delete(exchange=ex)
         except:
-            print "Error on tearDown:"
-            print traceback.print_exc()
+            print("Error on tearDown:")
+            print(traceback.print_exc())
         TestBase010.tearDown(self)
 
     def createMessage(self, key="", body=""):
diff --git a/qpid_tests/broker_0_10/lvq.py b/qpid_tests/broker_0_10/lvq.py
index 07a8906..40b9835 100644
--- a/qpid_tests/broker_0_10/lvq.py
+++ b/qpid_tests/broker_0_10/lvq.py
@@ -17,6 +17,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from qpid.tests.messaging.implementation import *
 from qpid.tests.messaging import Base
 import math
@@ -82,7 +83,7 @@ class LVQTests (Base):
 
         rcv = self.ssn.receiver("lvq; {mode: browse}")
         retrieved = fetch_all_as_tuples(rcv)
-        print [v for k, v in retrieved]
+        print([v for k, v in retrieved])
 
         for k, v in retrieved:
             assert v == "%s-%i" % (k, counters[k])
diff --git a/qpid_tests/broker_0_10/new_api.py b/qpid_tests/broker_0_10/new_api.py
index a2d724f..2dd91a4 100644
--- a/qpid_tests/broker_0_10/new_api.py
+++ b/qpid_tests/broker_0_10/new_api.py
@@ -17,6 +17,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from qpid.tests.messaging.implementation import *
 from qpid.tests.messaging import Base
 from qpidtoollibs import BrokerAgent
@@ -33,14 +34,14 @@ class GeneralTests(Base):
 
     def assertEqual(self, left, right, text=None):
         if not left == right:
-            print "assertEqual failure: %r != %r" % (left, right)
+            print("assertEqual failure: %r != %r" % (left, right))
             if text:
-                print "  %r" % text
+                print("  %r" % text)
             assert None
 
     def fail(self, text=None):
         if text:
-            print "Fail: %r" % text
+            print("Fail: %r" % text)
         assert None
 
     def setup_connection(self):
@@ -283,7 +284,7 @@ class SequenceNumberTests(Base):
 
     def fail(self, text=None):
         if text:
-            print "Fail: %r" % text
+            print("Fail: %r" % text)
         assert None
 
     def setup_connection(self):
diff --git a/qpid_tests/broker_0_10/stats.py b/qpid_tests/broker_0_10/stats.py
index 4f3931b..9f7078d 100644
--- a/qpid_tests/broker_0_10/stats.py
+++ b/qpid_tests/broker_0_10/stats.py
@@ -17,6 +17,7 @@
 # under the License.
 #
 
+from __future__ import print_function
 from qpid.tests.messaging.implementation import *
 from qpid.tests.messaging import Base
 from time import sleep
@@ -33,24 +34,24 @@ class BrokerStatsTests(Base):
 
     def assertEqual(self, left, right, text=None):
         if not left == right:
-            print "assertEqual failure: %r != %r" % (left, right)
+            print("assertEqual failure: %r != %r" % (left, right))
             if text:
-                print "  %r" % text
+                print("  %r" % text)
             assert None
 
     def failUnless(self, value, text=None):
         if value:
             return
-        print "failUnless failure",
+        print("failUnless failure", end=' ')
         if text:
-            print ": %r" % text
+            print(": %r" % text)
         else:
-            print
+            print()
         assert None
 
     def fail(self, text=None):
         if text:
-            print "Fail: %r" % text
+            print("Fail: %r" % text)
         assert None
 
     def setup_connection(self):
diff --git a/qpid_tests/broker_0_8/testlib.py b/qpid_tests/broker_0_8/testlib.py
index 4f026b1..b1ceeb2 100644
--- a/qpid_tests/broker_0_8/testlib.py
+++ b/qpid_tests/broker_0_8/testlib.py
@@ -21,6 +21,7 @@
 # Tests for the testlib itself.
 # 
 
+from __future__ import print_function
 from qpid.content import Content
 from qpid.testlib import TestBase
 from Queue import Empty
@@ -30,7 +31,7 @@ from traceback import *
 
 def mytrace(frame, event, arg):
     print_stack(frame);
-    print "===="
+    print("====")
     return mytrace
     
 class TestBaseTest(TestBase):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org