changeset 28738:706f4ab710c8

py3: lexicographical order imports and print_function in test-context.py
author Robert Stanca <robert.stanca7@gmail.com>
date Sun, 03 Apr 2016 16:34:55 +0300
parents a3a01194a337
children d289b8847f23
files tests/test-check-py3-compat.t tests/test-context.py
diffstat 2 files changed, 49 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- 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
@@ -248,7 +247,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)
--- 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)))