# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1460759784 -19800 # Node ID c4040a35b5d9ba55c90a68f06312bae670dfa05c # Parent 6262f0215d08fd39b2bd75e9822f420031565221 tests: make test-trusted use print_function There was some confusing output format at some places in test-trusted.py.out, the new print function ends with a newline by default whereas the old print statement uses a space generally. So the output in test-trusted.py.out is changed because of some confusing output format which was produced by print statement diff -r 6262f0215d08 -r c4040a35b5d9 tests/test-check-py3-compat.t --- a/tests/test-check-py3-compat.t Sat Apr 16 03:38:23 2016 +0530 +++ b/tests/test-check-py3-compat.t Sat Apr 16 04:06:24 2016 +0530 @@ -55,7 +55,6 @@ tests/test-atomictempfile.py not using absolute_import tests/test-demandimport.py not using absolute_import tests/test-demandimport.py requires print_function - tests/test-trusted.py requires print_function #if py3exe $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py @@ -188,6 +187,5 @@ mercurial/wireproto.py: error importing module: invalid syntax (bundle*.py, line *) (line *) (glob) tests/readlink.py: invalid syntax: invalid syntax (, line *) (glob) tests/test-demandimport.py: invalid syntax: invalid syntax (, line *) (glob) - tests/test-trusted.py: invalid syntax: invalid syntax (, line *) (glob) #endif diff -r 6262f0215d08 -r c4040a35b5d9 tests/test-trusted.py --- 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) diff -r 6262f0215d08 -r c4040a35b5d9 tests/test-trusted.py.out --- a/tests/test-trusted.py.out Sat Apr 16 03:38:23 2016 +0530 +++ b/tests/test-trusted.py.out Sat Apr 16 04:06:24 2016 +0530 @@ -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