ó {G_Tc@säddlZddlmZddlZddlZddlZddlZddlZejdde ƒZ d„Z dej fd„ƒYZ dej fd „ƒYZd ej fd „ƒYZd „Zed kràeƒndS(iÿÿÿÿN(t test_supportt mimetoolst deprecatedcOsWxJtdƒD]<}y||||ŽSWq tk r?}q q ‚q Xq W|‚dS(Ni(trangetIOError(tfuncthosttargstkwargstitlast_exc((s//usr/local/lib/python2.7/test/test_urllibnet.pyt_open_with_retry s tURLTimeoutTestcBs)eZdZd„Zd„Zd„ZRS(g$@cCstj|jƒdS(N(tsockettsetdefaulttimeouttTIMEOUT(tself((s//usr/local/lib/python2.7/test/test_urllibnet.pytsetUpscCstjdƒdS(N(R RtNone(R((s//usr/local/lib/python2.7/test/test_urllibnet.pyttearDown!scCs"ttjdƒ}|jƒ}dS(Nshttp://www.example.com/(R turllibturlopentread(Rtftx((s//usr/local/lib/python2.7/test/test_urllibnet.pyt testURLread$s(t__name__t __module__RRRR(((s//usr/local/lib/python2.7/test/test_urllibnet.pyR s  turlopenNetworkTestscBsŒeZdZd„Zd„Zd„Zd„Zd„Zd„Ze j e j d kdƒe j eed ƒd ƒd „ƒƒZd „ZRS(s6Tests urllib.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a good job overall of some of the basic interface features. There are no tests exercising the optional 'data' and 'proxies' arguments. No tests for transparent redirection have been written. setUp is not used for always constructing a connection to http://www.example.com/ since there a few tests that don't use that address and making a connection is expensive enough to warrant minimizing unneeded connections. cGsttj|ŒS(N(R RR(RR((s//usr/local/lib/python2.7/test/test_urllibnet.pyR7scCsi|jdƒ}x+d D]#}|jt||ƒd |ƒqWz|j|jƒd ƒWd|jƒXdS( Nshttp://www.example.com/Rtreadlinet readlinestfilenotclosetinfotgeturls3object returned from urlopen lacks the %s attributescalling 'read' failed(sreadsreadlines readlinessfilenosclosesinfosgeturl(Rt assertTruethasattrRR (Rtopen_urltattr((s//usr/local/lib/python2.7/test/test_urllibnet.pyt test_basic:s  cCsW|jdƒ}z6|j|jƒtdƒ|j|jƒtdƒWd|jƒXdS(Nshttp://www.example.com/s readline did not return a stringsreadlines did not return a list(RtassertIsInstanceRt basestringRtlistR (RR%((s//usr/local/lib/python2.7/test/test_urllibnet.pyttest_readlinesFs cCs]|jdƒ}z|jƒ}Wd|jƒ|j|tjdƒ|j|jƒdƒXdS(Nshttp://www.example.com/sAobject returned by 'info' is not an instance of mimetools.Messagethtml(RR!R R(RtMessaget assertEqualt getsubtype(RR%tinfo_obj((s//usr/local/lib/python2.7/test/test_urllibnet.pyt test_infoQs cCsGd}|j|ƒ}z|jƒ}Wd|jƒX|j||ƒdS(Nshttp://www.example.com/(RR"R R.(RtURLR%t gotten_url((s//usr/local/lib/python2.7/test/test_urllibnet.pyt test_geturl]s  cCsMd}tjƒj|ƒ}z|jƒ}Wd|jƒX|j|dƒdS(Ns$http://www.example.com/XXXinvalidXXXi”(RtFancyURLopenertopentgetcodeR R.(RR2R%tcode((s//usr/local/lib/python2.7/test/test_urllibnet.pyt test_getcodegs  twin32snot appropriate for Windowstfdopensos.fdopen not availablecCsV|jdƒ}|jƒ}tj|ƒ}z|j|jƒdƒWd|jƒXdS(Nshttp://www.example.com/s<reading from file created using fd returned by fileno failed(RRtosR;R#RR (RR%tfdtFILE((s//usr/local/lib/python2.7/test/test_urllibnet.pyt test_filenoqs  cCsYd}ytj|ƒWntjk r-nX|jd|ƒ|jttjdƒdS(Nssadflkjsasf.i.nvali.ds&%r should not resolve for test to workshttp://sadflkjsasf.i.nvali.d/(R t gethostbynametgaierrortskipTestt assertRaisesRRR(Rt bogus_domain((s//usr/local/lib/python2.7/test/test_urllibnet.pyttest_bad_address~s (swin32(RRt__doc__RR'R+R1R4R9tunittesttskipIftsystplatformt skipUnlessR$R<R?RE(((s//usr/local/lib/python2.7/test/test_urllibnet.pyR(s   ' turlretrieveNetworkTestscBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(s+Tests urllib.urlretrieve using the network.cGsttj|ŒS(N(R Rt urlretrieve(RR((s//usr/local/lib/python2.7/test/test_urllibnet.pyRM–scCsv|jdƒ\}}|jtjj|ƒdƒt|ƒ}z|j|jƒdƒWd|jƒtj|ƒXdS(Nshttp://www.example.com/s9file location returned by urlretrieve is not a valid paths=reading from the file location returned by urlretrieve failed( RMR#R<tpathtexiststfileRR tunlink(Rt file_locationR!R>((s//usr/local/lib/python2.7/test/test_urllibnet.pyR'™s  cCsŒ|jdtjƒ\}}|j|tjƒ|jtjj|ƒƒt|ƒ}z|j|j ƒdƒWd|j ƒtj |ƒXdS(Nshttp://www.example.com/s"reading from temporary file failed( RMRtTESTFNR.R#R<RNRORPRR RQ(RRRR!R>((s//usr/local/lib/python2.7/test/test_urllibnet.pyttest_specified_path¦s   cCs<|jdƒ\}}tj|ƒ|j|tjdƒdS(Nshttp://www.example.com/s.header is not an instance of mimetools.Message(RMR<RQR(RR-(RRRtheader((s//usr/local/lib/python2.7/test/test_urllibnet.pyt test_header³s cCsyd}|j|ƒ\}}tj|ƒ|jdƒ}d}ytj||ƒWn!tk rt|jd|ƒnXdS(Nshttp://www.example.com/tDates%a, %d %b %Y %H:%M:%S GMTsDate value not in %r format(RMR<RQt getheaderttimetstrptimet ValueErrortfail(RtlogoRRt fileheaderst datevaluet dateformat((s//usr/local/lib/python2.7/test/test_urllibnet.pyttest_data_headerºs  (RRRFRMR'RTRVRa(((s//usr/local/lib/python2.7/test/test_urllibnet.pyRL“s   cCs@tjdƒtjdtfƒtjtttƒWdQXdS(Ntnetworks!urllib.urlopen.. has been removed(Rtrequirestcheck_py3k_warningstDeprecationWarningt run_unittestR RRL(((s//usr/local/lib/python2.7/test/test_urllibnet.pyt test_mainÇs   t__main__(RGttestRR RRIR<RYt import_moduletTrueRR tTestCaseR RRLRgR(((s//usr/local/lib/python2.7/test/test_urllibnet.pyts       k4