Current File : //opt/imh-python/lib/python2.7/test/test_urllib2.pyo
�
��Wc@s�ddlZddlmZddlmZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlZyddlZWne
k
r�eZnXdejfd��YZd�Zd�Zd	�Zd
�Zdfd��YZd
fd��YZdefd��YZdejfd��YZdfd��YZdfd��YZdfd��YZdfd��YZdfd��YZd�Zd�Z dej!fd ��YZ"d!ej#fd"��YZ$d#fd$��YZ%d%ejfd&��YZ&d'�Z'd(ejfd)��YZ(d*ejfd+��YZ)d,ejfd-��YZ*ed.�Z+e,d/kr�e+d0e-�ndS(1i����N(ttest_support(ttest_urllib(tRequesttOpenerDirectortAbstractDigestAuthHandlertTrivialTestscBs5eZd�Zd�Zejed�d��ZRS(cCs�|jttjd�tjjtj�jtj	d�}tj
dkr�ddl}tj|�}|j
|jdd��}ntj
dkr�d|}n
d	|}tj|�}|j�}|j�dS(
Ns	bogus urlt/triscosi����s/.s./tnts
file:///%ss	file://%s(tassertRaisest
ValueErrorturllib2turlopentostpathtabspatht__file__treplacetseptnametstringtexpandt	translatet	maketranstreadtclose(tselftfnameRtfile_urltftbuf((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_trivials$

c
Cs�ddddgfdddgfdddd	d
ddd
gfddddgfg}x-|D]%\}}|jtj|�|�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"(tassertEqualRtparse_http_list(RttestsRtlist((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_parse_http_list1ssssl module requiredc
Cs?tj�}|jt��tjdddd|�WdQXdS(Nshttps://localhosttcafiles/nonexistent/pathtcontext(tssltcreate_default_contextR	R
RR(RR,((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_cafile_and_context9s(t__name__t
__module__RR*tunittestt
skipUnlessR-R/(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/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((((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_request_headers_dictBscCsdS(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((((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_request_headers_methods`scCsdS(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((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_password_manager�s>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((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt"test_password_manager_default_port�st
MockOpenercBs)eZgZdejd�Zd�ZRS(cCs!||||_|_|_dS(N(treqtdatattimeout(RR9R:R;((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytopen�scGs|||_|_dS(N(tprototargs(RR=R>((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyterror�sN(R0R1t
addheaderstNonetsockett_GLOBAL_DEFAULT_TIMEOUTR<R?(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR8�stMockFilecBs)eZdd�Zdd�Zd�ZRS(cCsdS(N((Rtcount((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�scCsdS(N((RRE((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytreadline�scCsdS(N((R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�sN(R0R1RARRFR(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRD�stMockHeaderscBseZd�ZRS(cCs
|j�S(N(tvalues(RR((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
getheaders�s(R0R1RI(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRG�stMockResponsecBs&eZdd�Zd�Zd�ZRS(cCsAtjj||�||||f\|_|_|_|_dS(N(tStringIOt__init__tcodetmsgtheadersturl(RRMRNROR:RP((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRLscCs|jS(N(RO(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytinfoscCs|jS(N(RP(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytgeturlsN(R0R1RARLRQRR(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRJs	t
MockCookieJarcBseZd�Zd�ZRS(cCs
||_dS(N(tach_req(Rtrequest((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytadd_cookie_headerscCs|||_|_dS(N(tec_reqtec_r(RtresponseRU((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytextract_cookies
s(R0R1RVRZ(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRS
s	t
FakeMethodcBseZd�Zd�ZRS(cCs||_||_||_dS(N(t	meth_namethandletaction(RR\R^R]((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRLs		cGs|j|j|j|�S(N(R]R\R^(RR>((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt__call__s(R0R1RLR_(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR[s	tMockHTTPResponsecBseZd�Zd�ZRS(cCs(||_||_||_||_dS(N(tfpRNtstatustreason(RRaRNRbRc((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRLs			cCsdS(Nt((R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRs(R0R1RLR(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR`s	t
MockHTTPClasscBsYeZd�Zejd�Zd�Zddd�Zddd�Z	d�Z
d�ZRS(cCs(g|_d|_t|_i|_dS(N(treq_headersRAR:tFalsetraise_on_endheaderst_tunnel_headers(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRL"s			cCs||_||_|S(N(thostR;(RRjR;((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR_(s		cCs
||_dS(N(tlevel(RRk((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytset_debuglevel-scCs5||_||_|r$||_n
|jj�dS(N(t_tunnel_hostt_tunnel_portRitclear(RRjtportRO((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
set_tunnel0s
		cCs}||_||_|dk	r6|j|j�7_n|jj�|rU||_n|jryddl}|j	��ndS(Ni����(
tmethodtselectorRARftitemstsortR:RhRBR?(RRrRPtbodyRORB((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRU8s		
	cCstt�idd�S(Ni�tOK(R`RD(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytgetresponseDscCsdS(N((R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRGsN(R0R1RLRBRCR_RlRARqRURxR(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRe!s			tMockHandlercBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(i�cCs|j|�dS(N(t_define_methods(Rtmethods((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRLNscCskxd|D]\}t|�dkr.|\}}n
|d}}t|||j�}t|j||�qWdS(Ni(tlenRAR[R]tsetattrt	__class__(RR{tspecRR^tmeth((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRzPs

cOs|jjj||||f�|dkr/dS|dkr?|S|dkrdtddid�}|S|dkrztd�S|jd�r�||jd	�d
}yt|�}Wnt	k
r�nXtddid�}|jj
d|d||di�S|d
krtjd��ndS(Nsreturn selfsreturn responsei�RwRdsreturn requestshttp://blah/R?t ithttpitraisetblah(
tparenttcallstappendRARJRt
startswithtrfindtintR
R?RtURLError(Rtfn_nameR^R>tkwdstresRM((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR]Vs*

#cCsdS(N((R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRlscCs||_g|j_dS(N(R�R�(RR�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
add_parentms	cCs#t|d�stS|j|jkS(Nt
handler_order(thasattrtTrueR�(Rtother((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt__lt__ps(	R0R1R�RLRzR]RR�R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRyJs					cCs�g}d}xp|D]h}dtfd��Y}||�}|j|7_|j|�|d}|j|�|j|�qW|S(s�Create 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((R0R1(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��si(RyR�R�R�tadd_handler(topenert	meth_specthandlersREtmethsR�R%((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytadd_ordered_mock_handlersvs



cGs+t�}x|D]}|j|�qW|S(N(RR�(thandler_instancesR�R%((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytbuild_test_opener�s	
tMockHTTPHandlercBs#eZd�Zd�Zd�ZRS(cCs ||_||_|j�dS(N(RMROtreset(RRMRO((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRL�s		cCsd|_g|_dS(Ni(t_counttrequests(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s	cCs�ddl}ddl}ddlm}|jj|j|��|jdkr�|jd|_tj|j	}|j
||j��}|jj
d|t�|j	||�S||_|j
|d��}tdd|d	|j��SdS(
Ni����(RKiiR�s

i�RwRd(t	mimetoolstcopyRKR�R�tdeepcopyR�thttplibt	responsesRMtMessageROR�R?RDR9RJtget_full_url(RR9R�R�RKRRN((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt	http_open�s		(R0R1RLR�R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s		tMockHTTPSHandlercBseZd�Zd�ZRS(cCs tjj|�t�|_dS(N(RtAbstractHTTPHandlerRLRethttpconn(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRL�scCs|j|j|�S(N(tdo_openR�(RR9((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
https_open�s(R0R1RLR�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s	tMockPasswordManagercBseZd�Zd�ZRS(cCs(||_||_||_||_dS(N(trealmRPtusertpassword(RR�turiR�R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytadd_password�s			cCs"||_||_|j|jfS(N(ttarget_realmt
target_urlR�R�(RR�tauthuri((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytfind_user_password�s		(R0R1R�R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s	tOpenerDirectorTestscBsGeZd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs6dtfd��Y}|jtt�j|��dS(Nt
NonHandlercBseZRS((R0R1(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s(tobjectR	t	TypeErrorRR�(RR�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_add_non_handler�s	cCsddlm}t�}ddgd
gg}t||�}|jtj��x(dD] }|j||j|d
�qWWdS(Ni����(R�R�sreturn selft
proxy_opentredirect_requesttdotproxytredirects://example.com/(sdo_opensreturn self(R�sreturn self(R�sreturn self(R�sproxysredirect(RR�RR�R�tUnknownHandlerR	R<(RR�toR�R�tscheme((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_badly_named_methods�s			
c
Cs�t�}dddgdgdgd	gg}t||�}td�}|j|�}|j||d�|ddf|ddfg}x[t||j�D]G\}}|\}	}
}}|j|	|
f|�|j||f�q�WdS(
NR�tftp_openthttp_error_302sreturn selfshttp://example.com/ii(s	http_opensreturn self(s	http_opensreturn self(RR�RR<R&tzipR�(
RR�R�R�R9trR�texpectedtgotthandlerRR>R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_handled�s	 cCs�t�}g}xqd	gdfdgdfgD]Q\}}dtfd��Y}||�}||_|j|�|j|�q.W|jd�}|j|jdd|d�|j|jdd|d�dS(
NR�sreturn selfi�iR�cBseZRS((R0R1(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�
sshttp://example.com/i(s	http_opensreturn self(RRyR�R�R�R<R&R�(RR�R�R�R�R�R%R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_handler_orders		
cCs|t�}dgdgg}t||�}td�}|jtj|j|�|j|j|dd|fifg�dS(NR�R�sreturn selfshttp://example.com/i(s	http_opensraise(s	http_opensreturn self(	RR�RR	RR�R<R&R�(RR�R�R�R9((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
test_raises	c
Cst�}dgddgdddgdgg}t||�}d	dd
��Y}td�}|j|�}|dd|ff|d
d||�ddiffg}x]t||j�D]I\}}	|\}
}}|j|
|f|	d
 �|j||	d
�q�WdS(NR�s	error 302thttp_error_400R�R�sreturn responsethttp_error_303t
http_errortUnknowncBseZd�ZRS(cSstS(N(R�(RR�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt__eq__4s(R0R1R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�3sshttp://example.com/iii.Rd(s	http_opens	error 302(R�sraise(shttp_error_302sreturn response((RR�RR<R�R�R&(
RR�R�R�R�R9R�R�R�R�R�tmethod_nameR>((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_http_error&s"		
cCsst�}d	d
gddgg}t||�}td�}|j|�}|ddf|ddf|ddf|ddfg}x�t|j�D]�\}\}}	}
}|dkr|j||	f||�|jt|
�d�|j|
dt�q�|j||	f||�|jt|
�d�|j|
dt�|
ddk	r�|j|
dt
�q�q�WdS(
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(RR�RR<t	enumerateR�R&R|tassertIsInstanceRARJ(RR�R�R�R9R�R�tiR�RR>R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_processorsAs(	 ((	R0R1R�R�R�R�R�R�R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s						cCsJddl}|j|�}tjdkrF|jd�rF|d}n|S(Ni����Rs///i(turllibtpathname2urlR
RR�(RR�turlpath((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytsanepathname2urles

tHandlerTestscBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�ZRS(csnddd��Y�dtjf�fd��Y}ddl}d}||�}t�}|_xdd|jd	d	d
ddgd
df	dd|jdd	d
ddgd
df	dd|jdd	d
ddgd
df	dd|jdd	d
ddgd
df	dddd	d	dddgd	df	dd|jd	d	dgddf	gD]\	}}}}	}
}}}
}t|�}d|_|j	|�}|j
|j|	�|j
|j|
�|j
|j
tj|��|j
|j|�|j
|j|�|j
|jj|
�|j
|jj|�|j�}|j
|jd�|�|j
t|d�t|��qHWdS(NtMockFTPWrappercBs#eZd�Zd�Zd�ZRS(cSs
||_dS(N(R:(RR:((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRLqscSs2|||_|_tj|j�t|j�fS(N(tfilenametfiletypeRKR:R|(RR�R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytretrfilerscSsdS(N((R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRus(R0R1RLR�R(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�ps		tNullFTPHandlercs&eZd�Zej�fd�ZRS(cSs
||_dS(N(R:(RR:((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRLxscsH|||_|_|||_|_||_�|j�|_|jS(N(R�tpasswdRjRptdirsR:t
ftpwrapper(RR�R�RjRpR�R;(R�(sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytconnect_ftpys
	(R0R1RLRBRCR�((R�(sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�ws	i����srheum rhaponicums ftp://localhost/foo/bar/baz.htmlt	localhostRdtItfootbarsbaz.htmls	text/htmls'ftp://parrot@localhost/foo/bar/baz.htmltparrots*ftp://%25parrot@localhost/foo/bar/baz.htmls%parrots,ftp://%2542parrot@localhost/foo/bar/baz.htmls	%42parrotsftp://localhost:80/foo/bar/iPtDsftp://localhost/baz.gif;type=atAsbaz.gifsContent-typesContent-length((Rt
FTPHandlertftplibR8R�tFTP_PORTRARR;R�R&R�R�RjRBt
gethostbynameRpR�R�R�R�RQtgetR�R|(RR�R�R:R%R�RPRjRpR�R�ttype_R�R�tmimetypeR9R�RO((R�sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_ftposL
1	cCs�ddl}ddl}tj�}t�}|_tj}tt	j
j|��}d}d|d|d|jd�|fg}y|j|j
��}	Wn|jk
r�d}	nX|	r�|jd|	|f�nx|D]}
t|d�}z�z|j|�Wd|j�X|jt|
��}z(|j�}
|j�}|j�}Wd|j�Xt	j|�}|j|j�}Wdt	j|�X|j|
|�|j|d	d
�|j|dd�|j|d
|�|j||
�q�Wx�d|dd|jd�t	j�|fdt	j�|fgD]h}
zQt|d�}z|j|�Wd|j�X|jtj|jt|
��Wdt	j|�Xq:Wtj�}t�}|_x�dt fdt!fdt!fdt fdt!fgD]�\}
}t|
�}y|j|�Wn(tjt"fk
rI|j#|�n*X|j#|j$|k�|j|j%d�|j|j%dk|�q�WdS(Ni����s
hello, world
sfile://localhost%ss	file://%ssfile://%s%sR�RdtwbsContent-types
text/plainsContent-lengtht13s
Last-modifiedsfile://localhost:80%ssfile:///file_does_not_exist.txtsfile://%s:80%s/%ss,file://somerandomhost.ontheinternet.com%s/%ssfile://ftp.example.com//foo.txts file://ftp.example.com///foo.txtsfile://ftp.example.com/foo.txts"file://somehost//foo/something.txts#file://localhost//foo/something.txttftp(&trfc822RBRtFileHandlerR8R�RtTESTFNR�R
RRR�tgethostnametgaierrorR�R<twriteRt	file_openRRRQRRtstatt
formatdatetst_mtimetremoveR&tgetcwdR	R�R�RgtOSErrort
assertTrueR9ttype(RR�RBR%R�RR�ttowriteturlst	localaddrRPRR�R:ROtrespurltstatstmodifiedR�R9((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt	test_file�s�	

				cCs!tj�}t�}|_d}xGddgD]9\}}t||idd6�}d|_|jdd�t�}|j	||�}|j
|j|j|j
|j|jd	kd
f|j�}	|	j|	j|j|j
�|�|j|jd�|j|jd�|j|j|�|j|jd
�|j|jdddg�|j|j|�q/Wt|_|jtj|j	||�dg|_x}dD]u}td|�}td	d
id�}|j|�}
|dkr|j d|j!�|j d|j!�n.|j|j!dd�|j|j!dd�|j|j!dd�|j|j!dd�|jdd�|jdd�|jdd�|jdd�|j|�}
|j|j!dd�|j|j!dd�|j|j!dd�|j|j!dd�q�WdS(Nshttp://example.com/tGETtPOSTR�R�tFootSpamteggsi�Rwsexample.comiRt
ConnectionRRdsContent-lengthsContent-typet0s!application/x-www-form-urlencodedtHostR�tbaz(RN(Rsblah(Rsclose(Rsbar(RR(RR(RdN("RR�R8R�RARR;tadd_unredirected_headerReR�RRFRQRRRMRNR�thas_keyR&RjRkRrRsRfR:R�RhR	R�R@RJtdo_request_tassertNotIntunredirected_hdrs(RR%R�RPRrR:R9R�R�thdrstnewreq((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt	test_httpsd		
	
c	Cs�tj�}t�}|_d}ddddg}xy|D]q}t||�}|j|�}|j|jdd�|jdd�|j|�}|j|jdd�q;WdS(	NRds#http://example.com/foo/bar/baz.htmls$http://example.com//foo/bar/baz.htmls$http://example.com/foo//bar/baz.htmls$http://example.com/foo/bar//baz.htmlRsexample.comssomeproxy:3128(
RR�R8R�RRR&R!t	set_proxyRA(	RR%R�R:tds_urlstds_urltds_reqt	np_ds_reqtp_ds_req((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_http_doubleslashDs	
cCs�tj�}t�}|_d}t|�}|j|�}|j|j�d�|j|j�d�d}t|�}|j|�}|j|j�d�|j|j�d�dS(Nshttp://www.python.org?getspamswww.python.orgs	/?getspamshttp://www.python.orgRd(	RR�R8R�RRR&tget_hosttget_selector(RR%R�t	weird_urlR9R#turl_without_path((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_fixpath_in_weirdurls^scCs�tj�}t�}|_d}t|�}tddid|�}|j||�}|j||k�|jt|d��tddid|�}|j||�}|j||k�|jt|d��tdd	id|�}|j||�}|j||k�|jt|d��td
did|�}|j|j||�dk�|j
|jd�|j
|j||d
dif�dS(
Nshttp://example.com/i�RwRdR=i�tAcceptedi�sPartial contenti�sBad gatewayR�(
RtHTTPErrorProcessorR8R�RRJR�RR�RAR&R=R>(RR%R�RPR9R�tnewr((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_errorsqs(cCs�t�}tj|�}t�}|_td�}tddid�}|j|�}|j|j	|kox|kn�|j
|j�d�|j|j��|j
||�}|j|j|k�|j|j|ko�|kn�dS(Nshttp://example.com/i�RwRdsexample.com(RSRtHTTPCookieProcessorR8R�RRJR�RRTR&tget_origin_req_hosttis_unverifiableR�RWRX(RtcjR%R�R9R�R#R3((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_cookies�s	&c
Cs%d}d}tj�}t�}|_x�dD]�}x�dD]�}t|d|�}t||�}|jd	d
�tj	|_
|dk	r�|jdtt|���n|j
dd
�y*||t�|dti|d6��Wn1tjk
r|j|d�|j|�nX|j|jj�|�y|j|jj�d�Wn(tk
ry|j|jj��nXg|jjD]}	|	j�^q�}
|jd|
�|jd|
�|j|jjd	d
�|jd|jj�|jd|jj�q<Wq/Wt|�}tj	|_
|d�}t|dd�}d}tj	|_
y%x|||d�|d}q[WWn*tjk
r�|j|tjj�nXt|dd�}d}tj	|_
y)x"|||d|�|d}q�WWn*tjk
r |j|tjj�nXdS(Nshttp://example.com/a.htmlshttp://example.com/b.htmli-i.i/i3s
blah
blah
s
http_error_%stNonsensesviking=withholdsContent-LengthRtspamtBlahtlocationRscontent-lengthscontent-typec	Ss-|j|t�ddti|d6��dS(Ni.R<R=(R�RDRG(R%R9RP((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��storigin_req_hostsexample.comishttp://example.com/ishttp://example.com/%d(i-i.i/i3(Ns
blah
blah
(RtHTTPRedirectHandlerR8R�RAtgetattrRt
add_headerRBRCR;tstrR|RRDRGt	HTTPErrorR&tassertIsNotNoneR9R�t
get_methodtAttributeErrorRthas_dataROtlowerR R!tmax_repeatstmax_redirections(
Rtfrom_urltto_urlR%R�RMR:RrR9txROR�RE((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
test_redirect�sj


%	cCsd}dddg}dddg}d}tj�}t�}|_t|�}tj|_xQ|D]I}|d	|}	|jtj	|j
|t�d
dti|	d6��qeWx^|D]V}|d	|}
|j
|t�d
d
ti|
d6��|j
|jj�|
�q�WdS(Nshttp://example.com/a.htmlR�thttpsR�tfiletimaptldapsexample.com/b.htmls://i.sSecurity LoopholeR=sThat's fine(RR?R8R�RRBRCR;R	RCR�RDRGR&R9R�(RRKt
valid_schemestinvalid_schemestschemeless_urlR%R�R9R�tinvalid_urlt	valid_url((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_invalid_redirect�s$

c	Cs�ddlm}ddlm}|�}||dd�tdd�}tj�}tj�}tj|�}t	||||�}|j
d�|j|jj
d��dS(	Ni����(t	CookieJar(tinteract_netscapeshttp://www.example.com/s	spam=eggsi.s%Location: http://www.cracker.com/

tCookie(t	cookielibRYttest.test_cookielibRZR�RtHTTPDefaultErrorHandlerR?R5R�R<RR9t
has_header(	RRYRZR8thhthdehthrhtcpR�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_cookie_redirect�s	
cCsrd}tdd|�}tj�}tj�}t|||�}|jd�}|j|j�|j��dS(Ns(http://www.example.com/index.html#OK

i.s
Location: shttp://www.example.com(	R�RR^R?R�R<R&RRtstrip(Rtredirected_urlR`RaRbR�Ra((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_redirect_fragmentscs�tj�d}tj|�t_�jttd��td�����fd�}|tj_tj	d�}�j
|j�d�dS(	Ns(HTTP/1.1 302 Found
Location: ?query

tHTTPConnections/paths/path?querycs?�j|t����j|||||�d|j_dS(NsHTTP/1.1 200 OK

Hello!(R&tnextRUR~tfakedata(tconnRrRPtpostkw(t
real_classRR(sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRUsshttp://python.org/pathshttp://python.org/path?query(s/paths/path?query(R�RhRtfakehttpt
addCleanupR}titerRURRR&RR(Rt	response1RURa((RnRRsj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_redirect_no_paths	cCs�t�}tjtdd��}|j|�d	gg}t||�}td�}|j|j�d�|j	|�}|j|j�d�|j|ddfgg|j
D]}|dd!^q��dS(
NR�sproxy.example.com:3128R�sreturn responseshttp://acme.example.com/sacme.example.comii(s	http_opensreturn response(RRtProxyHandlertdictR�R�RR&R,R<R�(RR�tphR�R�R9R�ttup((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
test_proxy!s	
cCs�dtjd<t�}tjtdd��}|j|�td�}|j|j	�d�|j
|�}|j|j	�d�td�}|j|j	�d�|j
|�}|j|j	�d�tjd=dS(	Ns
python.orgtno_proxyR�sproxy.example.comshttp://www.perl.org/swww.perl.orgshttp://www.python.orgswww.python.org(R
tenvironRRRtRuR�RR&R,R<(RR�RvR9R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_proxy_no_proxy2s
	
cCs�t�}tjtdd��}|j|�d	gg}t||�}td�}|j|j�d�|j	|�}|j|j�d�|j|ddfgg|j
D]}|dd!^q��dS(
NROsproxy.example.com:3128R�sreturn responseshttps://www.example.com/swww.example.comii(s
https_opensreturn response(RRRtRuR�R�RR&R,R<R�(RR�RvR�R�R9R�Rw((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_proxy_httpsBs	
cCst�}tjtdd��}|j|�t�}|j|�td�}|jdd�|jdd�|j|j	�d�|j
|j�|j|�}|j
d
|jj�|jd|jj�|j|j�|j|j	�d�|j|jd	�d�dS(NROsproxy.example.com:3128shttps://www.example.com/sProxy-AuthorizationtFooBars
User-AgenttGrailswww.example.comsProxy-authorization(sProxy-AuthorizationR}(s
User-AgentR~(RRRtRuR�R�RRAR&R,tassertIsNoneRmR<R R�RftassertInRDt
get_header(RR�Rvt
https_handlerR9R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt$test_proxy_https_proxy_authorizationQs$	
	
	
	
t"c	Cs�t�}t�}tj|�}d}tdd|||f�}|j|�|j|�|j||d|||dd�dS(NsACME Widget Storei�s(WWW-Authenticate: Basic realm=%s%s%s

t
Authorizations!http://acme.example.com/protected(RR�RtHTTPBasicAuthHandlerR�R�t_test_basic_auth(Rt
quote_charR�tpassword_managertauth_handlerR�thttp_handler((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_basic_authhs		

	cCs|jdd�dS(NR�t'(R�(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt(test_basic_auth_with_single_quoted_realmxsc
Cs�t�}t�}tj|�}d}tdd|�}|j|�|j|�d}tj|tf��'|j	||d|||dd�WdQXdS(NsACME Widget Storei�s$WWW-Authenticate: Basic realm=%s

sBasic Auth Realm was unquotedR�s!http://acme.example.com/protected(
RR�RR�R�R�Rtcheck_warningstUserWarningR�(RR�R�R�R�R�RN((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt#test_basic_auth_with_unquoted_realm{s		

	c	Cs�t�}tjtdd��}|j|�t�}tj|�}d}tdd|�}|j|�|j|�|j||d|||dd�dS(NR�sproxy.example.com:3128s
ACME Networksi�s(Proxy-Authenticate: Basic realm="%s"

sProxy-authorizations&http://acme.example.com:3128/protected(	RRRtRuR�R�tProxyBasicAuthHandlerR�R�(RR�RvR�R�R�R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_proxy_basic_auth�s	
	

	c
	Cs�dtfd��Y}dtjfd��Y}dtjfd��Y}|�}t�}||�}||�}d}tdd	|�}	|j|�|j|�|j|	�|j||d
||	|dd�|j|j	dd
gd�dS(NtRecordingOpenerDirectorcBseZd�Zd�ZRS(cSstj|�g|_dS(N(RRLtrecorded(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRL�s
cSs|jj|�dS(N(R�R�(RRQ((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytrecord�s(R0R1RLR�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s	tTestDigestAuthHandlercBseZd�ZRS(c_s*|jjd�tjj|||�dS(Ntdigest(R�R�RtHTTPDigestAuthHandlerthttp_error_401(RR>R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s(R0R1R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��stTestBasicAuthHandlercBseZd�ZRS(c_s*|jjd�tjj|||�dS(Ntbasic(R�R�RR�R�(RR>R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s(R0R1R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��ss
ACME Networksi�s&WWW-Authenticate: Basic realm="%s"

R�s!http://acme.example.com/protectedR�R�i(
RRR�R�R�R�R�R�R&R�(
RR�R�R�R�R�tdigest_handlert
basic_handlerR�R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt#test_basic_and_digest_auth_handlers�s$			


	c	Cs�ddl}	d	\}
}|j|||
|�|j||j�|j||j�|j|
|j�|j||j�|j|�}|j|j|�|j|j	|�|jt
|j�d�|j|jdj
|��d|
|f}
d|	j|
�j�}|j|jdj|�|�|j|jdj||�d|_|_|j�|j|�}|jt
|j�d�|j|jdj
|��dS(
Ni����twiletcoyoteiis%s:%ssBasic i(R�R�(tbase64R�R&R�RPR�R�R<R�R�R|R�tassertFalseR_tencodestringReR�R!RAR�(RR�R�tauth_headerR�R�R�trequest_urlt
protected_urlR�R�R�R�tuserpasstauth_hdr_value((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s.
(R0R1R�RR$R+R0R4R9RNRXRdRgRsRxR{R|R�R�R�R�R�R�R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�ms,	:	]	>					I													/t	MiscTestscBs#eZd�Zd�Zd�ZRS(cCs�dtjfd��Y}dtjfd��Y}dtjfd��Y}tj}|||�}|j||�|j||�|||��}|j||�|j||�||�}|j||�|�}|j|tj�|tj�}|j|tj�|tj��}|j|tj�dtjfd��Y}|||�}|j||�|j||�dS(	Nt
MyHTTPHandlercBseZRS((R0R1(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��st
FooHandlercBseZd�ZRS(cSsdS(N((R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytfoo_open�s(R0R1R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��st
BarHandlercBseZd�ZRS(cSsdS(N((R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytbar_open�s(R0R1R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��stMyOtherHTTPHandlercBseZRS((R0R1(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�s(RtHTTPHandlertBaseHandlertbuild_openertopener_has_handler(RR�R�R�R�R�R�((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_build_opener�s,		cCs8x1|jD]}|j|kr
Pq
q
W|jt�dS(N(R�R~RRg(RR�t
handler_classR%((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�scCsKt�}|jt��}|jd�WdQX|jt|j�d�dS(Ntinvalids5Unsupported digest authentication algorithm 'invalid'(RR	R
tget_algorithm_implsR&RBt	exception(RR�texc((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_unsupported_algorithms	(R0R1R�R�R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR��s	%	tRequestTestscBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZRS(cCs8tjd�|_tjdddidd6�|_dS(Nshttp://www.python.org/~jeremy/R:ROttestsX-Test(RRR�tpost(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pytsetUp+s	cCs6|jd|jj��|jd|jj��dS(NRR(R&R�RER�(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_method1scCss|j|jj��|jd|jj��|jjd�|j|jj��|jd|jj��dS(NRR;R(RR�RGR&REtadd_data(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
test_add_data5s
cCs|jd|jj��dS(Nshttp://www.python.org/~jeremy/(R&R�R�(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_get_full_url<s	cCsB|jd|jj��tjd�}|jd|j��dS(Ns	/~jeremy/shttp://www.python.org/R(R&R�R-RR(RR9((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
test_selector@scCs|jd|jj��dS(NR�(R&R�tget_type(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
test_get_typeEscCs|jd|jj��dS(Nswww.python.org(R&R�R,(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt
test_get_hostHscCs)tjd�}|jd|j��dS(Nshttp://www.%70ython.org/swww.python.org(RRR&R,(RR9((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_get_host_unquoteKscCsv|j|jj��|jjdd�|j|jj��|jd|jj��|jd|jj��dS(Nswww.perl.orgR�swww.python.org(RR�t	has_proxyR%R&R6R,(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyRxOs
cCs&td�}|jd|j��dS(Ns<URL:http://www.python.org>swww.python.org(RR&R,(RR9((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_wrapped_urlVscCsptd�}|jd|j��td�}|jd|j��d}t|�}|j|j�|�dS(Ns-http://www.python.org/?qs=query#fragment=trues
/?qs=queryshttp://www.python.org/#fun=trueRs.http://docs.python.org/library/urllib2.html#OK(RR&R-R�(RR9RP((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_url_fragmentZscCs6|jt|jd��|jt|jd��dS(Nt_Request__r_xxxt_Request__r_method(R�R�R�(R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_private_attributesescCsdS(sc
        Issue 13211 reveals that HTTPError didn't implement the URLError
        interface even though HTTPError is a subclass of URLError.

        >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None)
        >>> assert hasattr(err, 'reason')
        >>> err.reason
        'something bad happened'
        N((R((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_HTTPError_interfacejscCs�tjdddd
dd
dddd
�}|jt|d��y|j�Wntk
rn|jd	�nX|j|j�d�d
S(s]
        Issue 15701= - HTTPError interface has info method available from URLError.
        RNssomething bad happenedRPRMR"sContent-Length:42RaRcserr.info() failedN(	RRCRARR�RQRFtfailR&(Rterr((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyttest_HTTPError_interface_callus
(R0R1R�R�R�R�R�R�R�R�RxR�R�R�R�R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyR�)s													cCsVddlm}tj||�tjt|�ttttt	f}tj
|�dS(Ni����(ttest_urllib2(R�R�Rtrun_doctestRRR�R�R�R�trun_unittest(tverboseR�R(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt	test_main�s	t__main__R�(.R2R�RRR
RBRKRRRRR�R-tImportErrorRAtTestCaseRR4R5R6R7R8RDRuRGRJRSR[R`ReRyR�R�R�R�R�R�R�R�R�R�R�R�R�R0R�(((sj/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2.pyt<module>sR

+		!	A	/		),		�	���8\