comparison tests/test-hgweb-auth.py @ 28883:032c4c2f802a

pycompat: switch to util.urlreq/util.urlerr for py3 compat
author timeless <timeless@mozdev.org>
date Wed, 06 Apr 2016 23:22:12 +0000
parents 10c2ce44c35d
children 2c019aac6b99
comparison
equal deleted inserted replaced
28882:800ec7c048b0 28883:032c4c2f802a
1 from __future__ import absolute_import, print_function 1 from __future__ import absolute_import, print_function
2 2
3 from mercurial import demandimport; demandimport.enable() 3 from mercurial import demandimport; demandimport.enable()
4 import urllib2
5 from mercurial import ( 4 from mercurial import (
6 error, 5 error,
7 ui as uimod, 6 ui as uimod,
8 url, 7 url,
9 util, 8 util,
10 ) 9 )
10
11 urlerr = util.urlerr
12 urlreq = util.urlreq
11 13
12 class myui(uimod.ui): 14 class myui(uimod.ui):
13 def interactive(self): 15 def interactive(self):
14 return False 16 return False
15 17
102 'y.password': 'ypassword'}, 104 'y.password': 'ypassword'},
103 urls=['http://y@example.org/foo/bar']) 105 urls=['http://y@example.org/foo/bar'])
104 106
105 def testauthinfo(fullurl, authurl): 107 def testauthinfo(fullurl, authurl):
106 print('URIs:', fullurl, authurl) 108 print('URIs:', fullurl, authurl)
107 pm = urllib2.HTTPPasswordMgrWithDefaultRealm() 109 pm = urlreq.httppasswordmgrwithdefaultrealm()
108 pm.add_password(*util.url(fullurl).authinfo()[1]) 110 pm.add_password(*util.url(fullurl).authinfo()[1])
109 print(pm.find_user_password('test', authurl)) 111 print(pm.find_user_password('test', authurl))
110 112
111 print('\n*** Test urllib2 and util.url\n') 113 print('\n*** Test urllib2 and util.url\n')
112 testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo') 114 testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo')