##// END OF EJS Templates
tests: make test-trusted use print_function...
Pulkit Goyal -
r28934:c4040a35 default
parent child Browse files
Show More
@@ -55,7 +55,6 b''
55 tests/test-atomictempfile.py not using absolute_import
55 tests/test-atomictempfile.py not using absolute_import
56 tests/test-demandimport.py not using absolute_import
56 tests/test-demandimport.py not using absolute_import
57 tests/test-demandimport.py requires print_function
57 tests/test-demandimport.py requires print_function
58 tests/test-trusted.py requires print_function
59
58
60 #if py3exe
59 #if py3exe
61 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py
60 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py
@@ -188,6 +187,5 b''
188 mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
187 mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
189 tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
188 tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
190 tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
189 tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
191 tests/test-trusted.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
192
190
193 #endif
191 #endif
@@ -2,7 +2,7 b''
2 # with files from different users/groups, we cheat a bit by
2 # with files from different users/groups, we cheat a bit by
3 # monkey-patching some functions in the util module
3 # monkey-patching some functions in the util module
4
4
5 from __future__ import absolute_import
5 from __future__ import absolute_import, print_function
6
6
7 import os
7 import os
8 from mercurial import (
8 from mercurial import (
@@ -63,8 +63,8 b" def testui(user='foo', group='bar', tuse"
63 trusted = who[(user in tusers) + 2*(group in tgroups)]
63 trusted = who[(user in tusers) + 2*(group in tgroups)]
64 if trusted:
64 if trusted:
65 trusted = ', but we trust the ' + trusted
65 trusted = ', but we trust the ' + trusted
66 print '# %s user, %s group%s' % (kind[user == cuser], kind[group == cgroup],
66 print('# %s user, %s group%s' % (kind[user == cuser], kind[group == cgroup],
67 trusted)
67 trusted))
68
68
69 u = uimod.ui()
69 u = uimod.ui()
70 u.setconfig('ui', 'debug', str(bool(debug)))
70 u.setconfig('ui', 'debug', str(bool(debug)))
@@ -72,17 +72,17 b" def testui(user='foo', group='bar', tuse"
72 u.readconfig('.hg/hgrc')
72 u.readconfig('.hg/hgrc')
73 if silent:
73 if silent:
74 return u
74 return u
75 print 'trusted'
75 print('trusted')
76 for name, path in u.configitems('paths'):
76 for name, path in u.configitems('paths'):
77 print ' ', name, '=', path
77 print(' ', name, '=', path)
78 print 'untrusted'
78 print('untrusted')
79 for name, path in u.configitems('paths', untrusted=True):
79 for name, path in u.configitems('paths', untrusted=True):
80 print '.',
80 print('.', end=' ')
81 u.config('paths', name) # warning with debug=True
81 u.config('paths', name) # warning with debug=True
82 print '.',
82 print('.', end=' ')
83 u.config('paths', name, untrusted=True) # no warnings
83 u.config('paths', name, untrusted=True) # no warnings
84 print name, '=', path
84 print(name, '=', path)
85 print
85 print()
86
86
87 return u
87 return u
88
88
@@ -113,49 +113,49 b" testui(user='abc', group='def', tgroups="
113 # ... but we trust the user and the group
113 # ... but we trust the user and the group
114 testui(user='abc', group='def', tusers=['abc'], tgroups=['def'])
114 testui(user='abc', group='def', tusers=['abc'], tgroups=['def'])
115 # ... but we trust all users
115 # ... but we trust all users
116 print '# we trust all users'
116 print('# we trust all users')
117 testui(user='abc', group='def', tusers=['*'])
117 testui(user='abc', group='def', tusers=['*'])
118 # ... but we trust all groups
118 # ... but we trust all groups
119 print '# we trust all groups'
119 print('# we trust all groups')
120 testui(user='abc', group='def', tgroups=['*'])
120 testui(user='abc', group='def', tgroups=['*'])
121 # ... but we trust the whole universe
121 # ... but we trust the whole universe
122 print '# we trust all users and groups'
122 print('# we trust all users and groups')
123 testui(user='abc', group='def', tusers=['*'], tgroups=['*'])
123 testui(user='abc', group='def', tusers=['*'], tgroups=['*'])
124 # ... check that users and groups are in different namespaces
124 # ... check that users and groups are in different namespaces
125 print "# we don't get confused by users and groups with the same name"
125 print("# we don't get confused by users and groups with the same name")
126 testui(user='abc', group='def', tusers=['def'], tgroups=['abc'])
126 testui(user='abc', group='def', tusers=['def'], tgroups=['abc'])
127 # ... lists of user names work
127 # ... lists of user names work
128 print "# list of user names"
128 print("# list of user names")
129 testui(user='abc', group='def', tusers=['foo', 'xyz', 'abc', 'bleh'],
129 testui(user='abc', group='def', tusers=['foo', 'xyz', 'abc', 'bleh'],
130 tgroups=['bar', 'baz', 'qux'])
130 tgroups=['bar', 'baz', 'qux'])
131 # ... lists of group names work
131 # ... lists of group names work
132 print "# list of group names"
132 print("# list of group names")
133 testui(user='abc', group='def', tusers=['foo', 'xyz', 'bleh'],
133 testui(user='abc', group='def', tusers=['foo', 'xyz', 'bleh'],
134 tgroups=['bar', 'def', 'baz', 'qux'])
134 tgroups=['bar', 'def', 'baz', 'qux'])
135
135
136 print "# Can't figure out the name of the user running this process"
136 print("# Can't figure out the name of the user running this process")
137 testui(user='abc', group='def', cuser=None)
137 testui(user='abc', group='def', cuser=None)
138
138
139 print "# prints debug warnings"
139 print("# prints debug warnings")
140 u = testui(user='abc', group='def', cuser='foo', debug=True)
140 u = testui(user='abc', group='def', cuser='foo', debug=True)
141
141
142 print "# report_untrusted enabled without debug hides warnings"
142 print("# report_untrusted enabled without debug hides warnings")
143 u = testui(user='abc', group='def', cuser='foo', report=False)
143 u = testui(user='abc', group='def', cuser='foo', report=False)
144
144
145 print "# report_untrusted enabled with debug shows warnings"
145 print("# report_untrusted enabled with debug shows warnings")
146 u = testui(user='abc', group='def', cuser='foo', debug=True, report=False)
146 u = testui(user='abc', group='def', cuser='foo', debug=True, report=False)
147
147
148 print "# ui.readconfig sections"
148 print("# ui.readconfig sections")
149 filename = 'foobar'
149 filename = 'foobar'
150 f = open(filename, 'w')
150 f = open(filename, 'w')
151 f.write('[foobar]\n')
151 f.write('[foobar]\n')
152 f.write('baz = quux\n')
152 f.write('baz = quux\n')
153 f.close()
153 f.close()
154 u.readconfig(filename, sections=['foobar'])
154 u.readconfig(filename, sections=['foobar'])
155 print u.config('foobar', 'baz')
155 print(u.config('foobar', 'baz'))
156
156
157 print
157 print()
158 print "# read trusted, untrusted, new ui, trusted"
158 print("# read trusted, untrusted, new ui, trusted")
159 u = uimod.ui()
159 u = uimod.ui()
160 u.setconfig('ui', 'debug', 'on')
160 u.setconfig('ui', 'debug', 'on')
161 u.readconfig(filename)
161 u.readconfig(filename)
@@ -164,30 +164,30 b' def username(uid=None):'
164 return 'foo'
164 return 'foo'
165 util.username = username
165 util.username = username
166 u2.readconfig('.hg/hgrc')
166 u2.readconfig('.hg/hgrc')
167 print 'trusted:'
167 print('trusted:')
168 print u2.config('foobar', 'baz')
168 print(u2.config('foobar', 'baz'))
169 print 'untrusted:'
169 print('untrusted:')
170 print u2.config('foobar', 'baz', untrusted=True)
170 print(u2.config('foobar', 'baz', untrusted=True))
171
171
172 print
172 print()
173 print "# error handling"
173 print("# error handling")
174
174
175 def assertraises(f, exc=error.Abort):
175 def assertraises(f, exc=error.Abort):
176 try:
176 try:
177 f()
177 f()
178 except exc as inst:
178 except exc as inst:
179 print 'raised', inst.__class__.__name__
179 print('raised', inst.__class__.__name__)
180 else:
180 else:
181 print 'no exception?!'
181 print('no exception?!')
182
182
183 print "# file doesn't exist"
183 print("# file doesn't exist")
184 os.unlink('.hg/hgrc')
184 os.unlink('.hg/hgrc')
185 assert not os.path.exists('.hg/hgrc')
185 assert not os.path.exists('.hg/hgrc')
186 testui(debug=True, silent=True)
186 testui(debug=True, silent=True)
187 testui(user='abc', group='def', debug=True, silent=True)
187 testui(user='abc', group='def', debug=True, silent=True)
188
188
189 print
189 print()
190 print "# parse error"
190 print("# parse error")
191 f = open('.hg/hgrc', 'w')
191 f = open('.hg/hgrc', 'w')
192 f.write('foo')
192 f.write('foo')
193 f.close()
193 f.close()
@@ -195,9 +195,9 b' f.close()'
195 try:
195 try:
196 testui(user='abc', group='def', silent=True)
196 testui(user='abc', group='def', silent=True)
197 except error.ParseError as inst:
197 except error.ParseError as inst:
198 print inst
198 print(inst)
199
199
200 try:
200 try:
201 testui(debug=True, silent=True)
201 testui(debug=True, silent=True)
202 except error.ParseError as inst:
202 except error.ParseError as inst:
203 print inst
203 print(inst)
General Comments 0
You need to be logged in to leave comments. Login now