[PATCH 1 of 6 V2] tests: lexicographical order imports and print_function in test-context.py

Robert Stanca robert.stanca7 at gmail.com
Sun Apr 3 14:30:30 UTC 2016


# HG changeset patch
# User Robert Stanca <robert.stanca7 at gmail.com>
# Date 1459690495 -10800
#      Sun Apr 03 16:34:55 2016 +0300
# Node ID 7c86c35aea02711df6fbdbd7310c3d111f42c6b6
# Parent  c5531417666c9fc712d4f9302f51dbb480dc9c63
tests: lexicographical order imports and print_function in test-context.py

diff -r c5531417666c -r 7c86c35aea02 tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Sun Apr 03 08:26:57 2016 +0100
+++ b/tests/test-check-py3-compat.t	Sun Apr 03 16:34:55 2016 +0300
@@ -53,7 +53,6 @@
   tests/svn-safe-append.py not using absolute_import
   tests/svnxml.py not using absolute_import
   tests/test-atomictempfile.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
@@ -223,7 +222,6 @@
   mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)
   mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
   tests/readlink.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 c5531417666c -r 7c86c35aea02 tests/test-context.py
--- a/tests/test-context.py	Sun Apr 03 08:26:57 2016 +0100
+++ b/tests/test-context.py	Sun Apr 03 16:34:55 2016 +0300
@@ -1,10 +1,10 @@
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 import os
 from mercurial import (
+    context,
+    encoding,
     hg,
     ui,
-    context,
-    encoding,
 )
 
 u = ui.ui()
@@ -24,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
 
@@ -39,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
 
@@ -54,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['.']
@@ -88,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'],
@@ -115,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