config root man

Current Path : /usr/local/lib/python2.5/test/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/local/lib/python2.5/test/test_urllib2.pyc

hRc
@sddkZddklZddkZddkZddkZddkZddklZlZdei	fdYZ
dZdZdZ
d	Zd
fdYZdfd
YZdefdYZdeifdYZdfdYZdfdYZdfdYZdZdZdeifdYZdfdYZdei	fdYZd Zd!ei	fd"YZd#ei	fd$YZe d%Z!e"d&joe!d'e#ndS((iN(ttest_support(tRequesttOpenerDirectortTrivialTestscBseZdZdZRS(cCs|ittidtiitiidd}|dd!djo|d}nti	djod|idd}nKti	djo:d	dk
}ti|}|i|i
d
d}nd|}ti|}|i}|idS(
Ns	bogus urls\t/iit:tmactriscosis/.s./s	file://%s(tassertRaisest
ValueErrorturllib2turlopentostpathtabspatht__file__treplacetnametstringtexpandt	translatet	maketranstreadtclose(tselftfnameRtfile_urltftbuf((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_trivials!
c
Csddddgfdddgfdddd	d
ddd
gfddddgfg}x-|D]%\}}|iti||q^WdS(Nsa,b,ctatbtcspath"o,l"og"i"cal, examplespath"o,l"og"i"caltexamplesa, b, "c", "d", "e,f", g, hs"c"s"d"s"e,f"tgthsa="b\"c", d="e\,f", g="h\\i"sa="b"c"sd="e,f"sg="h\i"(tassertEqualsR
tparse_http_list(RttestsRtlist((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_parse_http_list(s(t__name__t
__module__RR((((s-/usr/local/lib/python2.5/test/test_urllib2.pyRs	cCsdS(s
    The Request.headers dictionary is not a documented interface.  It should
    stay that way, because the complete set of headers are only accessible
    through the .get_header(), .has_header(), .header_items() interface.
    However, .headers pre-dates those methods, and so real code will be using
    the dictionary.

    The introduction in 2.4 of those methods was a mistake for the same reason:
    code that previously saw all (urllib2 user)-provided headers in .headers
    now sees only a subset (and the function interface is ugly and incomplete).
    A better change would have been to replace .headers dict with a dict
    subclass (or UserDict.DictMixin instance?)  that preserved the .headers
    interface and also provided access to the "unredirected" headers.  It's
    probably too late to fix that, though.


    Check .capitalize() case normalization:

    >>> url = "http://example.com"
    >>> Request(url, headers={"Spam-eggs": "blah"}).headers["Spam-eggs"]
    'blah'
    >>> Request(url, headers={"spam-EggS": "blah"}).headers["Spam-eggs"]
    'blah'

    Currently, Request(url, "Spam-eggs").headers["Spam-Eggs"] raises KeyError,
    but that could be changed in future.

    N((((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_request_headers_dict1scCsdS(s
    Note the case normalization of header names here, to .capitalize()-case.
    This should be preserved for backwards-compatibility.  (In the HTTP case,
    normalization to .title()-case is done by urllib2 before sending headers to
    httplib).

    >>> url = "http://example.com"
    >>> r = Request(url, headers={"Spam-eggs": "blah"})
    >>> r.has_header("Spam-eggs")
    True
    >>> r.header_items()
    [('Spam-eggs', 'blah')]
    >>> r.add_header("Foo-Bar", "baz")
    >>> items = r.header_items()
    >>> items.sort()
    >>> items
    [('Foo-bar', 'baz'), ('Spam-eggs', 'blah')]

    Note that e.g. r.has_header("spam-EggS") is currently False, and
    r.get_header("spam-EggS") returns None, but that could be changed in
    future.

    >>> r.has_header("Not-there")
    False
    >>> print r.get_header("Not-there")
    None
    >>> r.get_header("Not-there", "default")
    'default'

    N((((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_request_headers_methodsOscCsdS(s
    >>> mgr = urllib2.HTTPPasswordMgr()
    >>> add = mgr.add_password
    >>> add("Some Realm", "http://example.com/", "joe", "password")
    >>> add("Some Realm", "http://example.com/ni", "ni", "ni")
    >>> add("c", "http://example.com/foo", "foo", "ni")
    >>> add("c", "http://example.com/bar", "bar", "nini")
    >>> add("b", "http://example.com/", "first", "blah")
    >>> add("b", "http://example.com/", "second", "spam")
    >>> add("a", "http://example.com", "1", "a")
    >>> add("Some Realm", "http://c.example.com:3128", "3", "c")
    >>> add("Some Realm", "d.example.com", "4", "d")
    >>> add("Some Realm", "e.example.com:3128", "5", "e")

    >>> mgr.find_user_password("Some Realm", "example.com")
    ('joe', 'password')
    >>> mgr.find_user_password("Some Realm", "http://example.com")
    ('joe', 'password')
    >>> mgr.find_user_password("Some Realm", "http://example.com/")
    ('joe', 'password')
    >>> mgr.find_user_password("Some Realm", "http://example.com/spam")
    ('joe', 'password')
    >>> mgr.find_user_password("Some Realm", "http://example.com/spam/spam")
    ('joe', 'password')
    >>> mgr.find_user_password("c", "http://example.com/foo")
    ('foo', 'ni')
    >>> mgr.find_user_password("c", "http://example.com/bar")
    ('bar', 'nini')

    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')

    Use latest add_password() in case of conflict:

    >>> mgr.find_user_password("b", "http://example.com/")
    ('second', 'spam')

    No special relationship between a.example.com and example.com:

    >>> mgr.find_user_password("a", "http://example.com/")
    ('1', 'a')
    >>> mgr.find_user_password("a", "http://a.example.com/")
    (None, None)

    Ports:

    >>> mgr.find_user_password("Some Realm", "c.example.com")
    (None, None)
    >>> mgr.find_user_password("Some Realm", "c.example.com:3128")
    ('3', 'c')
    >>> mgr.find_user_password("Some Realm", "http://c.example.com:3128")
    ('3', 'c')
    >>> mgr.find_user_password("Some Realm", "d.example.com")
    ('4', 'd')
    >>> mgr.find_user_password("Some Realm", "e.example.com:3128")
    ('5', 'e')

    N((R((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_password_managerps>cCsdS(sV
    >>> 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)

    N((R((s-/usr/local/lib/python2.5/test/test_urllib2.pyt"test_password_manager_default_portst
MockOpenercBs#eZgZddZdZRS(cCs|||_|_dS(N(treqtdata(RR0R1((s-/usr/local/lib/python2.5/test/test_urllib2.pytopenscGs|||_|_dS(N(tprototargs(RR3R4((s-/usr/local/lib/python2.5/test/test_urllib2.pyterrorsN(R)R*t
addheaderstNoneR2R5(((s-/usr/local/lib/python2.5/test/test_urllib2.pyR/stMockFilecBs)eZddZddZdZRS(cCsdS(N((Rtcount((s-/usr/local/lib/python2.5/test/test_urllib2.pyRscCsdS(N((RR9((s-/usr/local/lib/python2.5/test/test_urllib2.pytreadlinescCsdS(N((R((s-/usr/local/lib/python2.5/test/test_urllib2.pyRsN(R)R*R7RR:R(((s-/usr/local/lib/python2.5/test/test_urllib2.pyR8stMockHeaderscBseZdZRS(cCs
|iS(N(tvalues(RR((s-/usr/local/lib/python2.5/test/test_urllib2.pyt
getheaderss(R)R*R=(((s-/usr/local/lib/python2.5/test/test_urllib2.pyR;stMockResponsecBs&eZddZdZdZRS(cCsAtii||||||f\|_|_|_|_dS(N(tStringIOt__init__tcodetmsgtheadersturl(RRARBRCR1RD((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@scCs|iS(N(RC(R((s-/usr/local/lib/python2.5/test/test_urllib2.pytinfoscCs|iS(N(RD(R((s-/usr/local/lib/python2.5/test/test_urllib2.pytgeturlsN(R)R*R7R@RERF(((s-/usr/local/lib/python2.5/test/test_urllib2.pyR>s	t
MockCookieJarcBseZdZdZRS(cCs
||_dS(N(tach_req(Rtrequest((s-/usr/local/lib/python2.5/test/test_urllib2.pytadd_cookie_headerscCs|||_|_dS(N(tec_reqtec_r(RtresponseRI((s-/usr/local/lib/python2.5/test/test_urllib2.pytextract_cookiess(R)R*RJRN(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRGs	t
FakeMethodcBseZdZdZRS(cCs||_||_||_dS(N(t	meth_namethandletaction(RRPRRRQ((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@s		cGs|i|i|i|S(N(RQRPRR(RR4((s-/usr/local/lib/python2.5/test/test_urllib2.pyt__call__s(R)R*R@RS(((s-/usr/local/lib/python2.5/test/test_urllib2.pyROs	tMockHandlercBsDeZdZdZdZdZdZdZdZRS(icCs|i|dS(N(t_define_methods(Rtmethods((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@scCsmxf|D]^}t|djo|\}}n|d}}t|||i}t|i||qWdS(Ni(tlenR7RORQtsetattrt	__class__(RRVtspecRRRtmeth((s-/usr/local/lib/python2.5/test/test_urllib2.pyRU
s
cOsI|iii||||f|djodSn|djo|Sn|djotddhd}|Sn|djotdSn|idoy||id	d
}yt|}Wnt	j
onXtddhd}|ii
d|d||dhSn!|d
jotidnt
ptdS(Nsreturn selfsreturn responseitOKtsreturn requestshttp://blah/R5t ithttpitraisetblah(tparenttcallstappendR7R>Rt
startswithtrfindtintR	R5R
tURLErrortFalsetAssertionError(Rtfn_nameRRR4tkwdstresRA((s-/usr/local/lib/python2.5/test/test_urllib2.pyRQs*



'
cCsdS(N((R((s-/usr/local/lib/python2.5/test/test_urllib2.pyR)scCs||_g|i_dS(N(RbRc(RRb((s-/usr/local/lib/python2.5/test/test_urllib2.pyt
add_parent*s	cCs(t|dptSn|i|ijS(Nt
handler_order(thasattrtTrueRo(Rtother((s-/usr/local/lib/python2.5/test/test_urllib2.pyt__lt__-s(	R)R*RoR@RURQRRnRs(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRTs					cCsg}d}xp|D]h}dtfdY}||}|i|7_|i||d}|i||i|qW|S(sCreate MockHandlers and add them to an OpenerDirector.

    meth_spec: list of lists of tuples and strings defining methods to define
    on handlers.  eg:

    [["http_error", "ftp_open"], ["http_open"]]

    defines methods .http_error() and .ftp_open() on one handler, and
    .http_open() on another.  These methods just record their arguments and
    return None.  Using a tuple instead of a string causes the method to
    perform some action (see MockHandler.handle()), eg:

    [["http_error"], [("http_open", "return request")]]

    defines .http_error() on one handler (which simply returns None), and
    .http_open() on another handler, which returns a Request object.

    itMockHandlerSubclasscBseZRS((R)R*(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRtIsi(RTRoRnRdtadd_handler(topenert	meth_specthandlersR9tmethsRtR#((s-/usr/local/lib/python2.5/test/test_urllib2.pytadd_ordered_mock_handlers3s


cGs+t}x|D]}|i|qW|S(N(RRu(thandler_instancesRvR#((s-/usr/local/lib/python2.5/test/test_urllib2.pytbuild_test_openerRs
	tMockHTTPHandlercBs#eZdZdZdZRS(cCs ||_||_|idS(N(RARCtreset(RRARC((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@\s		cCsd|_g|_dS(Ni(t_counttrequests(R((s-/usr/local/lib/python2.5/test/test_urllib2.pyR~`s	cCsddk}ddk}ddk}ddkl}|ii|i||idjoa|id|_|i|i	}|i
||i}|ii
d|t|i	||Sn;||_|i
|d}tdd|d	|iSdS(
Ni(R?iiR_s

iR\R](t	mimetoolsthttplibtcopyR?RRdtdeepcopyRt	responsesRAtMessageRCRbR5R8R0R>tget_full_url(RR0RRRR?RRB((s-/usr/local/lib/python2.5/test/test_urllib2.pyt	http_opencs$	 	(R)R*R@R~R(((s-/usr/local/lib/python2.5/test/test_urllib2.pyR}Xs		tMockPasswordManagercBseZdZdZRS(cCs(||_||_||_||_dS(N(trealmRDtusertpassword(RRturiRR((s-/usr/local/lib/python2.5/test/test_urllib2.pytadd_passwordss			cCs"||_||_|i|ifS(N(ttarget_realmt
target_urlRR(RRtauthuri((s-/usr/local/lib/python2.5/test/test_urllib2.pytfind_user_passwordxs		(R)R*RR(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRrs	tOpenerDirectorTestscBsGeZdZdZdZdZdZdZdZRS(cCs6dtfdY}|itti|dS(Nt
NonHandlercBseZRS((R)R*(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRs(tobjectRt	TypeErrorRRu(RR((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_add_non_handlers	cCsddkl}t}ddgd
gg}t||}|itix(dD] }|i||i|d
qWWdS(Ni(Rhtdo_opensreturn selft
proxy_opentredirect_requesttdotproxytredirects://example.com/(sdo_opensreturn self(Rsreturn self(Rsreturn self(RRsredirect(R
RhRRzRutUnknownHandlerRR2(RRhtoRwRxtscheme((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_badly_named_methodss			c
Cst}dddgdgdgd	gg}t||}td}|i|}|i||d|ddf|ddfg}x[t||iD]G\}}|\}	}
}}|i|	|
f||i||fqWdS(
NRtftp_openthttp_error_302sreturn selfshttp://example.com/ii(s	http_opensreturn self(s	http_opensreturn self(RRzRR2tassertEqualtzipRc(
RRRwRxR0trRctexpectedtgotthandlerRR4Rl((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_handleds	 cCst}g}xqd	gdfdgdfgD]Q\}}dtfdY}||}||_|i||i|q.W|id}|i|idd|d|i|idd|ddS(
NRsreturn selfiiRtcBseZRS((R)R*(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRtsshttp://example.com/i(s	http_opensreturn self(RRTRoRdRuR2RRc(RRRxRyRoRtR#R((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_handler_orders		
cCs|t}dgdgg}t||}td}|iti|i||i|i|dd|fhfgdS(NRR`sreturn selfshttp://example.com/i(s	http_opensraise(s	http_opensreturn self(	RRzRRR
RhR2RRc(RRRwRxR0((s-/usr/local/lib/python2.5/test/test_urllib2.pyt
test_raises	c
Cs)t}dgddgdddgdgg}t||}d	dd
Y}td}|i|}t|idjpt|d
d|ff|dd||ddhffg}x]t||iD]I\}}	|\}
}}|i|
|f|	d |i||	dqWdS(NRs	error 302thttp_error_400R`Rsreturn responsethttp_error_303t
http_errortUnknowncBseZdZRS(cSstS(N(Rq(RRr((s-/usr/local/lib/python2.5/test/test_urllib2.pyt__eq__s(R)R*R(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRsshttp://example.com/iii.R](s	http_opens	error 302(Rsraise(shttp_error_302sreturn response((	RRzRR2RWRcRjRR(
RRRwRxRR0RRcRRRtmethod_nameR4((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_http_errors&		
cCst}d	d
gddgg}t||}td}|i|}|ddf|ddf|ddf|ddfg}xt|iD]\}\}}	}
}|djoN|i||	f|||it|
d|it	|
dtq|i||	f|||it|
d|it	|
dt|i|
ddjpt	|
dtqWdS(
Nthttp_requestsreturn requestt
http_responsesreturn responseshttp://example.com/iii(shttp_requestsreturn request(s
http_responsesreturn response(shttp_requestsreturn request(s
http_responsesreturn response(RRzRR2t	enumerateRcRRWtassert_t
isinstanceR7R>(RRRwRxR0RRctiRRR4Rl((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_processorss*	 
(	R)R*RRRRRRR(((s-/usr/local/lib/python2.5/test/test_urllib2.pyR~s						cCsMddk}|i|}tidjo|ido|d}n|S(Nitnts///i(turllibtpathname2urlRRRe(R
Rturlpath((s-/usr/local/lib/python2.5/test/test_urllib2.pytsanepathname2urls
 tHandlerTestscBsteZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
RS(csdddYdtiffdY}ddk}ddk}d}||}t}|_xodd|id	d
dgdd
fddddd
dgddfdd|idgddfgD]
\}}}	}
}}}
|it	|}|i
|i|ijo
djn|i
|i|i||i
|i|	|i
|i||i
|ii||i
|ii|
|i}|i
|id|
|i
t|dt|qWdS(NtMockFTPWrappercBseZdZdZRS(cSs
||_dS(N(R1(RR1((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@#scSs2|||_|_ti|it|ifS(N(tfilenametfiletypeR?R1RW(RRR((s-/usr/local/lib/python2.5/test/test_urllib2.pytretrfile$s(R)R*R@R(((s-/usr/local/lib/python2.5/test/test_urllib2.pyR"s	tNullFTPHandlercs eZdZfdZRS(cSs
||_dS(N(R1(RR1((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@)scsH|||_|_|||_|_||_|i|_|iS(N(RtpasswdthosttporttdirsR1t
ftpwrapper(RRRRRR(R(s-/usr/local/lib/python2.5/test/test_urllib2.pytconnect_ftp*s
	(R)R*R@R((R(s-/usr/local/lib/python2.5/test/test_urllib2.pyR(s	isrheum rhaponicums ftp://localhost/foo/bar/baz.htmlt	localhosttItfootbarsbaz.htmls	text/htmlsftp://localhost:80/foo/bar/iPtDR]sftp://localhost/baz.gif;type=atAsbaz.gifsContent-typesContent-length((R
t
FTPHandlertftplibtsocketR/RbtFTP_PORTR7RRRRRRRt
gethostbynameRRRRRREtgetRgRW(RRRRR1R#RRDRRttype_RRtmimetypeRRC((Rs-/usr/local/lib/python2.5/test/test_urllib2.pyttest_ftp!s6		*cCs6ddk}ddk}ddk}ti}t}|_ti}t	t
ii|}d}d|d|d|i
d|fg}	y|i
|i}
Wn|ij
o
d}
nX|
o|	id|
|fnx	|	D]}t|d}zz|i|Wd|iX|it|}
z(|
i}|
i}|
i}Wd|
iXt
i|}|i|i}Wdt
i|X|i|||i|d	d
|i|dd|i|d
|qWxwd|gD]h}zQt|d}z|i|Wd|iX|iti|it|Wdt
i|XqWti}t}|_xdt fdt!fdt!fgD]\}}t|}y|i|Wn*tit"fj
o|i#|qX|i#|i$|j|i|i%dqWdS(Nis
hello, world
sfile://localhost%ss	file://%ssfile://%s%sRR]twbsContent-types
text/plainsContent-lengtht13s
Last-modifiedsfile://localhost:80%ssfile://ftp.example.com//foo.txts file://ftp.example.com///foo.txtsfile://ftp.example.com/foo.txttftp(&ttimetrfc822RR
tFileHandlerR/RbRtTESTFNRRR
RRtgethostnametgaierrorRdR2twriteRt	file_openRRRERFtstatt
formatdatetst_mtimetremoveRRRhRqRitOSErrorRR0ttype(RRRRR#RRRttowriteturlst	localaddrRDRRR1RCtnewurltstatstmodifiedRR0((s-/usr/local/lib/python2.5/test/test_urllib2.pyt	test_fileMsx$			
c	sNdddYddfdY}ti}t}|_d}x@ddgD]2\}}t||hd	d
<}|idd|}|i||}	|	i|	i	|	i
|	i|	i|	i
d
jdf|	i
}
|
i|
i|i|	i||i|id|i|id|i|i||i|id|i|id d!d"g|i|i|q[Wt|_|iti|i||d#g|_xd$D]}}td|}td
dhd}	|i|}|djo0|id|ij|id|ijn/|i|idd|i|idd|i|idd|i|idd|idd|idd	|idd|idd|i|}|i|idd|i|idd	|i|idd|i|iddqWdS(%NtMockHTTPResponsecBseZdZdZRS(cSs(||_||_||_||_dS(N(tfpRBtstatustreason(RRRBRR((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@s			cSsdS(NR]((R((s-/usr/local/lib/python2.5/test/test_urllib2.pyRs(R)R*R@R(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRs	t
MockHTTPClasscsAeZdZdZdZdhdZfdZRS(cSsg|_d|_t|_dS(N(treq_headersR7R1Ritraise_on_endheaders(R((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@s		cSs
||_|S(N(R(RR((s-/usr/local/lib/python2.5/test/test_urllib2.pyRSs	cSs
||_dS(N(tlevel(RR((s-/usr/local/lib/python2.5/test/test_urllib2.pytset_debuglevelscSsr||_||_|i|i7_|ii|o
||_n|ioddk}|indS(Ni(	tmethodtselectorRtitemstsortR1RRR5(RRRDtbodyRCR((s-/usr/local/lib/python2.5/test/test_urllib2.pyRIs		


csthddS(NiR\(R8(R(R(s-/usr/local/lib/python2.5/test/test_urllib2.pytgetresponsesN(R)R*R@RSRR7RIR((R(s-/usr/local/lib/python2.5/test/test_urllib2.pyRs
			
shttp://example.com/tGETtPOSTRaRtFootSpamteggsiR\sexample.comiRt
ConnectionRR]sContent-lengthsContent-typet0s!application/x-www-form-urlencodedtHostRtbaz(((RN(Rsblah(Rsclose(Rsbar(RR(RR(R]N( R
tAbstractHTTPHandlerR/RbR7Rtadd_unredirected_headerRRR:RERFRARBRthas_keyRRRRRRR1RqRRRhR6R>tdo_request_Rtunredirected_hdrs(RRR#RRDRR1R0R_Rthdrstnewreq((Rs-/usr/local/lib/python2.5/test/test_urllib2.pyt	test_httpsj
	
	
cCsti}t}|_d}t|}tddhd|}|i||}|i||j|it|dtddhd|}|i|i||dj|i
|id|i
|i||ddhfdS(	Nshttp://example.com/iR\R]R3itCreatedR_(
R
tHTTPErrorProcessorR/RbRR>RRRpR7RR3R4(RR#RRDR0Rtnewr((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_errorsscCst}ti|}t}|_td}tddhd}|i|}|i|i	|jo
|jn|i
|id|i|i|i
||}|i|i|j|i|i|jo
|jndS(Nshttp://example.com/iR\R]sexample.com(RGR
tHTTPCookieProcessorR/RbRR>RRRHR$tget_origin_req_hosttis_unverifiableRRKRL(RtcjR#RR0RRR((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_cookiess	'cCsd}d}ti}t}|_xudD]m}xddD]\}t|d|}t||}|id	d
|iddy,||t	|d
t
h|d<Wn6tij
o'|i|djo
|dj	nX|i
|ii|y|i
|iidWn*tj
o|i|iinX|i
|iid	d
|id|iij|id|iijq<Wq/Wt|}|d}	t|dd}d}
y$x|	||d|
d}
qWn,tij
o|i
|
tiinXt|dd}d}
y(x!|	||d|
|
d}
qAWn,tij
o|i
|
tiinXdS(Nshttp://example.com/a.htmlshttp://example.com/b.htmli-i.i/i3s
blah
blah
s
http_error_%stNonsensesviking=withholdRtspamtBlahtlocationRc
Ss/|i|tddth|d<dS(Ni.RR(RR8R;(R#R0RD((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@storigin_req_hostsexample.comishttp://example.com/ishttp://example.com/%d(i-i.i/i3(Ns
blah
blah
(R
tHTTPRedirectHandlerR/RbR7tgetattrRt
add_headerRR8R;t	HTTPErrorRRR0Rt
get_methodtAttributeErrorthas_dataRCRtmax_repeatstmax_redirections(Rtfrom_urltto_urlR#RRAR1RR0RR9((s-/usr/local/lib/python2.5/test/test_urllib2.pyt
test_redirect!sZ%!	c	Csddkl}ddkl}|}||ddtdd}ti}ti}ti|}t	||||}|i
d|i|ii
ddS(	Ni(t	CookieJar(tinteract_netscapeshttp://www.example.com/s	spam=eggsi.s%Location: http://www.cracker.com/

tCookie(t	cookielibR-ttest.test_cookielibR.R}R
tHTTPDefaultErrorHandlerR!RR|R2RR0t
has_header(	RR-R.RthhthdehthrhtcpR((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_cookie_redirect\s	
c	Cst}titdd}|i|d	gg}t||}td}|i|id|i	|}|i|id|i|ddfgg}|i
D]}||dd!q~dS(
NR_sproxy.example.com:3128Rsreturn responseshttp://acme.example.com/sacme.example.comii(s	http_opensreturn response(RR
tProxyHandlertdictRuRzRRtget_hostR2Rc(	RRtphRwRxR0Rt_[1]ttup((s-/usr/local/lib/python2.5/test/test_urllib2.pyt
test_proxyls	
c	Cszt}t}ti|}d}tdd|}|i||i||i||d|||dddS(NsACME Widget Storeis&WWW-Authenticate: Basic realm="%s"

t
Authorizations!http://acme.example.com/protected(RRR
tHTTPBasicAuthHandlerR}Rut_test_basic_auth(RRvtpassword_managertauth_handlerRthttp_handler((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_basic_auth}s		

	c	Cst}titdd}|i|t}ti|}d}tdd|}|i||i||i||d|||dddS(NR_sproxy.example.com:3128s
ACME Networksis(Proxy-Authenticate: Basic realm="%s"

sProxy-authorizations&http://acme.example.com:3128/protected(	RR
R9R:RuRtProxyBasicAuthHandlerR}RB(RRvR<RCRDRRE((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_proxy_basic_auths	
	

	c
	CsdtfdY}dtifdY}dtifdY}|}t}||}||}d}tdd	|}	|i||i||i|	|i||d
||	|dd|i|i	dd
gddS(NtRecordingOpenerDirectorcBseZdZdZRS(cSsti|g|_dS(N(RR@trecorded(R((s-/usr/local/lib/python2.5/test/test_urllib2.pyR@s
cSs|ii|dS(N(RJRd(RRE((s-/usr/local/lib/python2.5/test/test_urllib2.pytrecords(R)R*R@RK(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRIs	tTestDigestAuthHandlercBseZdZRS(c_s*|iidtii|||dS(Ntdigest(RbRKR
tHTTPDigestAuthHandlerthttp_error_401(RR4Rl((s-/usr/local/lib/python2.5/test/test_urllib2.pyROs(R)R*RO(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRLstTestBasicAuthHandlercBseZdZRS(c_s*|iidtii|||dS(Ntbasic(RbRKR
RARO(RR4Rl((s-/usr/local/lib/python2.5/test/test_urllib2.pyROs(R)R*RO(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRPss
ACME Networksis&WWW-Authenticate: Basic realm="%s"

R@s!http://acme.example.com/protectedRMRQi(
RR
RNRARR}RuRBRRJ(
RRIRLRPRvRCtdigest_handlert
basic_handlerRRE((s-/usr/local/lib/python2.5/test/test_urllib2.pyt#test_basic_and_digest_auth_handlerss$			


	c	Csddk}	ddk}
d	\}}|i|||||i||i|i||i|i||i|i||i|i|}
|i|i	||i|i
||it|id|i
|idi|d||f}d|	i|i}|i|idi||d|_|_|i|i|}
|it|id|i
|idi|dS(
Nitwiletcoyoteiis%s:%ssBasic i(RURV(tbase64RRRRRDRRR2RRRWRtassertFalseR3tencodestringtstript
get_headerR7R~(RRvRDtauth_headerRRERCtrequest_urlt
protected_urlRWRRRRtuserpasstauth_hdr_value((s-/usr/local/lib/python2.5/test/test_urllib2.pyRBs*
(R)R*RRRRRR,R8R?RFRHRTRB(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRs	,	Y	[			;					/t	MiscTestscBseZdZdZRS(cCsdtifdY}dtifdY}dtifdY}ti}|||}|i|||i|||||}|i|||i||||}|i|||}|i|ti|ti}|i|ti|ti}|i|tidtifdY}|||}|i|||i||dS(	Nt
MyHTTPHandlercBseZRS((R)R*(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRbst
FooHandlercBseZdZRS(cSsdS(N((R((s-/usr/local/lib/python2.5/test/test_urllib2.pytfoo_opens(R)R*Rd(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRcst
BarHandlercBseZdZRS(cSsdS(N((R((s-/usr/local/lib/python2.5/test/test_urllib2.pytbar_opens(R)R*Rf(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRestMyOtherHTTPHandlercBseZRS((R)R*(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRgs(R
tHTTPHandlertBaseHandlertbuild_openertopener_has_handler(RRbRcReRjRRg((s-/usr/local/lib/python2.5/test/test_urllib2.pyttest_build_openers,		cCs:x3|iD]}|i|joPq
q
W|itdS(N(RxRYRRi(RRvt
handler_classR#((s-/usr/local/lib/python2.5/test/test_urllib2.pyRks

	(R)R*RlRk(((s-/usr/local/lib/python2.5/test/test_urllib2.pyRas	%cCsSddkl}ti||tit|ttttf}ti	|dS(Ni(ttest_urllib2(
ttestRnRtrun_doctestR
RRRRatrun_unittest(tverboseRnR&((s-/usr/local/lib/python2.5/test/test_urllib2.pyt	test_mains	t__main__Rr($tunittestRoRRRR?R
RRtTestCaseRR+R,R-R.R/R8R:R;R>RGRORTRzR|RiR}RRRRRaR7RsR)Rq(((s-/usr/local/lib/python2.5/test/test_urllib2.pys<module>s:"		!	A	/	,			/



Man Man