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

Pulkit Goyal 7895pulkit at gmail.com
Tue Apr 12 16:48:16 EDT 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1460493329 -19800
#      Wed Apr 13 02:05:29 2016 +0530
# Node ID 8111970b9a0dbb08cb6da59b0e79db0b4aedcdce
# Parent  f05f5bc8ea2f98a3f77232d8a50745014363c115
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
@@ -65,7 +65,6 @@
   tests/test-run-tests.py not using absolute_import
   tests/test-simplemerge.py not using absolute_import
   tests/test-symlink-os-yes-fs-no.py not using absolute_import
-  tests/test-trusted.py requires print_function
   tests/test-ui-color.py not using absolute_import
   tests/test-url.py not using absolute_import
 
@@ -202,6 +201,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 = ui.uimod()
     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 '.',
-        u.config('paths', name) # warning with debug=True
-        print '.',
-        u.config('paths', name, untrusted=True) # no warnings
-        print name, '=', path
-    print
+        print('.',
+        u.config('paths', name)) # warning with debug=True
+        print('.',
+        u.config('paths', name, untrusted=True)) # no warnings
+        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)


More information about the Mercurial-devel mailing list