[PATCH 1 of 2 V2] tests: use absolute_import and print_function in seq.py , test-ancestor.py

Robert Stanca robert.stanca7 at gmail.com
Thu Mar 31 16:15:26 UTC 2016


# HG changeset patch
# User Robert Stanca <robert.stanca7 at gmail.com>
# Date 1459436991 -10800
#      Thu Mar 31 18:09:51 2016 +0300
# Node ID 1aa23d597ac85bd8e53f92281a6251e58b9405d7
# Parent  ff0d3b6b287f89594bd8d0308fe2810d2a18ea01
tests: use absolute_import and print_function in seq.py , test-ancestor.py

Eliminate Pyhton3 compatibility warnings

diff -r ff0d3b6b287f -r 1aa23d597ac8 tests/seq.py
--- a/tests/seq.py	Tue Mar 29 12:29:00 2016 -0500
+++ b/tests/seq.py	Thu Mar 31 18:09:51 2016 +0300
@@ -7,6 +7,7 @@
 #   seq START STOP        [START, STOP] stepping by 1
 #   seq START STEP STOP   [START, STOP] stepping by STEP
 
+from __future__ import absolute_import, print_function
 import sys
 
 start = 1
@@ -20,4 +21,4 @@
 stop = int(sys.argv[-1]) + 1
 
 for i in xrange(start, stop, step):
-    print i
+    print(i)
diff -r ff0d3b6b287f -r 1aa23d597ac8 tests/test-ancestor.py
--- a/tests/test-ancestor.py	Tue Mar 29 12:29:00 2016 -0500
+++ b/tests/test-ancestor.py	Thu Mar 31 18:09:51 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 ff0d3b6b287f -r 1aa23d597ac8 tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Tue Mar 29 12:29:00 2016 -0500
+++ b/tests/test-check-py3-compat.t	Thu Mar 31 18:09:51 2016 +0300
@@ -56,14 +56,11 @@
   tests/readlink.py requires print_function
   tests/revlog-formatv0.py not using absolute_import
   tests/run-tests.py not using absolute_import
-  tests/seq.py not using absolute_import
-  tests/seq.py requires print_function
   tests/silenttestrunner.py not using absolute_import
   tests/silenttestrunner.py requires print_function
   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
@@ -277,9 +274,7 @@
   tests/generate-working-copy-states.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
   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/seq.py: invalid syntax: Missing parentheses in call to 'print' (<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)


More information about the Mercurial-devel mailing list