a 5êdg‘ã@sFddlZddlZddlZddlZGdd„dejƒZedkrBe ¡dS)éNc@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)Ú TestResponsecCs0t tjtj¡|_|j d¡|_dddœ|_dS)NÚrbzwww.python.orgÚclose)ZHostÚ Connection)ÚsocketÚAF_INETÚ SOCK_STREAMÚsockÚmakefileÚfpÚ test_headers©Úself©rú5/usr/local/lib/python3.9/test/test_urllib_response.pyÚsetUp s ÿzTestResponse.setUpcsZtj |j¡‰| ˆtj¡‡fdd„}| |jj¡|ƒ|  |jj¡|  t |¡dS)Ncs(ˆ}Wdƒn1s0YdS©Nr)Zspam©ÚaddbaserrÚfsz!TestResponse.test_with..f) ÚurllibÚresponserr ZassertIsInstanceÚtempfileÚ_TemporaryFileWrapperZ assertFalseÚclosedÚ assertTrueZ assertRaisesÚ ValueError)rrrrrÚ test_withs zTestResponse.test_withcsDd‰‡fdd„}tj |j|¡}| ¡| |jj¡| ˆ¡dS)NFcsd‰dS)NTrr©Zclosehook_calledrrÚ closehook sz1TestResponse.test_addclosehook..closehook)rrZ addclosehookr rrr)rrrrrÚtest_addclosehooks  zTestResponse.test_addclosehookcCs8tj |j|j¡}| | ¡|j¡| |j|j¡dSr)rrZaddinfor r Ú assertEqualÚinfoÚheaders)rr"rrrÚ test_addinfo*szTestResponse.test_addinfocCs€d}d}tj |j|j||¡}| | ¡|j¡| | ¡|¡| | ¡|¡| |j |j¡| |j |¡| |j |¡dS)Nzhttp://www.python.orgéÈ) rrZ addinfourlr r r!r"ÚgeturlZgetcoder#ÚurlÚstatus)rr'ÚcodeZinfourlrrrÚtest_addinfourl/sÿzTestResponse.test_addinfourlcCs|j ¡dSr)r rr rrrÚtearDown;szTestResponse.tearDownN) Ú__name__Ú __module__Ú __qualname__rrr r$r*r+rrrrrs    rÚ__main__) rrZurllib.responserZunittestZTestCaserr,ÚmainrrrrÚs 6