[PATCH 8 of 8 v3] tests: make test-trusted use print_function

Pulkit Goyal 7895pulkit at gmail.com
Wed Apr 13 16:01:51 EDT 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1460576434 -19800
#      Thu Apr 14 01:10:34 2016 +0530
# Node ID cee512d555a4741c18c1cfa5c95e7496a47b63e2
# Parent  6b0befc9866f13cfa1aaa8610e37a4c5e89a89c0
tests: make test-trusted use print_function

diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -61,7 +61,6 @@
   tests/test-lrucachedict.py requires print_function
   tests/test-manifest.py not using absolute_import
   tests/test-pathencode.py not using absolute_import
-  tests/test-trusted.py requires print_function
 
 #if py3exe
   $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py
@@ -195,6 +194,5 @@
   tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   tests/test-lrucachedict.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
-  tests/test-trusted.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
 
 #endif
diff --git a/tests/test-trusted.py b/tests/test-trusted.py
--- a/tests/test-trusted.py
+++ b/tests/test-trusted.py
@@ -2,7 +2,7 @@
 # with files from different users/groups, we cheat a bit by
 # monkey-patching some functions in the util module
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import os
 from mercurial import (
@@ -63,8 +63,8 @@
     trusted = who[(user in tusers) + 2*(group in tgroups)]
     if trusted:
         trusted = ', but we trust the ' + trusted
-    print '# %s user, %s group%s' % (kind[user == cuser], kind[group == cgroup],
-                                     trusted)
+    print('# %s user, %s group%s' % (kind[user == cuser], kind[group == cgroup],
+                                     trusted))
 
     u = uimod.ui()
     u.setconfig('ui', 'debug', str(bool(debug)))
@@ -72,17 +72,17 @@
     u.readconfig('.hg/hgrc')
     if silent:
         return u
-    print 'trusted'
+    print('trusted')
     for name, path in u.configitems('paths'):
-        print '   ', name, '=', path
-    print 'untrusted'
+        print('   ', name, '=', path)
+    print('untrusted')
     for name, path in u.configitems('paths', untrusted=True):
-        print '.',
+        print('.', end=' ')
         u.config('paths', name) # warning with debug=True
-        print '.',
+        print('.', end=' ')
         u.config('paths', name, untrusted=True) # no warnings
-        print name, '=', path
-    print
+        print(name, '=', path)
+    print()
 
     return u
 
@@ -113,49 +113,49 @@
 # ... but we trust the user and the group
 testui(user='abc', group='def', tusers=['abc'], tgroups=['def'])
 # ... but we trust all users
-print '# we trust all users'
+print('# we trust all users')
 testui(user='abc', group='def', tusers=['*'])
 # ... but we trust all groups
-print '# we trust all groups'
+print('# we trust all groups')
 testui(user='abc', group='def', tgroups=['*'])
 # ... but we trust the whole universe
-print '# we trust all users and groups'
+print('# we trust all users and groups')
 testui(user='abc', group='def', tusers=['*'], tgroups=['*'])
 # ... check that users and groups are in different namespaces
-print "# we don't get confused by users and groups with the same name"
+print("# we don't get confused by users and groups with the same name")
 testui(user='abc', group='def', tusers=['def'], tgroups=['abc'])
 # ... lists of user names work
-print "# list of user names"
+print("# list of user names")
 testui(user='abc', group='def', tusers=['foo', 'xyz', 'abc', 'bleh'],
        tgroups=['bar', 'baz', 'qux'])
 # ... lists of group names work
-print "# list of group names"
+print("# list of group names")
 testui(user='abc', group='def', tusers=['foo', 'xyz', 'bleh'],
        tgroups=['bar', 'def', 'baz', 'qux'])
 
-print "# Can't figure out the name of the user running this process"
+print("# Can't figure out the name of the user running this process")
 testui(user='abc', group='def', cuser=None)
 
-print "# prints debug warnings"
+print("# prints debug warnings")
 u = testui(user='abc', group='def', cuser='foo', debug=True)
 
-print "# report_untrusted enabled without debug hides warnings"
+print("# report_untrusted enabled without debug hides warnings")
 u = testui(user='abc', group='def', cuser='foo', report=False)
 
-print "# report_untrusted enabled with debug shows warnings"
+print("# report_untrusted enabled with debug shows warnings")
 u = testui(user='abc', group='def', cuser='foo', debug=True, report=False)
 
-print "# ui.readconfig sections"
+print("# ui.readconfig sections")
 filename = 'foobar'
 f = open(filename, 'w')
 f.write('[foobar]\n')
 f.write('baz = quux\n')
 f.close()
 u.readconfig(filename, sections=['foobar'])
-print u.config('foobar', 'baz')
+print(u.config('foobar', 'baz'))
 
-print
-print "# read trusted, untrusted, new ui, trusted"
+print()
+print("# read trusted, untrusted, new ui, trusted")
 u = uimod.ui()
 u.setconfig('ui', 'debug', 'on')
 u.readconfig(filename)
@@ -164,30 +164,30 @@
     return 'foo'
 util.username = username
 u2.readconfig('.hg/hgrc')
-print 'trusted:'
-print u2.config('foobar', 'baz')
-print 'untrusted:'
-print u2.config('foobar', 'baz', untrusted=True)
+print('trusted:')
+print(u2.config('foobar', 'baz'))
+print('untrusted:')
+print(u2.config('foobar', 'baz', untrusted=True))
 
-print
-print "# error handling"
+print()
+print("# error handling")
 
 def assertraises(f, exc=error.Abort):
     try:
         f()
     except exc as inst:
-        print 'raised', inst.__class__.__name__
+        print('raised', inst.__class__.__name__)
     else:
-        print 'no exception?!'
+        print('no exception?!')
 
-print "# file doesn't exist"
+print("# file doesn't exist")
 os.unlink('.hg/hgrc')
 assert not os.path.exists('.hg/hgrc')
 testui(debug=True, silent=True)
 testui(user='abc', group='def', debug=True, silent=True)
 
-print
-print "# parse error"
+print()
+print("# parse error")
 f = open('.hg/hgrc', 'w')
 f.write('foo')
 f.close()
@@ -195,9 +195,9 @@
 try:
     testui(user='abc', group='def', silent=True)
 except error.ParseError as inst:
-    print inst
+    print(inst)
 
 try:
     testui(debug=True, silent=True)
 except error.ParseError as inst:
-    print inst
+    print(inst)
diff --git a/tests/test-trusted.py.out b/tests/test-trusted.py.out
--- a/tests/test-trusted.py.out
+++ b/tests/test-trusted.py.out
@@ -133,7 +133,7 @@
     global = /some/path
 untrusted
 . . global = /some/path
-.ignoring untrusted configuration option paths.local = /another/path
+. ignoring untrusted configuration option paths.local = /another/path
 . local = /another/path
 
 # report_untrusted enabled without debug hides warnings
@@ -152,7 +152,7 @@
     global = /some/path
 untrusted
 . . global = /some/path
-.ignoring untrusted configuration option paths.local = /another/path
+. ignoring untrusted configuration option paths.local = /another/path
 . local = /another/path
 
 # ui.readconfig sections


More information about the Mercurial-devel mailing list