Patchwork [03,of,10,V3] tests: use print_function in test-ancestor.py

login
register
mail settings
Submitter roby roby
Date April 2, 2016, 3:37 p.m.
Message ID <86ad720eb4fc8b479394.1459611455@roby>
Download mbox | patch
Permalink /patch/14257/
State Accepted
Headers show

Comments

roby roby - April 2, 2016, 3:37 p.m.
# HG changeset patch
# User Robert Stanca <robert.stanca7@gmail.com>
# Date 1459607591 -10800
#      Sat Apr 02 17:33:11 2016 +0300
# Node ID 86ad720eb4fc8b479394ace981d8099591e26b96
# Parent  af089c63c98dce6a17e7be645c688163e446328a
tests: use print_function in test-ancestor.py

Patch

diff -r af089c63c98d -r 86ad720eb4fc tests/test-ancestor.py
--- a/tests/test-ancestor.py	Sat Apr 02 17:29:38 2016 +0300
+++ b/tests/test-ancestor.py	Sat Apr 02 17:33:11 2016 +0300
@@ -1,4 +1,4 @@ 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import binascii
 import getopt
@@ -94,13 +94,13 @@ 
 
     def err(seed, graph, bases, seq, output, expected):
         if nerrs[0] == 0:
-            print >> sys.stderr, 'seed:', hex(seed)[:-1]
+            print('seed:', hex(seed)[:-1], file=sys.stderr)
         if gerrs[0] == 0:
-            print >> sys.stderr, 'graph:', graph
-        print >> sys.stderr, '* bases:', bases
-        print >> sys.stderr, '* seq: ', seq
-        print >> sys.stderr, '*  output:  ', output
-        print >> sys.stderr, '*  expected:', expected
+            print('graph:', graph, file=sys.stderr)
+        print('* bases:', bases, file=sys.stderr)
+        print('* seq: ', seq, file=sys.stderr)
+        print('*  output:  ', output, file=sys.stderr)
+        print('*  expected:', expected, file=sys.stderr)
         nerrs[0] += 1
         gerrs[0] += 1
 
@@ -178,14 +178,14 @@ 
          13: [8]}
 
 def genlazyancestors(revs, stoprev=0, inclusive=False):
-    print ("%% lazy ancestor set for %s, stoprev = %s, inclusive = %s" %
-           (revs, stoprev, inclusive))
+    print(("%% lazy ancestor set for %s, stoprev = %s, inclusive = %s" %
+           (revs, stoprev, inclusive)))
     return ancestor.lazyancestors(graph.get, revs, stoprev=stoprev,
                                   inclusive=inclusive)
 
 def printlazyancestors(s, l):
-    print 'membership: %r' % [n for n in l if n in s]
-    print 'iteration:  %r' % list(s)
+    print('membership: %r' % [n for n in l if n in s])
+    print('iteration:  %r' % list(s))
 
 def test_lazyancestors():
     # Empty revs
@@ -235,9 +235,10 @@ 
                 cgcas = sorted(cl.index.ancestors(a, b))
                 pygcas = sorted(ancestor.ancestors(cl.parentrevs, a, b))
                 if cgcas != pygcas:
-                    print "test_gca: for dag %s, gcas for %d, %d:" % (dag, a, b)
-                    print "  C returned:      %s" % cgcas
-                    print "  Python returned: %s" % pygcas
+                    print("test_gca: for dag %s, gcas for %d, %d:"
+                         % (dag, a, b))
+                    print("  C returned:      %s" % cgcas)
+                    print("  Python returned: %s" % pygcas)
 
 def main():
     seed = None
diff -r af089c63c98d -r 86ad720eb4fc tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Sat Apr 02 17:29:38 2016 +0300
+++ b/tests/test-check-py3-compat.t	Sat Apr 02 17:33:11 2016 +0300
@@ -61,7 +61,6 @@ 
   tests/sitecustomize.py not using absolute_import
   tests/svn-safe-append.py not using absolute_import
   tests/svnxml.py not using absolute_import
-  tests/test-ancestor.py requires print_function
   tests/test-atomictempfile.py not using absolute_import
   tests/test-batching.py not using absolute_import
   tests/test-batching.py requires print_function
@@ -276,7 +275,6 @@ 
   tests/get-with-headers.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/silenttestrunner.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
-  tests/test-ancestor.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   tests/test-batching.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-bdiff.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-context.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)