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

login
register
mail settings
Submitter roby roby
Date March 31, 2016, 4:15 p.m.
Message ID <1aa23d597ac85bd8e53f.1459440926@roby>
Download mbox | patch
Permalink /patch/14206/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

roby roby - March 31, 2016, 4:15 p.m.
# HG changeset patch
# User Robert Stanca <robert.stanca7@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
Yuya Nishihara - April 1, 2016, 2:56 p.m.
On Thu, 31 Mar 2016 19:15:26 +0300, Robert Stanca wrote:
> # HG changeset patch
> # User Robert Stanca <robert.stanca7@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

I'll queue this, thanks.

> -    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)

I've dropped extra parens.

To committers:
Should I split this into seq.py and test-ancestor.py patches?

I don't think it's worth the effort, but the summary of the next patch is
too long. I could rewrite it to "in multiple files", but the result would
be repating patches of the same summary line.
Pierre-Yves David - April 1, 2016, 6:38 p.m.
On 04/01/2016 07:56 AM, Yuya Nishihara wrote:
> On Thu, 31 Mar 2016 19:15:26 +0300, Robert Stanca wrote:
>> # HG changeset patch
>> # User Robert Stanca <robert.stanca7@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
>
> I'll queue this, thanks.
>
>> -    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)
>
> I've dropped extra parens.
>
> To committers:
> Should I split this into seq.py and test-ancestor.py patches?

We probably want to stick to the "one change per patch idea" one 
category of change and one file per patch.
Yuya Nishihara - April 2, 2016, 3:07 a.m.
On Fri, 1 Apr 2016 11:38:54 -0700, Pierre-Yves David wrote:
> On 04/01/2016 07:56 AM, Yuya Nishihara wrote:
> > On Thu, 31 Mar 2016 19:15:26 +0300, Robert Stanca wrote:  
> >> # HG changeset patch
> >> # User Robert Stanca <robert.stanca7@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  
> >
> > I'll queue this, thanks.
> >  
> >> -    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)  
> >
> > I've dropped extra parens.
> >
> > To committers:
> > Should I split this into seq.py and test-ancestor.py patches?  
> 
> We probably want to stick to the "one change per patch idea" one
> category of change and one file per patch.

Ok. Robert, can you split this patch and resend them?

Patch

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)