[PATCH 1 of 5 V2] tests: use absolute_import, print_function in test-batching.py, test-bdiff.py, test-context.py
Robert Stanca
robert.stanca7 at gmail.com
Thu Mar 31 22:12:03 EDT 2016
# HG changeset patch
# User Robert Stanca <robert.stanca7 at gmail.com>
# Date 1459465779 -10800
# Fri Apr 01 02:09:39 2016 +0300
# Node ID 63418ac38fa7b4878ca074f6f8f1b8dbe7dc376c
# Parent ff0d3b6b287f89594bd8d0308fe2810d2a18ea01
tests: use absolute_import, print_function in test-batching.py, test-bdiff.py, test-context.py
Eliminate Python3 compatibility warnings
diff -r ff0d3b6b287f -r 63418ac38fa7 tests/test-batching.py
--- a/tests/test-batching.py Tue Mar 29 12:29:00 2016 -0500
+++ b/tests/test-batching.py Fri Apr 01 02:09:39 2016 +0300
@@ -5,8 +5,15 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-from mercurial.peer import localbatch, batchable, future
-from mercurial.wireproto import remotebatch
+from __future__ import absolute_import, print_function
+from mercurial.peer import (
+ localbatch,
+ batchable,
+ future,
+)
+from mercurial.wireproto import (
+ remotebatch,
+)
# equivalent of repo.repository
class thing(object):
@@ -31,11 +38,11 @@
def use(it):
# Direct call to base method shared between client and server.
- print it.hello()
+ print(it.hello())
# Direct calls to proxied methods. They cause individual roundtrips.
- print it.foo("Un", two="Deux")
- print it.bar("Eins", "Zwei")
+ print(it.foo("Un", two="Deux"))
+ print(it.bar("Eins", "Zwei"))
# Batched call to a couple of (possibly proxied) methods.
batch = it.batch()
@@ -53,17 +60,17 @@
# as possible.
batch.submit()
# After the call to submit, the futures actually contain values.
- print foo.value
- print foo2.value
- print bar.value
- print greet.value
- print hello.value
- print bar2.value
+ print(foo.value)
+ print(foo2.value)
+ print(bar.value)
+ print(greet.value)
+ print(hello.value)
+ print(bar2.value)
# local usage
mylocal = localthing()
-print
-print "== Local"
+print()
+print("== Local")
use(mylocal)
# demo remoting; mimicks what wireproto and HTTP/SSH do
@@ -93,12 +100,12 @@
args = dict(arg.split('=', 1) for arg in args)
return getattr(self, name)(**args)
def perform(self, req):
- print "REQ:", req
+ print("REQ:", req)
name, args = req.split('?', 1)
args = args.split('&')
vals = dict(arg.split('=', 1) for arg in args)
res = getattr(self, name)(**vals)
- print " ->", res
+ print(" ->", res)
return res
def batch(self, cmds):
res = []
@@ -171,6 +178,6 @@
# demo remote usage
myproxy = remotething(myserver)
-print
-print "== Remote"
+print()
+print("== Remote")
use(myproxy)
diff -r ff0d3b6b287f -r 63418ac38fa7 tests/test-bdiff.py
--- a/tests/test-bdiff.py Tue Mar 29 12:29:00 2016 -0500
+++ b/tests/test-bdiff.py Fri Apr 01 02:09:39 2016 +0300
@@ -1,5 +1,9 @@
+from __future__ import absolute_import, print_function
import struct
-from mercurial import bdiff, mpatch
+from mercurial import (
+ bdiff,
+ mpatch,
+)
def test1(a, b):
d = bdiff.bdiff(a, b)
@@ -7,13 +11,13 @@
if d:
c = mpatch.patches(a, [d])
if c != b:
- print "***", repr(a), repr(b)
- print "bad:"
- print repr(c)[:200]
- print repr(d)
+ print("***", repr(a), repr(b))
+ print("bad:")
+ print(repr(c)[:200])
+ print(repr(d))
def test(a, b):
- print "***", repr(a), repr(b)
+ print("***", repr(a), repr(b))
test1(a, b)
test1(b, a)
@@ -44,23 +48,23 @@
while pos < len(bin):
p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12])
pos += 12
- print p1, p2, repr(bin[pos:pos + l])
+ print(p1, p2, repr(bin[pos:pos + l]))
pos += l
showdiff("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\nx\n\nz\n")
showdiff("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\ny\n\nx\n\nz\n")
-print "done"
+print("done")
def testfixws(a, b, allws):
c = bdiff.fixws(a, allws)
if c != b:
- print "*** fixws", repr(a), repr(b), allws
- print "got:"
- print repr(c)
+ print("*** fixws", repr(a), repr(b), allws)
+ print("got:")
+ print(repr(c))
testfixws(" \ta\r b\t\n", "ab\n", 1)
testfixws(" \ta\r b\t\n", " a b\n", 0)
testfixws("", "", 1)
testfixws("", "", 0)
-print "done"
+print("done")
diff -r ff0d3b6b287f -r 63418ac38fa7 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 Fri Apr 01 02:09:39 2016 +0300
@@ -65,12 +65,6 @@
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
- tests/test-bdiff.py not using absolute_import
- tests/test-bdiff.py requires print_function
- tests/test-context.py not using absolute_import
- tests/test-context.py requires print_function
tests/test-demandimport.py not using absolute_import
tests/test-demandimport.py requires print_function
tests/test-doctest.py not using absolute_import
@@ -280,9 +274,6 @@
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)
tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
tests/test-duplicateoptions.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
tests/test-filecache.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
diff -r ff0d3b6b287f -r 63418ac38fa7 tests/test-context.py
--- a/tests/test-context.py Tue Mar 29 12:29:00 2016 -0500
+++ b/tests/test-context.py Fri Apr 01 02:09:39 2016 +0300
@@ -1,5 +1,11 @@
+from __future__ import absolute_import, print_function
import os
-from mercurial import hg, ui, context, encoding
+from mercurial import (
+ hg,
+ ui,
+ context,
+ encoding,
+)
u = ui.ui()
@@ -18,9 +24,9 @@
if os.name == 'nt':
d = repo[None]['foo'].date()
- print "workingfilectx.date = (%d, %d)" % (d[0], d[1])
+ print("workingfilectx.date = (%d, %d)" % (d[0], d[1]))
else:
- print "workingfilectx.date =", repo[None]['foo'].date()
+ print("workingfilectx.date =", repo[None]['foo'].date())
# test memctx with non-ASCII commit message
@@ -33,7 +39,7 @@
ctx.commit()
for enc in "ASCII", "Latin-1", "UTF-8":
encoding.encoding = enc
- print "%-8s: %s" % (enc, repo["tip"].description())
+ print("%-8s: %s" % (enc, repo["tip"].description()))
# test performing a status
@@ -48,15 +54,15 @@
ctxb = context.memctx(repo, [ctxa.node(), None], "test diff", ["foo"],
getfilectx, ctxa.user(), ctxa.date())
-print ctxb.status(ctxa)
+print(ctxb.status(ctxa))
# test performing a diff on a memctx
for d in ctxb.diff(ctxa, git=True):
- print d
+ print(d)
# test safeness and correctness of "ctx.status()"
-print '= checking context.status():'
+print('= checking context.status():')
# ancestor "wcctx ~ 2"
actx2 = repo['.']
@@ -82,26 +88,26 @@
from mercurial import scmutil
-print '== checking workingctx.status:'
+print('== checking workingctx.status:')
wctx = repo[None]
-print 'wctx._status=%s' % (str(wctx._status))
+print('wctx._status=%s' % (str(wctx._status)))
-print '=== with "pattern match":'
-print actx1.status(other=wctx,
- match=scmutil.matchfiles(repo, ['bar-m', 'foo']))
-print 'wctx._status=%s' % (str(wctx._status))
-print actx2.status(other=wctx,
- match=scmutil.matchfiles(repo, ['bar-m', 'foo']))
-print 'wctx._status=%s' % (str(wctx._status))
+print('=== with "pattern match":')
+print(actx1.status(other=wctx,
+ match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
+print('wctx._status=%s' % (str(wctx._status)))
+print(actx2.status(other=wctx,
+ match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
+print('wctx._status=%s' % (str(wctx._status)))
-print '=== with "always match" and "listclean=True":'
-print actx1.status(other=wctx, listclean=True)
-print 'wctx._status=%s' % (str(wctx._status))
-print actx2.status(other=wctx, listclean=True)
-print 'wctx._status=%s' % (str(wctx._status))
+print('=== with "always match" and "listclean=True":')
+print(actx1.status(other=wctx, listclean=True))
+print('wctx._status=%s' % (str(wctx._status)))
+print(actx2.status(other=wctx, listclean=True))
+print('wctx._status=%s' % (str(wctx._status)))
-print "== checking workingcommitctx.status:"
+print("== checking workingcommitctx.status:")
wcctx = context.workingcommitctx(repo,
scmutil.status(['bar-m'],
@@ -109,34 +115,34 @@
[],
[], [], [], []),
text='', date='0 0')
-print 'wcctx._status=%s' % (str(wcctx._status))
+print('wcctx._status=%s' % (str(wcctx._status)))
-print '=== with "always match":'
-print actx1.status(other=wcctx)
-print 'wcctx._status=%s' % (str(wcctx._status))
-print actx2.status(other=wcctx)
-print 'wcctx._status=%s' % (str(wcctx._status))
+print('=== with "always match":')
+print(actx1.status(other=wcctx))
+print('wcctx._status=%s' % (str(wcctx._status)))
+print(actx2.status(other=wcctx))
+print('wcctx._status=%s' % (str(wcctx._status)))
-print '=== with "always match" and "listclean=True":'
-print actx1.status(other=wcctx, listclean=True)
-print 'wcctx._status=%s' % (str(wcctx._status))
-print actx2.status(other=wcctx, listclean=True)
-print 'wcctx._status=%s' % (str(wcctx._status))
+print('=== with "always match" and "listclean=True":')
+print(actx1.status(other=wcctx, listclean=True))
+print('wcctx._status=%s' % (str(wcctx._status)))
+print(actx2.status(other=wcctx, listclean=True))
+print('wcctx._status=%s' % (str(wcctx._status)))
-print '=== with "pattern match":'
-print actx1.status(other=wcctx,
- match=scmutil.matchfiles(repo, ['bar-m', 'foo']))
-print 'wcctx._status=%s' % (str(wcctx._status))
-print actx2.status(other=wcctx,
- match=scmutil.matchfiles(repo, ['bar-m', 'foo']))
-print 'wcctx._status=%s' % (str(wcctx._status))
+print('=== with "pattern match":')
+print(actx1.status(other=wcctx,
+ match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
+print('wcctx._status=%s' % (str(wcctx._status)))
+print(actx2.status(other=wcctx,
+ match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
+print('wcctx._status=%s' % (str(wcctx._status)))
-print '=== with "pattern match" and "listclean=True":'
-print actx1.status(other=wcctx,
+print('=== with "pattern match" and "listclean=True":')
+print(actx1.status(other=wcctx,
match=scmutil.matchfiles(repo, ['bar-r', 'foo']),
- listclean=True)
-print 'wcctx._status=%s' % (str(wcctx._status))
-print actx2.status(other=wcctx,
+ listclean=True))
+print('wcctx._status=%s' % (str(wcctx._status)))
+print(actx2.status(other=wcctx,
match=scmutil.matchfiles(repo, ['bar-r', 'foo']),
- listclean=True)
-print 'wcctx._status=%s' % (str(wcctx._status))
+ listclean=True))
+print('wcctx._status=%s' % (str(wcctx._status)))
More information about the Mercurial-devel
mailing list