changeset 28754:7e5744e8334c

py3: use print_function in test-parseindex2.py
author Robert Stanca <robert.stanca7@gmail.com>
date Mon, 04 Apr 2016 03:14:16 +0300
parents 0c2295384eea
children 84673a7c54af
files tests/test-check-py3-compat.t tests/test-parseindex2.py
diffstat 2 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
@@ -234,7 +233,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)
--- 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()