Pino Toscano
2016-Jan-28 13:25 UTC
[Libguestfs] [PATCH] python: stop using parens-less print in tests
print "" is no more available in Python 3, and print(...) is available since Python 2.7; as one of the tests was using print(), use this form everywhere so the tests can run fine with Python 3. --- python/t/820-rhbz912499.py | 18 +++++++++--------- python/t/910-libvirt.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/python/t/820-rhbz912499.py b/python/t/820-rhbz912499.py index de6d1d3..1909a37 100644 --- a/python/t/820-rhbz912499.py +++ b/python/t/820-rhbz912499.py @@ -30,28 +30,28 @@ import guestfs try: import libvirt except: - print "skipping test: could not import python-libvirt" + print ("skipping test: could not import python-libvirt") exit (77) # If the backend is not libvirt, skip the test. backend = guestfs.GuestFS().get_backend() rex = re.compile ("^libvirt") if not rex.match (backend): - print "skipping test: backend is not libvirt" + print ("skipping test: backend is not libvirt") exit (77) # If the architecture doesn't support IDE, skip the test. machine = platform.machine () rex = re.compile ("i.86") if machine != "x86_64" and not rex.match (machine): - print "skipping test: arch is not x86 and does not support IDE" + print ("skipping test: arch is not x86 and does not support IDE") exit (77) conn = libvirt.open (None) # Check we're using the version of libvirt-python that has c_pointer() methods. if not "c_pointer" in dir (conn): - print "skipping test: libvirt-python doesn't support c_pointer()" + print ("skipping test: libvirt-python doesn't support c_pointer()") exit (77) # Create a test disk. @@ -86,12 +86,12 @@ dom = conn.createXML (xml, libvirt.VIR_DOMAIN_START_AUTODESTROY) if dom == None: raise "could not create temporary domain (%s)" % domname -print "temporary domain %s is running" % domname +print ("temporary domain %s is running" % domname) # Libvirt should have labelled the disk. -print "before starting libguestfs" +print ("before starting libguestfs") before = check_output (["ls", "-Z", filename]) -print "disk label = %s" % before +print ("disk label = %s" % before) # Now see if we can open the domain with libguestfs without # disturbing the label. @@ -101,9 +101,9 @@ if r != 1: raise "unexpected return value from add_libvirt_dom (%d)" % r g.launch () -print "after starting libguestfs" +print ("after starting libguestfs") after = check_output (["ls", "-Z", filename]) -print "disk label = %s" % after +print ("disk label = %s" % after) if before != after: raise "disk label was changed unexpectedly" diff --git a/python/t/910-libvirt.py b/python/t/910-libvirt.py index 1f70f36..f6c99c9 100644 --- a/python/t/910-libvirt.py +++ b/python/t/910-libvirt.py @@ -28,14 +28,14 @@ guestsdir = os.environ['guestsdir'] try: import libvirt except: - print "could not import python-libvirt" + print ("could not import python-libvirt") exit (77) conn = libvirt.open ("test:///%s/guests.xml" % guestsdir) # Check we're using the version of libvirt-python that has c_pointer() methods. if not "c_pointer" in dir (conn): - print "skipping test: libvirt-python doesn't support c_pointer()" + print ("skipping test: libvirt-python doesn't support c_pointer()") exit (77) dom = conn.lookupByName ("blank-disk") -- 2.5.0
Richard W.M. Jones
2016-Jan-28 13:43 UTC
Re: [Libguestfs] [PATCH] python: stop using parens-less print in tests
On Thu, Jan 28, 2016 at 02:25:46PM +0100, Pino Toscano wrote:> print "" is no more available in Python 3, and print(...) is available > since Python 2.7; as one of the tests was using print(), use this form > everywhere so the tests can run fine with Python 3.ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Reasonably Related Threads
- [PATCH 1/3] python: tests: refactor to use unittest's discovery
- [PATCH] python: tests: use more targeted assert*() functions/checks
- [PATCH 0/8] python: PEP 8 fixes
- [PATCH v2] lib: Convert all drive socket parameters to an absolute path (RHBZ#1588451).
- Re: [PATCH 1/6] tests: use fake rhsrvany.exe