Index: Lib/test/test_urllib2.py =================================================================== --- Lib/test/test_urllib2.py (revision 67015) +++ Lib/test/test_urllib2.py (working copy) @@ -47,6 +47,56 @@ self.assertEquals(urllib2.parse_http_list(string), list) +def test_case_insensitive_dict(): + """ + Original key case is preserved + + >>> sorted(urllib2.CaseInsensitiveDict(spam="eggs", Eggs="spam").items()) + [('Eggs', 'spam'), ('spam', 'eggs')] + + Lookup is case-insensitive + + >>> urllib2.CaseInsensitiveDict(spam="eggs")["SPAM"] + 'eggs' + + The most recently set item for each case-canonicalized key is returned on + key lookup + + >>> r = urllib2.CaseInsensitiveDict(spam="eggs") + >>> r["SPAM"] = "spam" + >>> r["spam"] + 'spam' + + but all of the items that were set still remain (jlee: I think this is pretty confusing behaviour) + + >>> sorted(r.items()) + [('SPAM', 'spam'), ('spam', 'eggs')] + + Inherited methods preserve invariants + + >>> r = urllib2.CaseInsensitiveDict(spam="eggs") + >>> r["spam"] = "eggs" + >>> r["SPAM"] = "spam" + >>> del r['SPAM'] + >>> r.items() + [('spam', 'eggs')] + >>> 'spam' in r + True + + >>> r = urllib2.CaseInsensitiveDict(spam="eggs") + >>> r.update({'SPAM': 'spam'}) + >>> r['spam'] + 'spam' + + Non-string keys are not allowed + + >>> r = urllib2.CaseInsensitiveDict({None: 'spam'}) + Traceback (most recent call last): + TypeError + + """ + + def test_request_headers_dict(): """ The Request.headers dictionary is not a documented interface. It should