diff options
author | Georg Brandl <georg@python.org> | 2006-05-28 20:23:12 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-05-28 20:23:12 (GMT) |
commit | 2b3303761180af657e0c8c112b7d770bb7b87a9f (patch) | |
tree | e533d8fd2d44eda15620b3802c47940128792503 /Lib/test/test_urllib2.py | |
parent | 0fd1291c38a8b8aed57bcdbf030fffe3fb42a241 (diff) | |
download | cpython-2b3303761180af657e0c8c112b7d770bb7b87a9f.zip cpython-2b3303761180af657e0c8c112b7d770bb7b87a9f.tar.gz cpython-2b3303761180af657e0c8c112b7d770bb7b87a9f.tar.bz2 |
Patch #1496206: urllib2 PasswordMgr ./. default ports
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r-- | Lib/test/test_urllib2.py | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 9203e37..32cc612 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -76,10 +76,11 @@ def test_password_manager(self): >>> mgr.find_user_password("c", "http://example.com/bar") ('bar', 'nini') - Currently, we use the highest-level path where more than one match: + Actually, this is really undefined ATM +## Currently, we use the highest-level path where more than one match: - >>> mgr.find_user_password("Some Realm", "http://example.com/ni") - ('joe', 'password') +## >>> mgr.find_user_password("Some Realm", "http://example.com/ni") +## ('joe', 'password') Use latest add_password() in case of conflict: @@ -110,6 +111,53 @@ def test_password_manager(self): pass +def test_password_manager_default_port(self): + """ + >>> mgr = urllib2.HTTPPasswordMgr() + >>> add = mgr.add_password + + The point to note here is that we can't guess the default port if there's + no scheme. This applies to both add_password and find_user_password. + + >>> add("f", "http://g.example.com:80", "10", "j") + >>> add("g", "http://h.example.com", "11", "k") + >>> add("h", "i.example.com:80", "12", "l") + >>> add("i", "j.example.com", "13", "m") + >>> mgr.find_user_password("f", "g.example.com:100") + (None, None) + >>> mgr.find_user_password("f", "g.example.com:80") + ('10', 'j') + >>> mgr.find_user_password("f", "g.example.com") + (None, None) + >>> mgr.find_user_password("f", "http://g.example.com:100") + (None, None) + >>> mgr.find_user_password("f", "http://g.example.com:80") + ('10', 'j') + >>> mgr.find_user_password("f", "http://g.example.com") + ('10', 'j') + >>> mgr.find_user_password("g", "h.example.com") + ('11', 'k') + >>> mgr.find_user_password("g", "h.example.com:80") + ('11', 'k') + >>> mgr.find_user_password("g", "http://h.example.com:80") + ('11', 'k') + >>> mgr.find_user_password("h", "i.example.com") + (None, None) + >>> mgr.find_user_password("h", "i.example.com:80") + ('12', 'l') + >>> mgr.find_user_password("h", "http://i.example.com:80") + ('12', 'l') + >>> mgr.find_user_password("i", "j.example.com") + ('13', 'm') + >>> mgr.find_user_password("i", "j.example.com:80") + (None, None) + >>> mgr.find_user_password("i", "http://j.example.com") + ('13', 'm') + >>> mgr.find_user_password("i", "http://j.example.com:80") + (None, None) + + """ + class MockOpener: addheaders = [] def open(self, req, data=None): |