[PATCH 5 of 6 V2] tests: use print_function in test-parseindex2.py

Robert Stanca robert.stanca7 at gmail.com
Sun Apr 3 20:41:07 EDT 2016


# HG changeset patch
# User Robert Stanca <robert.stanca7 at gmail.com>
# Date 1459728856 -10800
#      Mon Apr 04 03:14:16 2016 +0300
# Node ID ec372c9dce4f405cc56a3a98b418d052a94dfa33
# Parent  a32159ae139781e64b1c82b633d4a1c357b5a07e
tests: use print_function in test-parseindex2.py

diff -r a32159ae1397 -r ec372c9dce4f tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Mon Apr 04 03:06:33 2016 +0300
+++ b/tests/test-check-py3-compat.t	Mon Apr 04 03:14:16 2016 +0300
@@ -60,7 +60,6 @@
   tests/test-lrucachedict.py not using absolute_import
   tests/test-lrucachedict.py requires print_function
   tests/test-manifest.py not using absolute_import
-  tests/test-parseindex2.py requires print_function
   tests/test-pathencode.py not using absolute_import
   tests/test-pathencode.py requires print_function
   tests/test-propertycache.py not using absolute_import
@@ -209,7 +208,6 @@
   tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-lrucachedict.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
-  tests/test-parseindex*.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/test-propertycache.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/test-revlog-ancestry.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/test-status-inprocess.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
diff -r a32159ae1397 -r ec372c9dce4f tests/test-parseindex2.py
--- a/tests/test-parseindex2.py	Mon Apr 04 03:06:33 2016 +0300
+++ b/tests/test-parseindex2.py	Mon Apr 04 03:14:16 2016 +0300
@@ -3,7 +3,7 @@
 It also checks certain aspects of the parsers module as a whole.
 """
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 from mercurial import (
     parsers,
 )
@@ -128,10 +128,10 @@
         hexstring = hex(hexversion)
     except TypeError:
         hexstring = None
-    print ("FAILED: version test #%s with Python %s and patched "
-           "sys.hexversion %r (%r):\n Expected %s but got:\n-->'%s'\n" %
-           (testnumber, sys.version_info, hexversion, hexstring, expected,
-            stdout))
+    print("FAILED: version test #%s with Python %s and patched "
+          "sys.hexversion %r (%r):\n Expected %s but got:\n-->'%s'\n" %
+          (testnumber, sys.version_info, hexversion, hexstring, expected,
+           stdout))
 
 def testversionokay(testnumber, hexversion):
     stdout, stderr = importparsers(hexversion)
@@ -176,7 +176,7 @@
     except TypeError:
         pass
     else:
-        print "Expected to get TypeError."
+        print("Expected to get TypeError.")
 
    # Check parsers.parse_index2() on an index file against the original
    # Python implementation of parseindex, both with and without inlined data.
@@ -188,10 +188,10 @@
     c_res_2 = parse_index2(data_non_inlined, False)
 
     if py_res_1 != c_res_1:
-        print "Parse index result (with inlined data) differs!"
+        print("Parse index result (with inlined data) differs!")
 
     if py_res_2 != c_res_2:
-        print "Parse index result (no inlined data) differs!"
+        print("Parse index result (no inlined data) differs!")
 
     ix = parsers.parse_index2(data_inlined, True)[0]
     for i, r in enumerate(ix):
@@ -199,11 +199,12 @@
             i = -1
         try:
             if ix[r[7]] != i:
-                print 'Reverse lookup inconsistent for %r' % r[7].encode('hex')
+                print('Reverse lookup inconsistent for %r'
+                    % r[7].encode('hex'))
         except TypeError:
             # pure version doesn't support this
             break
 
-    print "done"
+    print("done")
 
 runtest()


More information about the Mercurial-devel mailing list