--- a/tests/test-trusted.py Sat Apr 16 03:38:23 2016 +0530
+++ b/tests/test-trusted.py Sat Apr 16 04:06:24 2016 +0530
@@ -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)