asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T a bYh@srddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZmZddlmZmZddlmZddlmZmZmZddlmZmZddlZddlZddl Z!z ddl"Z"Wne#yddZ$Yn0d dZ$Gd d d e"j%Z&e'ed p6ej(j)Z*d dZ+GdddZ,Gddde,ej-Z.Gddde,e!j-Z/Gddde,Z0Gddde0ej-Z1Gddde0e!j-Z2Gddde0Z3Gddde3ej-Z4Gdd d e3e!j-Z5Gd!d"d"e0Z6Gd#d$d$e6ej-Z7Gd%d&d&e6e!j-Z8Gd'd(d(e0Z9Gd)d*d*e9ej-Z:Gd+d,d,e9e!j-Z;Gd-d.d.ZGd1d2d2ed>eCe!j-ZEGd?d@d@e jFZGGdAdBdBeGZHGdCdDdDeGZIejJGdEdFdFe jFZKGdGdHdHZLGdIdJdJZMGdKdLdLe jFeLZNGdMdNdNeNeMZOGdOdPdPeNZPGdQdRdRe jFeLZQGdSdTdTeQeMZRGdUdVdVeQZSGdWdXdXe jFZTGdYdZdZeTZUGd[d\d\eTZVGd]d^d^eNeQZWGd_d`d`eWeMZXGdadbdbeWZYGdcddddejZZ[e\e[j]Gdedfdfe jFZ^Gdgdhdhe jFZ_Gdidjdjej=Z`dkdlZaGdmdndne_ZbGdodpdpe_ZcGdqdrdre jFZdGdsdtdtedZeGdudvdvedZfGdwdxdxe jFZgGdydzdzegZhGd{d|d|egZie jejkd}kd~Gddde jFZlGdddelZmGdddelZnddZoepdkrne qdS)N)dequeUserList)cyclecount)support)assert_python_okassert_python_failurerun_python_until_end)FakePathskip_if_sanitizercOstdt|i|S)Nb)arraybytes)poskwr(/usr/local/lib/python3.9/test/test_io.py byteslike3srcOs>t|i|}t}t|t||t|ddd<|S)NB)r EmptyStructctypesZresizelen memoryviewcast)rrdataobjrrrr6s c@s eZdZdS)rN__name__ __module__ __qualname__rrrrr=srZgettotalrefcountcCs8ttddd}|jWdS1s*0YdS)Nrlatin-1encoding)open__file__ _CHUNK_SIZEfrrr_default_chunk_sizeEsr)c@s`eZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ dddZ dS)MockRawIOWithoutReadrcCs t||_g|_d|_d|_dSNr)list _read_stack _write_stack_reads_extraneous_reads)selfZ read_stackrrr__init__Os zMockRawIOWithoutRead.__init__cCs|jt|t|SN)r.appendrrr1r rrrwriteUszMockRawIOWithoutRead.writecCsdSNTrr1rrrwritableYszMockRawIOWithoutRead.writablecCsdSN*rr8rrrfileno\szMockRawIOWithoutRead.filenocCsdSr7rr8rrrreadable_szMockRawIOWithoutRead.readablecCsdSr7rr8rrrseekablebszMockRawIOWithoutRead.seekablecCsdSr+rr1rwhencerrrseekeszMockRawIOWithoutRead.seekcCsdSr+rr8rrrtellhszMockRawIOWithoutRead.tellcCs|jd7_t|}z|jd}Wn"tyF|jd7_YdS0|dur\|jd=dSt|}t||kr|jd=||d|<|S|d||dd<||d|jd<|SdSNr)r/rr- IndexErrorr0)r1bufZmax_lenrnrrrreadintoks$   zMockRawIOWithoutRead.readintoNcCs|Sr3r)r1rrrrtruncateszMockRawIOWithoutRead.truncate)r)N) rrrr2r6r9r<r=r>rArBrHrIrrrrr*Ks r*c@s eZdZdS)CMockRawIOWithoutReadNrrrrrrJsrJc@s eZdZdS)PyMockRawIOWithoutReadNrrrrrrKsrKc@seZdZdddZdS) MockRawIONcCs>|jd7_z|jdWS|jd7_YdS0dS)NrDr)r/r-popr0r1rGrrrreads zMockRawIO.read)NrrrrPrrrrrLsrLc@s eZdZdS) CMockRawIONrrrrrrRsrRc@s eZdZdS) PyMockRawIONrrrrrrSsrScsFeZdZfddZd fdd ZddZdd Zfd d ZZS) MisbehavedRawIOcst|dSN)superr6r5 __class__rrr6szMisbehavedRawIO.writeNcst|dSrU)rWrPrOrXrrrPszMisbehavedRawIO.readcCsdS)Nirr?rrrrAszMisbehavedRawIO.seekcCsdS)Ni8rr8rrrrBszMisbehavedRawIO.tellcst|t|dSN)rWrHr)r1rFrXrrrHs zMisbehavedRawIO.readinto)N) rrrr6rPrArBrH __classcell__rrrXrrTs  rTc@s eZdZdS)CMisbehavedRawIONrrrrrr]sr]c@s eZdZdS)PyMisbehavedRawIONrrrrrr^sr^cs$eZdZfddZddZZS)SlowFlushRawIOcstt|_dSr3)rWr2 threadingEventin_flushr8rXrrr2s zSlowFlushRawIO.__init__cCs|jtddS)Ng?)rbsettimesleepr8rrrflushs zSlowFlushRawIO.flush)rrrr2rfr\rrrXrr_s r_c@s eZdZdS)CSlowFlushRawIONrrrrrrgsrgc@s eZdZdS)PySlowFlushRawIONrrrrrrhsrhc@seZdZdZddZdS)CloseFailureIOrcCs|jsd|_tdSNrDclosedOSErrorr8rrrcloseszCloseFailureIO.closeN)rrrrlrnrrrrrisric@s eZdZdS)CCloseFailureIONrrrrrrosroc@s eZdZdS)PyCloseFailureIONrrrrrrpsrpcs6eZdZfddZdfdd ZfddZZS) MockFileIOcsg|_t|dSr3) read_historyrWr2r1rrXrrr2szMockFileIO.__init__Ncs,t|}|j|durdnt||Sr3)rWrPrrr4r)r1rGresrXrrrPs zMockFileIO.readcst|}|j||Sr3)rWrHrrr4)r1r rtrXrrrHs  zMockFileIO.readinto)N)rrrr2rPrHr\rrrXrrqs rqc@s eZdZdS) CMockFileIONrrrrrrusruc@s eZdZdS) PyMockFileIONrrrrrrvsrvc@s,eZdZddZddZddZddZd S) MockUnseekableIOcCsdSNFrr8rrrr>szMockUnseekableIO.seekablecGs|ddSNz not seekableUnsupportedOperationr1argsrrrrAszMockUnseekableIO.seekcGs|ddSryrzr|rrrrBszMockUnseekableIO.tellcGs|ddSryrzr|rrrrIszMockUnseekableIO.truncateN)rrrr>rArBrIrrrrrwsrwc@seZdZejZdS)CMockUnseekableION)rrrior{rrrrr~sr~c@seZdZejZdS)PyMockUnseekableION)rrrpyior{rrrrrsrc@sNeZdZddZddZddZddZd d Zdd d ZddZ ddZ dS)MockNonBlockWriterIOcCsg|_d|_dSr3)r. _blocker_charr8rrrr2szMockNonBlockWriterIO.__init__cCsd|j}g|jdd<|S)NrM)joinr.)r1srrr pop_writtens z MockNonBlockWriterIO.pop_writtencCs ||_dSr3)r)r1charrrrblock_onszMockNonBlockWriterIO.block_oncCsdSr7rr8rrrr= szMockNonBlockWriterIO.readablecCsdSr7rr8rrrr>szMockNonBlockWriterIO.seekablercCsdSr+rr?rrrrAszMockNonBlockWriterIO.seekcCsdSr7rr8rrrr9szMockNonBlockWriterIO.writablecCstt|}d}|jr`z||j}Wnty4Yn,0|dkrV|j|d||Sd|_dS|j|t|S)Nr)rrindex ValueErrorr.r4r)r1r rGrrrr6s  zMockNonBlockWriterIO.writeN)r) rrrr2rrr=r>rAr9r6rrrrrs rc@seZdZejZdS)CMockNonBlockWriterION)rrrrBlockingIOErrorrrrrr-src@seZdZejZdS)PyMockNonBlockWriterION)rrrrrrrrrr0src@seZdZddZddZddZdbdd Zd Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2daS)cIOTestcCsttjdSr3runlinkTESTFNr8rrrsetUp6sz IOTest.setUpcCsttjdSr3rr8rrrtearDown9szIOTest.tearDowncCsD||dd|d||d|d||dd||dd||dd||d||ddd||dtd}|||d d |dd<||dd||d d||dd d ||d ||dd||d |t|jddS)Nsblah.r[rsHello.rrDs world s *********hrV ) assertEqualr6rIrBrA bytearray assertRaises TypeError)r1r(bufferrrr write_ops<s(   zIOTest.write_opsFcCs|d}||dt|}|||d|t|dtd}|||d|t|d||ddd||dd||dd||d d ||td d||d dd ||dd||dd ||td||d d d||dd||d| t |jd|r|d||d|d ||d||d |dtd}|| |d|t|ddS)Nr[shellos worlrVd r hello world rDrMxirsworld rsworld ) rPrrrHrrrrArBrr readinto1)r1r(Zbufferedrrrrread_opsTs>     zIOTest.read_opslc CsPz|||j|jWn ttfy:|dYn0|||j||dd|||jd||dd|jd|||jd|||jd||dd|jd|||jd|jd|||jd||dd|jd||dd|j|| dddS) Nzno largefile supportxxxrrDrVrr) rrALARGE OverflowErrorrskipTestrBr6rIrPr1r(rrrlarge_file_opsws zIOTest.large_file_opsc Cs|j}dD]N}|tj|,}|||j|||jWdq 1sN0Yq |jtjddd,}|||j|||jWdn1s0Y|jtjddd2}|||jd|||jdgWdn1s0Y|tjd2}|||jd|||jdgWdn1sD0Y|tjdZ}|||jd |||jd g|||j d |j |||j d |j Wdn1s0YdS) N)wwbrr bufferingrbsblahsblah r Zblahzblah rDr) r{r$rrrrPreadliner6 writelinesrASEEK_CURSEEK_END)r1excmodefprrrtest_invalid_operationss&.,02zIOTest.test_invalid_operationsc sfdd}fdd}fdd}fdd}fd d }fd d }fd d}fdd}|df|df|df|df|df|df|df|dfjdfjdff } | D]\} } | | } d| v} | | d| v}| |t| jrd}n$t| jj fr(d}n dd| vrF| n t | j | rn| d| n t | jd t | j|r| |n t | j|tjdr| ||fvrWdWdqd| v}| ||r| | dn t | j t | jd|rT|rT| | dn t | j t | jdWdn1s0YWdq1s0YqdS)Ncs"t\}}t||dS)Nr )ospipernFileIO)r rr8rr pipe_readers  z3IOTest.test_optional_abilities..pipe_readercsNt\}}tj|tjtj|dfd}||j |dS)Ndtargetr}r) rr addCleanuprnr`ThreadrPstartrr)r rthreadr8rr pipe_writers   z3IOTest.test_optional_abilities..pipe_writercsSr3)BufferedReaderrwrr8rrbuffered_readersz7IOTest.test_optional_abilities..buffered_readercsSr3)BufferedWriterrwrr8rrbuffered_writersz7IOTest.test_optional_abilities..buffered_writercsSr3)BufferedRandomBytesIOrr8rrbuffered_randomsz7IOTest.test_optional_abilities..buffered_randomcsSr3)BufferedRWPairrwrr8rrbuffered_rw_pairs z8IOTest.test_optional_abilities..buffered_rw_paircs$Gfdddj}|dS)NcseZdZjjZjjZdS)zMIOTest.test_optional_abilities..text_reader..UnseekableReaderN)rrrBufferedIOBaser9r6rr8rrUnseekableReadersrasciirw TextIOWrapper)rr8rr text_readersz3IOTest.test_optional_abilities..text_readercs$Gfdddj}|dS)NcseZdZjjZjjZdS)zMIOTest.test_optional_abilities..text_writer..UnseekableWriterN)rrrrr=rPrr8rrUnseekableWritersrrr)rr8rr text_writersz3IOTest.test_optional_abilities..text_writerfrfwr rZrwsrw33zUnknown base classr(rDwinrr)rStringIOsubTestrr=r9 isinstance TextIOBaser RawIOBasefailr<rrmrPr6sysplatform startswithr>rBrArI)r1rrrrrrrrteststestZ abilitiesrr=r9rr>rr8rtest_optional_abilitiessh                    zIOTest.test_optional_abilitiescCsjd}|t|j|dt|d}t.tdt|t|j|dWdn1s\0YdS)Nzfoobarrrignore)rrr$rwarningscatch_warnings simplefilterDeprecationWarning)r1Z fn_with_NULZbytes_fnrrrtest_open_handles_NUL_chars s    z"IOTest.test_open_handles_NUL_charscCs|jtjdddJ}||d||d||d||Wdn1sb0Y|jtjdddJ}||d||d||d||Wdn1s0YdS)NrrrFTr r$rrrr=r9r>rrrrrrtest_raw_file_ios(zIOTest.test_raw_file_iocCs|tjdJ}||d||d||d||Wdn1s^0Y|tjdL}||d||d||d||dWdn1s0YdS)NrFTrrrrrrtest_buffered_file_ios(zIOTest.test_buffered_file_iocCs"|tjd}|dWdn1s.0Y|tjd}||d||dd||dd||d d ||d ||dd |t|jd Wdn1s0Y|tjd }|t|jd Wdn1s0YdS)Nrs"abc def xyzzy foobar another linerabc rdef rVxyszzy sfoobar s another lineg333333@r )r$rrr6rrrrrrrr test_readline+s(.zIOTest.test_readlinecCs*Gddd|j}|ttft|dS)Nc@seZdZddZdS)z+IOTest.test_readline_nonsizeable..RcSsdSr3rr8rrrr=sz4IOTest.test_readline_nonsizeable..R.readlineN)rrrrrrrrR<sr)IOBaserr StopIterationnextr1rrrrtest_readline_nonsizeable9sz IOTest.test_readline_nonsizeablecCs(Gddd|j}|t|jddS)Nc@seZdZddZdS)z'IOTest.test_next_nonsizeable..RcSsdSr3rr8rrr__next__Esz0IOTest.test_next_nonsizeable..R.__next__N)rrrrrrrrrDsrrD)rrr readlinesrrrrtest_next_nonsizeableAszIOTest.test_next_nonsizeablecCs@|}|||}||d||}||ddS)NrT)rrgetvaluerr)r1r(rrrrtest_raw_bytes_ioIs    zIOTest.test_raw_bytes_iocCstjdddkstjdkr.tdd|j|tjdd}||Wdn1s^0Y|tjd}||Wdn1s0YdS)NrrdarwinZ largefilez-test requires %s bytes and a long time to runw+br)rrrZrequiresrr$rrrrrrtest_large_file_opsQs(zIOTest.test_large_file_opsc CsdD]}d}|tjd|}|dWdn1s<0Y||jdd}z<|tjd|}ddWdn1s0YWn ty||jdYq0|dqdS)N)rrrrTrDrz1/0 didn't raise an exception)r$rrr6rrlZeroDivisionErrorr)r1bufsizer(rrrtest_with_open^s(* zIOTest.test_with_opencCs|tjd}|dWdn1s.0Y|jtjddd }||dWdn1sp0Y|tjd }||dWdn1s0Y|tjd }||dWdn1s0YdS)Nrrabrrra)r$rrr6rrB assertGreaterrrrrtest_append_mode_tellns(..zIOTest.test_append_mode_tellc sgGfddd|j}tdtf~|tjd}|d~t|gd|tjd }|| dWdn1s0YWdn1s0YdS)Ncs:eZdZfddZfddZfddZZS)z(IOTest.test_destructor..MyFileIOcs4dz tj}Wnty(Yn0|dSrjr4rW__del__AttributeErrorrrYrecordrrr{s    z0IOTest.test_destructor..MyFileIO.__del__csdtdSrUr4rWrnr8rrrrns z.IOTest.test_destructor..MyFileIO.closecsdtdSNrr4rWrfr8rrrrfs z.IOTest.test_destructor..MyFileIO.flushrrrrrnrfr\rrrXrMyFileIOzsrrrrDrVrr) rrcheck_warningsResourceWarningrr6 gc_collectrr$rP)r1rr(rrrtest_destructorxs  zIOTest.test_destructorcs<gGfddd|}|}~t|gddS)NcsBeZdZddZfddZfddZfddZZS) z+IOTest._check_base_destructor..MyIOcSsd|_d|_d|_dS)NrDrVr)on_delon_closeon_flushr8rrrr2sz4IOTest._check_base_destructor..MyIO.__init__cs6|jz tj}Wnty*Yn0|dSr3)r4rrWrrrrrrrs    z3IOTest._check_base_destructor..MyIO.__del__cs|jtdSr3)r4r rWrnr8rrrrns z1IOTest._check_base_destructor..MyIO.closecs|jtdSr3)r4r!rWrfr8rrrrfs z1IOTest._check_base_destructor..MyIO.flush)rrrr2rrnrfr\rrrXrMyIOsr"r)rrr)r1baser"r(rrr_check_base_destructors zIOTest._check_base_destructorcCs||jdSr3)r$rr8rrrtest_IOBase_destructorszIOTest.test_IOBase_destructorcCs||jdSr3)r$rr8rrrtest_RawIOBase_destructorsz IOTest.test_RawIOBase_destructorcCs||jdSr3)r$rr8rrrtest_BufferedIOBase_destructorsz%IOTest.test_BufferedIOBase_destructorcCs||jdSr3)r$rr8rrrtest_TextIOBase_destructorsz!IOTest.test_TextIOBase_destructorcCsz|tjd}|dWdn1s.0Y|tjd }||dWdn1sl0YdS)Nrrrr$rrr6rrPrrrrtest_close_flushess(zIOTest.test_close_flushescstdtdtfdd}||tjd| |  |   dS)NircsF|.||fWdn1s80YdSr3)rr6rr'r rGr1rrchecksz'IOTest.test_array_writes..checkr) r rangertobytesrrrrrrLrr)r1r-rr,rtest_array_writess  zIOTest.test_array_writescCs|jt|jtjddddS)NrFclosefdrrr$rrr8rrr test_closefdszIOTest.test_closefdcCs&|tjd}|dWdn1s.0Y|tjdT}|j|ddd}||d|d|| t |jWdn1s0Y|tjdX}|j|ddd}||ddd || t |j t d Wdn1s0YdS) Nregg r Fr1rrrseggrD) r$rrr6r<rrPrArnrrrHrr1r(filerrrtest_read_closeds( ,zIOTest.test_read_closedcCs|jt|jtjddddS)Nr Fr1r3r8rrrtest_no_closefd_with_filenamesz$IOTest.test_no_closefd_with_filenamecCs|tjd}|dWdn1s.0Y|tjdH}||jjjd|j|ddd}||jjjdWdn1s0YdS)Nrsegg r TFr1) r$rrr6rrrawr2r<r6rrrtest_closefd_attrs (zIOTest.test_closefd_attrcCstdtfB|tjd}|d||_t|}~t Wdn1sV0Y| ||| tjd }| | dWdn1s0YdS)Nrrsabcxxxr)rrrrrr6r(weakrefrefr assertIsNoner$rrP)r1r(wrrrrtest_garbage_collections  &zIOTest.test_garbage_collectioncCsd}tj|s |d|tjdkr4|dtjtj krJ|d|j |ddd}| t |j Wdn1s~0Y| |d}| t |j Wdn1s0Y| |d }| t |j Wdn1s0YdS) Nz /dev/zeroz{0} does not existz+test can only run in a 32-bit address spacez&test requires at least 2 GiB of memoryrrrr )rpathexistsrformatrmaxsizerZreal_max_memuseZ_2Gr$rrrP)r1Zzeror(rrrtest_unbounded_files     ,,zIOTest.test_unbounded_filecsh|j|i|gfdd}|_|tj|j||ddd_dS)Ncsjgdd<tdSr3rkrrlr(rr bad_flushsz4IOTest.check_flush_error_on_close..bad_flushrcSsdSr3rrrrrrMz3IOTest.check_flush_error_on_close..)r$rfrrmrn assertTruerl assertFalse)r1r}kwargsrHrrGrcheck_flush_error_on_close s  z!IOTest.check_flush_error_on_closecCs.|jtjdddttjtjtjB}|j|dddttjtjtjB}|j|ddddt||tjdttjtjtjB}||dttjtjtjB}|j|dddt||tjdttjtjtjB}||dttjtjtjB}|j|dddt|dS)NrrrF)rr2r1r)rMrrrr$O_WRONLYO_CREATrn)r1fdrrrtest_flush_error_on_closes$    z IOTest.test_flush_error_on_closecCs<|jtjddd}||||t|jdS)Nrrr)r$rrrnrrrfrrrrtest_multi_close3s zIOTest.test_multi_closecCs|d}||dd||dd||dd||dd||dd||dd||dd||dddS) N)abcdNefgNrVabcrTefgrM)r*rrPr1rawiorrrtest_RawIOBase_read:s zIOTest.test_RawIOBase_readcCs@|||||f}|D]}|t|dq&dS)N__dict__)rrrrrrJhasattr)r1rrrrrtest_types_have_dictGszIOTest.test_types_have_dictcs|tjd}|dWdn1s.0Yttjtjfdd}|jdd|d }||dWdn1s0YdS)Nrr5csSr3r)rBflagsrPrropenerVsz"IOTest.test_opener..opener non-existentr rb)r$rrr6rO_RDONLYrrP)r1r(rbrrar test_openerRs ( zIOTest.test_openercCsVdd}|t}tdd|dWdn1s60Y|t|jddS)NcSsdS)NrrZfnamer`rrr badopener]sz4IOTest.test_bad_opener_negative_1..badopenerrcr rdzopener returned -1rrr$rstr exceptionr1rhcmrrrtest_bad_opener_negative_1[s ,z!IOTest.test_bad_opener_negative_1cCsVdd}|t}tdd|dWdn1s60Y|t|jddS)NcSsdS)Nrrgrrrrhesz8IOTest.test_bad_opener_other_negative..badopenerrcr rdzopener returned -2rirlrrrtest_bad_opener_other_negativecs ,z%IOTest.test_bad_opener_other_negativec Cs|tdx}|tdL}|j|dd}|j|dd|||Wdn1sl0YWdn1s0YdS)NrFr1)r$r%rr<r2rrn)r1f1f2Zfileiorrrtest_fileio_closefdks zIOTest.test_fileio_closefdc Csjt|L|t"|jtjdddWdn1s>0YWdn1s\0YdS)Nrrrrcheck_no_resource_warningrrr$rr8rrrtest_nonbuffered_textiows  zIOTest.test_nonbuffered_textioc Csjt|L|t"|jtjdddWdn1s>0YWdn1s\0YdS)Nrinvalidnewlinertr8rrrtest_invalid_newline|s  zIOTest.test_invalid_newlinec Cs~Gddd|j}|}dD]\}||>td}|t|||d|t|dWdq1sn0YqdS)Nc@seZdZddZeZdS)z3IOTest.test_buffered_readinto_mixin..StreamcSsdS)N12345rr1sizerrrrPsz8IOTest.test_buffered_readinto_mixin..Stream.readN)rrrrPread1rrrrStreamsrrHrr[r{)rrrrgetattrr)r1rstreammethodrrrrtest_buffered_readinto_mixins z#IOTest.test_buffered_readinto_mixinc s`fdd}|ttj|tttjtjdR}t|}t|dWdn1sv0YWdn1s0Ytd}t|dWdn1s0Ytt }t |dWdn1s0Y t d"ttjdWdn1sR0YdS)Ncsv|d}|dWdn1s,0Y|d }|dWdn1sh0YdS)Nrr5r )r$r6rrP)rBr(r8rrcheck_path_succeedss(z7IOTest.test_fspath_support..check_path_succeedsrzread/write/append modeZrwxa) r rrrfsencoder$r<rrFloatingPointErrorassertRaisesRegexr)r1rr(Zbad_pathrr8rtest_fspath_supports   H * ,zIOTest.test_fspath_supportcCs8|d}||d|d}||ddSNrSrTrUabcdefg)r*rrPreadallrZrrrtest_RawIOBase_readalls  zIOTest.test_RawIOBase_readallc CsGddd|j}d}d}|D]}|||\}}}}|tt|} t|f|} t| |}||| ||t| ||| d|t||f||} || |d| |t| j ||Wdq1s0YqdS)Nc@s$eZdZddZddZddZdS)z3IOTest.test_BufferedIOBase_readinto..ReadercSs ||_dSr3avail)r1rrrrr2sz.Reader.__init__cSs"|jd|}|j|d|_|Sr3r)r1r}resultrrrrPsz8IOTest.test_BufferedIOBase_readinto..Reader.readcSs|t|dSrZ)rPminr|rrrr~sz9IOTest.test_BufferedIOBase_readinto..Reader.read1N)rrrr2rPr~rrrrReadersr) )rHrr[r[)rHrrr)rHr[rr[)rHrr)rHrrr)rrr[r[)rrrr[)rr[rr[)rrrr[)rrrr) rrrr.rrrrZassertSequenceEqualr) r1rrZ UNUSED_BYTErrrZrequestrreaderrZunusedrrrtest_BufferedIOBase_readintos    z#IOTest.test_BufferedIOBase_readintocCs4Gddd|j}|}|t|jdd|_dS)Nc@seZdZddZddZdS)z#IOTest.test_close_assert..RcSsdSr3r)r1namevaluerrr __setattr__sz/IOTest.test_close_assert..R.__setattr__cSs tdSr3rmr8rrrrfsz)IOTest.test_close_assert..R.flushN)rrrrrfrrrrrsrcSsdSr3rr8rrrrIrMz*IOTest.test_close_assert..)rrrmrnrf)r1rr(rrrtest_close_assertszIOTest.test_close_assertN)F)3rrrrrrrrrrrrrrrrrrrr r rr$r%r&r'r(r*r0r4r8r9r;r@rFrMrQrRr\r_rfrnrprsrvrzrrrrrrrrrr4s` !h           )rc@seZdZddZdS)CIOTestcCsLGddd|j}||}||_t|}~~t|||dS)Nc@seZdZddZdS)z*CIOTest.test_IOBase_finalize..MyIOcSsdSr3rr8rrrrnsz0CIOTest.test_IOBase_finalize..MyIO.closeNrrrrnrrrrr"sr")rrr<r=rrr>)r1r"rr?rrrtest_IOBase_finalizes zCIOTest.test_IOBase_finalizeN)rrrrrrrrrsrc@s eZdZdS)PyIOTestNrrrrrrsrc@seZdZddZddZdS)APIMismatchTestcCs*tjtjtjdd}|j|tdddS)N) __weakref__)rz6Python RawIOBase does not have all C RawIOBase methodsmsg)rdetect_api_mismatchrrrrrcr1Zmismatchrrrtest_RawIOBase_io_in_pyio_matchs z/APIMismatchTest.test_RawIOBase_io_in_pyio_matchcCs&ttjtj}|j|tdddS)Nz6C RawIOBase does not have all Python RawIOBase methodsr)rrrrrrrcrrrrtest_RawIOBase_pyio_in_io_match sz/APIMismatchTest.test_RawIOBase_pyio_in_io_matchN)rrrrrrrrrrsrc@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)CommonBufferedTestscCs<|}||}||||t|jt|dSr3)rLtpassertIsdetachrrreprr1r:rFrrr test_detachs  zCommonBufferedTests.test_detachcCs&|}||}|d|dSr:)rLrrr<r1r[bufiorrr test_filenos zCommonBufferedTests.test_filenocCs:|}||}|t|jdd|t|jdddS)Nrrr)rLrrrrArrrrtest_invalid_args!s z%CommonBufferedTests.test_invalid_argscsL|j}gGfddd|}|}||}~t|gddS)Ncs:eZdZfddZfddZfddZZS)zBCommonBufferedTests.test_override_destructor..MyBufferedIOcs4dz tj}Wnty(Yn0|dSrjrrrrrr,s    zJCommonBufferedTests.test_override_destructor..MyBufferedIO.__del__csdtdSrUrr8rrrrn4s zHCommonBufferedTests.test_override_destructor..MyBufferedIO.closecsdtdSrrr8rrrrf7s zHCommonBufferedTests.test_override_destructor..MyBufferedIO.flushrrrrXr MyBufferedIO+srr)rrLrrr)r1rrr[rrrrtest_override_destructor(sz,CommonBufferedTests.test_override_destructorcs4|}||fdd}||t|dS)Ncs(Wdn1s0YdSr3rrrrr_withDsz7CommonBufferedTests.test_context_manager.._with)rLrrr)r1r[rrrrtest_context_manager@s   z(CommonBufferedTests.test_context_managerc Cs|}tr}|t||jWdn1s>0YtsZ||j n|j durt| |j j t Wdn1s0YdSr3) rircatch_unraisable_exceptionrrrxyzzyIOBASE_EMITS_UNRAISABLEr> unraisablerexc_typermr1r[rmrrrtest_error_through_destructorLs  * z1CommonBufferedTests.test_error_through_destructorcCsr|}||}d|jj|jjf}|t|d|d|_|t|d|d|_|t|d|dS)Nz (%s\.)?%sz<%s>dummyz<%s name='dummy'>dummyz<%s name=b'dummy'>)rLrrr assertRegexrr)r1r:r Zclsnamerrr test_reprYs zCommonBufferedTests.test_reprc Csd|}||}t|d|0z t|Wnty@Yn0Wdn1sV0YdSNr)rLrr swap_attrr RuntimeErrorr1r:r rrrtest_recursive_reprcs   z'CommonBufferedTests.test_recursive_reprcs|gfdd}|_||tj|j|j||d|ddd_dS)Ncsjjgdd<tdSr3rkrr rlr:rrrHrsz@CommonBufferedTests.test_flush_error_on_close..bad_flushrrDcSsdSr3rrrrrrI}rMz?CommonBufferedTests.test_flush_error_on_close..) rLrfrrrmrnrJrlrKr1rHrrrrQms    z-CommonBufferedTests.test_flush_error_on_closecCs|}dd}dd}||_||}||_|t}|Wdn1sV0Y||jjd| |jj t||jj jd| |j dd|_d d|_dS) NcSs tddSNrfrrrrrrHsz@CommonBufferedTests.test_close_error_on_close..bad_flushcSs tddSNrnrrrrr bad_closesz@CommonBufferedTests.test_close_error_on_close..bad_closernrfcSsdSr3rrrrrrIrMz?CommonBufferedTests.test_close_error_on_close..cSsdSr3rrrrrrIrM) rLrnrrfrrmrrkr}assertIsInstance __context__rKrlr1r:rHrr errrrrtest_close_error_on_closes  &  z-CommonBufferedTests.test_close_error_on_closecCs|}dd}dd}||_||}||_|t}|Wdn1sV0Y|dt|j| |jj t|dt|jj | |j dd|_d d|_dS) NcSstdSr3non_existing_flushrrrrrHszNCommonBufferedTests.test_nonnormalized_close_error_on_close..bad_flushcSstdSr3non_existing_closerrrrrszNCommonBufferedTests.test_nonnormalized_close_error_on_close..bad_closerrcSsdSr3rrrrrrIrMzMCommonBufferedTests.test_nonnormalized_close_error_on_close..cSsdSr3rrrrrrIrM) rLrnrrfr NameErrorassertInrjrkrrrKrlrrrr'test_nonnormalized_close_error_on_closes  &  z;CommonBufferedTests.test_nonnormalized_close_error_on_closecCs<|}||}||||t|jdSr3)rLrrnrrrfrrrrrRs  z$CommonBufferedTests.test_multi_closecCs6||d}||j|j||j|jddS)N AAAAAAAAAAr)rrwrr{rBrAr1rrrrtest_unseekablesz#CommonBufferedTests.test_unseekablecCsN|}||}|}|t||_Wdn1s@0YdSr3)rLrrrr:)r1r:rFxrrrtest_readonly_attributess   z,CommonBufferedTests.test_readonly_attributesN)rrrrrrrrrrrrQrrrRrrrrrrrs    rc@s(eZdZejddZejddZdS) SizeofTestcCs\d}d}|}|j||d}t||}|}|j||d}|t|||dS)N  buffer_size)rLrr getsizeofr)r1Zbufsize1Zbufsize2r[rr}rrr test_sizeofszSizeofTest.test_sizeofcCsFd}|}|j||d}t||}||t||dS)Nrr)rLrrrrnr)r1rr[rr}rrrtest_buffer_freeings zSizeofTest.test_buffer_freeingN)rrrr cpython_onlyrrrrrrrs rc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZeddd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+S),BufferedReaderTestrcCs|dg}||}|||j|dd|j|dd|d||jt|j|dd|jt|j|dd|jt|j|dd|dg}|||d|dS)NrSrrr)rLrr2rrPrrrrrrtest_constructors     z#BufferedReaderTest.test_constructorcCsX|j|j}~|j|j}|ttfd|jd||||dddSNuninitialized|has no attributerrM) r__new__rrrrPr2rLrrrrrtest_uninitializeds z%BufferedReaderTest.test_uninitializedcCsDdD]*}|d}||}|d||q|t|jddS)N)Nrrrro)rLrrrPrr)r1argr[rrrr test_reads   zBufferedReaderTest.test_readcCs|d}||}|d|d|d|d||jd|d|d|d|d||jd|d |d||jd |d |d||jd |d|d||jd dS)NrarDbrMrrWrrTrVrUrrrLrrrPr~r/rrrr test_read1s  zBufferedReaderTest.test_read1cCs|d}||}|d|d|d||d||d|d||jd|d |||jd dS) NrrrDsbcrTrUrrrMrrrrrrtest_read1_arbitrarys  z'BufferedReaderTest.test_read1_arbitrarycCs|d}||}td}|||d||d|||d||d|||d||d|||d||d|||d||d|d }||}|||d||d|||d||d dS) NrrVrVcdrXrDsgfr)rSNscb)rLrrrrH)r1r[rr rrr test_readintos&          z BufferedReaderTest.test_readintocCs4d}|d}|j||d}td}||dd||jd|||d||d||jd|||d||ddd ||jd|||d||d ||jdtd|}||dd ||jd|||d ||dd d ||jddS)Nr)rSdefghsjklrrVrrSrDrVrWrrrsfghjklr)rLrrrpeekr/r)r1rr[rr rrrtest_readinto1&s*    z!BufferedReaderTest.test_readinto1cCsd}d}||f}|j||d}tdd}||}||t|t|d}||t|| |d||d|| ||ddt||ddSN<saaaaaaaaaaaaaaaaaaaaaaaaaarr+s xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrr) rLrr rHr rrr assertLessrr1rrr[rr rGZbmrrrtest_readinto_array=s   z&BufferedReaderTest.test_readinto_arraycCsd}d}||f}|j||d}tdd}||}||t|t|d}||t|| |d||d|| ||ddt||ddSr) rLrr rr rrrrrrrrrtest_readinto1_arrayRs   z'BufferedReaderTest.test_readinto1_arraycsVfdd}|gd|dddg|dgddS)Ncsd}|S)NrrrX)rLr)r[r8rrrhs z0BufferedReaderTest.test_readlines..bufiorr[rrrrrrr8rtest_readlinesgs z!BufferedReaderTest.test_readlinesc Csd}t|}dgd|dggdgd|ggdgdgdgg}|D]d\}}}||}|j||d }d} |D]*} ||| || | | | | 7} ql||j|qBdS) N abcdefghir)rrDrr)rrrr)rDrVrrV)rrrDr)rrqrrrPrr) r1rZdlenrrZbuf_read_sizesZraw_read_sizesr[rrnbytesrrrtest_bufferingos  z!BufferedReaderTest.test_bufferingcCs|d}||}|d|d|d|d|d||d|d|||d||d}|d |||dS) N)rSrTNrUNNNabcdrerDsfgrM)rNNr)rLrrrPrr>rrrrrtest_read_non_blockings   z)BufferedReaderTest.test_read_non_blockingcCs*|d}||}|d|ddS)Nrri(#rLrrrPrrrrtest_read_past_eofs  z%BufferedReaderTest.test_read_past_eofcCs(|d}||}|d|dSrrrrrr test_read_alls  z BufferedReaderTest.test_read_allcpuc svz`d}ttd|}t|tt|}|tjd |Wdn1s\0Y|jtj|j dd}| |dggfddfd d td D}t |t d Wdn1s0Y|d d}tdD]&}tt|g}||||q Wdn1sJ0YWttjnttj0dS)Nrrrr c shz2tddgD] }|}|s$q0|qWn0tyb}z|WYd}~n d}~00dS)NrD)rrPr4 Exception)rGre)rerrorsresultsrrr(s  z*BufferedReaderTest.test_threads..fcsg|]}tjdqSrr`r.0rr'rr rMz3BufferedReaderTest.test_threads..r{Gz?(the following exceptions were caught: %rrM)r,r.randomshufflerrr$rrr6 read_moder start_threadsrdrerKrrrr)r1Nlrr:threadsr+cr)rrr(rr test_threadss.  (   (  8zBufferedReaderTest.test_threadscCsb||d}||j|j||j|jd|d||j|jd||j|jdS)NrrrD)rrwrr{rBrArPrrrrrs  z"BufferedReaderTest.test_unseekablecCs@|d}||}|t|jd|t|jdd|_dS)NrrcSsdSr3rrrrrrIrMz7BufferedReaderTest.test_misbehaved_io..)rTrrrmrArBrnrrrrtest_misbehaved_ios   z%BufferedReaderTest.test_misbehaved_ioc Csd}d|d||d|dfD]}|d|g}|||}|||d|||jdd||j|d|ddg}|||}|||d|||jdd||jqdS)NrrVrDrrzfailed for {}: {} != 0)rLrrrPr0rD)r1rrGr[rrrrtest_no_extraneous_reads      z*BufferedReaderTest.test_no_extraneous_readcCsDttd}|d||t|j|t|jddS)N12rD) rrrrPrnrrrr~r5rrrtest_read_on_closeds  z&BufferedReaderTest.test_read_on_closedcCsH|d}||}||||j|j||j|jddS)NrSr)rqrrKr9rr{rIrrrrtest_truncate_on_read_onlys   z-BufferedReaderTest.test_truncate_on_read_onlyN)rrrr%rrrrrrrrrrr rrrrrequires_resourcer+rr,r-r/r0rrrrrs,   ' rc@sHeZdZejZeddddddZddZdd Z d d Z d d Z dS)CBufferedReaderTestTLsanitizer defaults to crashing instead of returning NULL for malloc failure.ZmemoryaddressreasoncCsDt|tjdkr@|}||}|ttt f|j |tjdSNrA) rrrrErLrrr MemoryErrorrr2rrrrrs     z$CBufferedReaderTest.test_constructorcCs|dg}||}|jt|j|dd|t|j|jt|j|dd|t|j|jt|j|dd|t|jdS)NrSrrrr)rLrrrr2rPrrrrtest_initialization s  z'CBufferedReaderTest.test_initializationcCs(|d}||}|t|jddS)Nrr)rTrrrmrPrrrrtest_misbehaved_io_reads  z+CBufferedReaderTest.test_misbehaved_io_readcCs|tjtjtdtfB|tjd}||}||_t |}~t Wdn1sf0Y| ||dS)Nrr) rrrrrrrrr(r<r=rr>r1r[r(r?rrrr@s  &z+CBufferedReaderTest.test_garbage_collectioncCsD|td$|tdddWdn1s60YdS)Nrrrrrrrr8rrrtest_args_error(sz#CBufferedReaderTest.test_args_errorN) rrrrrrr rr9r:r@r=rrrrr2s    r2c@seZdZejZdS)PyBufferedReaderTestN)rrrrrrrrrrr>.sr>c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zed(d)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3S)4BufferedWriterTestrcCs|}||}|||j|dd|j|dd|d|d||jt|j|dd|jt|j|dd|jt|j|dd|||d|d ||d |j d dS) NrrrrrSrrrghirMsabcghi) rLrr2rr6rfrrrr.rrrrr5s   z#BufferedWriterTest.test_constructorcCsX|j|j}~|j|j}|ttfd|jd||||dddS)NrrMr) rrrrrr6r2rLrrrrrrEs z%BufferedWriterTest.test_uninitializedcCsD|}||}|d||j|||jdgdS)Nshowdy!)rLrr6rKr.rrrrrrtest_detach_flushOs    z$BufferedWriterTest.test_detach_flushcCsh|}||d}|d||jtd}||d|dd<||d|jddS)Nr rSdef***rMabcdef) rLrr6rKr.rrfrr)r1writerrrrrr test_writeWs     zBufferedWriterTest.test_writecCsn|}||d}d}tdt|dD]}||||dq(d|j}|||dd|dS)Nr sabcdefghijklmnoprrrMi) rLrr.rr6rr.rJr)r1rErcontentsrGZflushedrrrtest_write_overflowcs  z&BufferedWriterTest.test_write_overflowc Csttdd}d}|}||d}dd}|}|t|krtt|t||}|||||||||||7}q6| ||d |j dS)Nrrrrcss&tdD]}tdD] }|VqqdS)NrD)rr.)r}r+rrr gen_sizesus  z2BufferedWriterTest.check_writes..gen_sizesrM) rr.rLrrrrrr6rfrr.) r1Zintermediate_funcrGrGrErrJsizesr}rrr check_writesns   zBufferedWriterTest.check_writescCs|dddS)NcSsdSr3rrrrrrIrMz0BufferedWriterTest.test_writes..rLr8rrr test_writesszBufferedWriterTest.test_writescCs|dddS)NcSs|Sr3rrrrrrIrMz.rMr8rrrtest_writes_and_flushessz*BufferedWriterTest.test_writes_and_flushescCs(dd}||dd}||dS)NcSs8|}||dd||dd||ddSrC)rBrArrrrr_seekabssz:BufferedWriterTest.test_writes_and_seeks.._seekabscSs4|dd}|dd|dd||ddS)NrrDr)rArPrrr_seekrels   z:BufferedWriterTest.test_writes_and_seeks.._seekrelrM)r1rQrRrrrtest_writes_and_seekss z(BufferedWriterTest.test_writes_and_seekscCs|dddS)NcSs||Sr3)rIrBrrrrrIrMz>BufferedWriterTest.test_writes_and_truncates..rMr8rrrtest_writes_and_truncatessz,BufferedWriterTest.test_writes_and_truncatesc Cs|}||d}||dd||dd|d||dd|dz|d Wn,|jy}z|j}WYd}~nd}~00|d ||d ||d ||d d|}| | d|dS)Nr r rsefghir[ksjklmn0sopqrwxyz0123456789z'BlockingIOError should have been raisedrsabcdefghijklmnopqrwxyzs ABCDEFGHIrs 01234567A) rrrr6rrcharacters_writtenrrrJr)r1r:rrwrittenrrrrtest_write_non_blockings&      z*BufferedWriterTest.test_write_non_blockingcCst}||d}||dd||d|dd||dd|dd||d||dd|||d dS) NrrDrrsXYrVsXYcdefs123456s XYcdef123456) rrrrr6rBrArrfr1r:rrrrtest_write_and_rewinds   z(BufferedWriterTest.test_write_and_rewindcCs<|}||d}|d||d|jddSNr rSr)rLrr6rfrr.r1rErrrr test_flushs   zBufferedWriterTest.test_flushcCsFgd}|}||d}||||d|jddSN)rVrrXr rMrD)rLrrrfrrr.r1r(rErrrrtest_writeliness   z"BufferedWriterTest.test_writelinescCsJtgd}|}||d}||||d|jddSr_)rrLrrrfrrr.r`rrrtest_writelines_userlists    z+BufferedWriterTest.test_writelines_userlistcCsL|}||d}|t|jgd|t|jd|t|jddS)Nr rabc)rLrrrrr]rrrtest_writelines_errors  z(BufferedWriterTest.test_writelines_errorcCs>|}||d}|d~t|d|jddSr\)rLrr6rrrr.r]rrrrs   z"BufferedWriterTest.test_destructorcCs|tjtj|jtj|jddH}||d}|d|| dd|| dWdn1sr0Y|jtjddd }|| dWdn1s0YdS) Nrrr rDrrrrS) rrrrr$ write_moderr6rrIrBrP)r1r:rr(rrr test_truncates  .z BufferedWriterTest.test_truncatec Cs|tjtj|tjd}|ddWdn1sB0Ygd}|D]n}|jtjd|dH}|d|d|d||| |dWdqX1s0YqXdS) Nri')rrzr+brrDrV) rrrrr$r6rPrIrrB)r1r(Z buffer_sizesrrrrtest_truncate_after_writes, z,BufferedWriterTest.test_truncate_after_writerc szd}ttd|}tddg}d}t|t|krbt|}||||||7}q.~|jtj |j dd}| |dgfdd fd d td D}t |t d Wdn1s0Y|dWdn1s0Y|tj d}Wdn1sJ0YtdD]} ||t| g|q\Wttj nttj 0dS)NrrrDrrrr c sjz4z }Wnty$YWdS0|qWn0tyd}z|WYd}~n d}~00dSr3)popleftrEr6rr4)rr)rrqueuerrr(s    z*BufferedWriterTest.test_threads..fcsg|]}tjdqSrrrr'rrr &rMz3BufferedWriterTest.test_threads..rr!r"r)rr.rrrrr4r$rrrerr&rdrerKrnrPrrr) r1r'rGrKrGr}r:r)rr+r)rrr(rkrr+s6      ((( zBufferedWriterTest.test_threadscCsP|}||d}|t|jd|t|j|t|jddd|_dS)Nr[rrDcSsdSr3rrrrrrI;rMz7BufferedWriterTest.test_misbehaved_io..)rTrrrmrArBr6rnrrrrr,3s  z%BufferedWriterTest.test_misbehaved_iocCs@|t"||ddWdn1s20YdSNr rrrrrLr8rrrtest_max_buffer_size_removal=s z/BufferedWriterTest.test_max_buffer_size_removalcCsH|}dd}||_||}|d|t|j||jdS)NcSs tdSr3r)r rrr bad_writeCsz?BufferedWriterTest.test_write_error_on_close..bad_writespam)rLr6rrrmrnrJrl)r1r:ror rrrtest_write_error_on_closeAs  z,BufferedWriterTest.test_write_error_on_closecCs\|}||d}tj|jd}||j|t |j d| |j | dS)Nr rrp)r_rr`rrnrrbwaitrrr6rJrlr)r1r[rtrrrtest_slow_close_from_threadKs   z.BufferedWriterTest.test_slow_close_from_threadN)rrrrerrrArFrHrLrNrOrSrTrYr[r^rarbrdrrfrirr1r+r,rnrqrtrrrrr?2s4      .  r?c@s@eZdZejZeddddddZddZdd Z d d Z d S) CBufferedWriterTestTr3r4cCsDt|tjdkr@|}||}|ttt f|j |tjdSr7) r?rrrErLrrrr8rr2rrrrr[s     z$CBufferedWriterTest.test_constructorcCs|}||}|jt|j|dd|t|jd|jt|j|dd|t|jd|jt|j|dd|t|jddS)NrrrBrr)rLrrrr2r6rrrrr9gs z'CBufferedWriterTest.test_initializationcCs|tjtjtdtfL|tjd}||}|d||_ t |}~t Wdn1sp0Y| |||tjd }||dWdn1s0YdS)Nrrs123xxxr)rrrrrrrrr6rr<r=rr>r$rrPr;rrrr@qs   &z+CBufferedWriterTest.test_garbage_collectioncCsD|td$|tdddWdn1s60YdS)Nrrr<r8rrrr=sz#CBufferedWriterTest.test_args_errorN) rrrrrrr rr9r@r=rrrrruXs    ruc@seZdZejZdS)PyBufferedWriterTestN)rrrrrrrrrrrvsrvc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+S),BufferedRWPairTestcCs$|||}||jdSr3)rrLrKrlr1pairrrrrsz#BufferedRWPairTest.test_constructorcCs|j|j}~|j|j}|ttfd|jd|ttfd|jd|||| |dd| |dddSr) rrrrrrPr6r2rLrrxrrrrs  z%BufferedRWPairTest.test_uninitializedcCs(|||}||j|jdSr3)rrLrr{rrxrrrrszBufferedRWPairTest.test_detachcCsF|t(|||ddWdn1s80YdSrlrmr8rrr(test_constructor_max_buffer_size_removals z;BufferedRWPairTest.test_constructor_max_buffer_size_removalcCs,Gdddt}|t|j||dS)Nc@seZdZddZdS)zJBufferedRWPairTest.test_constructor_with_not_readable..NotReadablecSsdSrxrr8rrrr=szSBufferedRWPairTest.test_constructor_with_not_readable..NotReadable.readableNrrrr=rrrr NotReadablesr|rLrrmr)r1r|rrr"test_constructor_with_not_readablesz5BufferedRWPairTest.test_constructor_with_not_readablecCs,Gdddt}|t|j||dS)Nc@seZdZddZdS)zLBufferedRWPairTest.test_constructor_with_not_writeable..NotWriteablecSsdSrxrr8rrrr9szUBufferedRWPairTest.test_constructor_with_not_writeable..NotWriteable.writableN)rrrr9rrrr NotWriteablesrr})r1rrrr#test_constructor_with_not_writeablesz6BufferedRWPairTest.test_constructor_with_not_writeablecCsv||d|}||dd||dd||d||d|}||dddS)NrDrrSrDrTrX)rrrLrrPrxrrrrs zBufferedRWPairTest.test_readcsTfdd}|gd|gd|dddgdS)NcsdS)Ns abc def h)rrrLrr8rrrIrMz3BufferedRWPairTest.test_readlines..)rrrr[rrrrxrr8rrs z!BufferedRWPairTest.test_readlinescCs<||d|}||dd||ddS)NrDrrSrB)rrrLrr~rxrrrrszBufferedRWPairTest.test_read1c Cs|dD]r}||T||d|}td}|t|||d|t|dWdq1sl0YqdS)NrrDsr[sabcde)rrrrLrrrr)r1rryrrrrrs  z BufferedRWPairTest.test_readintocCsf|}|||}|d|td}||d|dd<|||jddgdS)NrSrBrC)rLrr6rfrrr.)r1rryrrrrrFs   zBufferedRWPairTest.test_writecCsB||d|}||dd||dddS)NrDrrS)rrrLrJrrrrPrxrrr test_peekszBufferedRWPairTest.test_peekcCs&|||}||dSr3)rrLrJr=rxrrr test_readablesz BufferedRWPairTest.test_readablecCs&|||}||dSr3)rrLrJr9rxrrrtest_writeablesz!BufferedRWPairTest.test_writeablecCs&|||}||dSr3)rrLrKr>rxrrr test_seekablesz BufferedRWPairTest.test_seekablecCs8|||}||j|||jdSr3)rrLrKrlrnrJrxrrrtest_close_and_closeds z(BufferedRWPairTest.test_close_and_closedcCsdd}|}||_|}|||}|t}|Wdn1sR0Y|dt|j||j | |j ||j dd|_dS)NcSstdSr3reader_non_existingrrrr reader_closeszIBufferedRWPairTest.test_reader_close_error_on_close..reader_closercSsdSr3rrrrrrI rMzEBufferedRWPairTest.test_reader_close_error_on_close..) rLrnrrrrrjrkrJrlrK)r1rrrEryrrrr test_reader_close_error_on_closes  &   z3BufferedRWPairTest.test_reader_close_error_on_closec Csdd}|}|}||_|||}|t}|Wdn1sR0Y|dt|j||j | |j ||j dd|_d}t Lt d}t Wdn1s0Yt Wdn1s0YdS)NcSstdSr3writer_non_existingrrrr writer_closeszIBufferedRWPairTest.test_writer_close_error_on_close..writer_closercSsdSr3rrrrrrIrMzEBufferedRWPairTest.test_writer_close_error_on_close..)rLrnrrrrrjrkrKrlrJrrr)r1rrrEryrrrr test_writer_close_error_on_closes$  &      &z3BufferedRWPairTest.test_writer_close_error_on_closecCsdd}dd}|}||_|}||_|||}|t}|Wdn1s`0Y|dt|j||jj t|dt|jj | |j | |j | |j dd|_d d|_dS) NcSstdSr3rrrrrr*szPBufferedRWPairTest.test_reader_writer_close_error_on_close..reader_closecSstdSr3rrrrrr,szPBufferedRWPairTest.test_reader_writer_close_error_on_close..writer_closerrcSsdSr3rrrrrrI=rMzLBufferedRWPairTest.test_reader_writer_close_error_on_close..cSsdSr3rrrrrrI>rM) rLrnrrrrrjrkrrrKrl)r1rrrrEryrrrr'test_reader_writer_close_error_on_close)s"  &    z:BufferedRWPairTest.test_reader_writer_close_error_on_closecCsGdddt}||d|d}||||d|d}||||d|d}||||d|d}||dS)Nc@seZdZddZddZdS)z8BufferedRWPairTest.test_isatty..SelectableIsAttycSst|||_dSr3)rLr2_isatty)r1isattyrrrr2Bs zABufferedRWPairTest.test_isatty..SelectableIsAtty.__init__cSs|jSr3)rr8rrrrFsz?BufferedRWPairTest.test_isatty..SelectableIsAtty.isattyN)rrrr2rrrrrSelectableIsAttyAsrFT)rLrrKrrJ)r1rryrrr test_isatty@szBufferedRWPairTest.test_isattycCs*|||}t|}d}d}dSr3)rrLr<r=)r1Zbrwr=rrrtest_weakref_clearingUs z(BufferedRWPairTest.test_weakref_clearingN)rrrrrrrzr~rrrrrrFrrrrrrrrrrrrrrrws*    rwc@seZdZejZdS)CBufferedRWPairTestN)rrrrrrrrrrr[src@seZdZejZdS)PyBufferedRWPairTestN)rrrrrrrrrrr^src@seZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+Zd+Zd+S),BufferedRandomTestrb+zwb+cCst|t|dSr3)rrr?r8rrrrfs z#BufferedRandomTest.test_constructorcCst|t|dSr3)rrr?r8rrrrjs z%BufferedRandomTest.test_uninitializedcCsn|d}||d}|d|d|d|d||j|d||d|jd dS) N)asdfghjkr asrVsdddseeersdddeeer)rLrrrPr6rKr.r1r:rrrrtest_read_and_writens     z&BufferedRandomTest.test_read_and_writecCs|d}||}|d|d|d||dd|d|d|d|dd|d||d ||d d|d ||dd |d ||d|d||d|| t |jddS)Ns asdfghjklrrVrrrs123fs asdf123flrr[rDrsfl r) rrrrPrBrAr6rfrrrrrrrtest_seek_and_tellys$       z%BufferedRandomTest.test_seek_and_tellcCs|d}||}|d||d|d|d||d|d|||d||d|||dd|d ||dd|d ||d dS) Nr rVrVr.rXrr@rsXYZr)rrrr6rBrfrA)r1Z read_funcr:rrrrcheck_flush_and_reads      z'BufferedRandomTest.check_flush_and_readcCs|dddS)NcWs |j|Sr3)rP)rr}rrrrIrMz8BufferedRandomTest.test_flush_and_read..rr8rrrtest_flush_and_readsz&BufferedRandomTest.test_flush_and_readcCsddd}||dS)NrcSs.t|dkr|nd}||}t|d|S)Nr')rrHrrrGr rrr _readintos z=BufferedRandomTest.test_flush_and_readinto.._readinto)rr)r1rrrrtest_flush_and_readintos z*BufferedRandomTest.test_flush_and_readintocCsddd}||dS)NrcSs2||}|dkr|d|}|t|d|SNrrD)rrArrrrr_peeks   z5BufferedRandomTest.test_flush_and_peek.._peek)rrr1rrrrtest_flush_and_peeks z&BufferedRandomTest.test_flush_and_peekcCsh|d}||}|d||d||dd|d||d|dS)Nr 123s45rs 12345fghi)rrr6rfrArrrPrZrrrtest_flush_and_writes     z'BufferedRandomTest.test_flush_and_writecCst|t|dSr3)rr+r?r8rrrr+s zBufferedRandomTest.test_threadscCs(dd}||dd}||dS)NcSs|ddSrj)rrrrrrsz6BufferedRandomTest.test_writes_and_peek.._peekcSs.|}|dd|d||ddS)NrrDr)rBrArrPrrrrs  rMrrrrtest_writes_and_peeks z'BufferedRandomTest.test_writes_and_peekcCsdd}||dS)NcSs|dd|ddSr)rArPrrrr_reads z7BufferedRandomTest.test_writes_and_reads.._readrMr1rrrrtest_writes_and_readssz(BufferedRandomTest.test_writes_and_readscCsdd}||dS)NcSs|dd|ddSr)rAr~rrrr_read1s z9BufferedRandomTest.test_writes_and_read1s.._read1rM)r1rrrrtest_writes_and_read1ssz)BufferedRandomTest.test_writes_and_read1scCsdd}||dS)NcSs|dd|tddSr)rArHrrrrrrs z;BufferedRandomTest.test_writes_and_readintos.._readrMrrrrtest_writes_and_readintossz,BufferedRandomTest.test_writes_and_readintoscCsdD]}|d}||d}||dd||d|d||||d||||d|}||dd|dd|qdS)N)rDr[rrrDABr)rrrrPrBr6rfr)r1Zoverwrite_sizer:rrrrrtest_write_after_readaheads  z-BufferedRandomTest.test_write_after_readaheadc Csdd}d}tdt|D]t}t|t|D]`}||}||d}|||||t|}d||<d||<|||d||fq,qdS) NcSs:||||||d|||ddS)N)rArPr6)rZpos1Zpos2rrrmutates    z:BufferedRandomTest.test_write_rewind_write..mutatesrrrVrDzfailed result for i=%d, j=%d)r.rrrrfrrr)r1rr r+jr:rexpectedrrrtest_write_rewind_writes      z*BufferedRandomTest.test_write_rewind_writecCs^|d}||d}||dd||d||dd||ddS)NrrrVsAAsBBr)rrrrPrIr6rZrrr!test_truncate_after_read_or_write s   z4BufferedRandomTest.test_truncate_after_read_or_writecCst|t|dSr3)rr,r?r8rrrr, s z%BufferedRandomTest.test_misbehaved_ioc Cs|d}||d}|d||dd|d||dd|dtd}||||d |d ||dd | || d Wdn1s0YWdn1s0Y|d }||dV}||dd|d||dd| || dWdn1s`0YWdn1s0YdS)Nsabcdefghr1rDr2rTrf4rs1b2d3f4hrSrrWsa2c) rrr6rrPr~rrHrrfr)r1r:r(rFrrrtest_interleaved_read_write s*       L  z.BufferedRandomTest.test_interleaved_read_writec Cs|d}||v}|d||d|d||d|d||d|||dWdn1s0YWdn1s0YdS) Ns ab cdef g rsb rrr s 1b 2def 3 )rrr6rrrfr)r1r:r(rrrtest_interleaved_readline_write7 s     z2BufferedRandomTest.test_interleaved_readline_writeN)rrrr%rerrrrrrrrrr+rrrrrrrr,rrrr0rrrrrbs0     rc@s8eZdZejZeddddddZddZdd Z d S) CBufferedRandomTestTr3r4cCsDt|tjdkr@|}||}|ttt f|j |tjdSr7) rrrrErLrrrr8rr2rrrrrN s     z$CBufferedRandomTest.test_constructorcCst|t|dSr3)r2r@rur8rrrr@Z s z+CBufferedRandomTest.test_garbage_collectioncCsD|td$|tdddWdn1s60YdS)Nrrr<r8rrrr=^ sz#CBufferedRandomTest.test_args_errorN) rrrrrrr rr@r=rrrrrK s   rc@seZdZejZdS)PyBufferedRandomTestN)rrrrrrrrrrrd src@sXeZdZdddZddZddZdd Zd d Zdd dZddZ d Z e ddZ dS)StatefulIncrementalDecoderstrictcCstj|||dSr3)codecsIncrementalDecoderr2reset)r1rrrrr2 sz#StatefulIncrementalDecoder.__init__cCs dt|S)Nz)idr8rrr__repr__ sz#StatefulIncrementalDecoder.__repr__cCsd|_d|_t|_dSrj)r+orrr8rrrr sz StatefulIncrementalDecoder.resetcCs,|jdA|jdA}}t|j|d|fS)NrDr)r+rrr)r1r+rrrrgetstate sz#StatefulIncrementalDecoder.getstatecCs:|\}}t||_t|d\}}|dA|dA|_|_dS)NrrD)rrdivmodr+r)r1staterrr+rrrrsetstate s z#StatefulIncrementalDecoder.setstateFcCsd}|D]d}|jdkrD|tdkr6|jrB||7}ql|j|q|j|t|j|jkr||7}q|r|jr||7}|S)Nrr.)r+ordr process_wordr4r)r1inputfinaloutputr rrrdecode s     z!StatefulIncrementalDecoder.decodecCsd}|jdtdkr6tdt|jddp,d|_nv|jdtdkrhtdt|jddp^d|_nD|jd}t||jkr|d|j7}|jr|d|j}|d 7}t|_|S) Nrrr+crDrr-r) rrrintr+rrrr)r1rrrrr s   z'StatefulIncrementalDecoder.process_wordc Cs6|jr2|dkr2td}tjd|jdddd|dSdS)N test_decoderr!)rencoderincrementalencoder streamreader streamwriterincrementaldecoder) codecEnabledrlookup CodecInfor)clsrlatin1rrrlookupTestDecoder s z,StatefulIncrementalDecoder.lookupTestDecoderN)r)F) rrrr2rrrrrrr classmethodrrrrrrs s  rc@seZdZgdZddZdS)StatefulIncrementalDecoderTest))r Fza.b.c.d.)oiabcdTabcd.)s oi...abcd...Tr)si.o6.x.xyz.toolongtofit.Fzx-----.xyz---.toolon.)s i.i2.o6xyzTzxy----.z-----.)si.o3.i6.abcdefghijklmnopTz abc.ghi.mno.)s;i.o29.a.b.cde.o15.abcdefghijabcdefghij.i3.a.b.c.d.ei00k.l.mTza----------------------------.b----------------------------.cde--------------------------.abcdefghijabcde.a.b------------..c.------------.d.e------------.k--------------.l--------------.m--------------.cCs\|jD]$\}}}t}|||||qt}||dd||ddddS)NrrrMrDr) test_casesrrr)r1reofrdrrrr s z+StatefulIncrementalDecoderTest.test_decoderN)rrrrrrrrrr src@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e ejjdddZeje ejjdddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Z d0d1Z!d2d3Z"d4d5Z#d6d7Z$d8d9Z%d:d;Z&dd?Z(d@dAZ)dBdCZ*dDdEZ+dFdGZ,dHdIZ-dJdKZ.dLdMZ/dNdOZ0dPdQZ1dRdSZ2dTdUZ3dVdWZ4dXdYZ5dZd[Z6d\d]Z7d^d_Z8ej9d`daZ:dbdcZ;dddeZdjdkZ?dldmZ@dndoZAdpdqZBdrdsZCdtduZDdvdwZEdxdyZFdzd{ZGd|d}ZHd~dZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSdS)TextIOWrapperTestcCs"d|_dd|_ttjdS)NsAAA BBB CCC DDD EEE sAAA BBB CCC DDD EEE r)testdatar normalizedrrrr8rrrr s zTextIOWrapperTest.setUpcCsttjdSr3rr8rrrr szTextIOWrapperTest.tearDowncCs|d}||d}||}|j|ddd||jd||jd|j|ddd ||jd||jd|d ||jt |j|d d |jt |j|d d dS)Né rr! r#ryFutf-8T)r#line_bufferingé r;rxr) rrrr2rr#rrrrrr1r r rsrrrr s   z"TextIOWrapperTest.test_constructorcCsf|j|j}~|j|j}|tt||ttfd|jd| | | |dddS)Nrrr) rrrrrrrrrPr2rLrr1rsrrrr s z$TextIOWrapperTest.test_uninitializedcCsP|}||}|td|j|ddWdn1sB0YdS)Nzis not a text encodinghexr")rrr LookupErrorr)r1r r rrr*test_non_text_encoding_codecs_are_rejected s zrz4<(%s\.)?TextIOWrapper name='dummy' encoding='utf-8'>r z=<(%s\.)?TextIOWrapper name='dummy' mode='r' encoding='utf-8'>rz><(%s\.)?TextIOWrapper name=b'dummy' mode='r' encoding='utf-8'>) rrrrrrrrrrr)r1r:r rsmodnamerrrr8 s*      zTextIOWrapperTest.test_reprc Csd|}||}t|d|0z t|Wnty@Yn0Wdn1sV0YdSr)rrrrrrr1r:rsrrrrL s   z%TextIOWrapperTest.test_recursive_reprcCsv|}||d}|j|ddd}|d||d|d||d|d ||d dS) Nr TryrXrMzY ZsXY ZzA BsXY ZA B)rrrr6rrrrrrtest_line_bufferingV s    z%TextIOWrapperTest.test_line_bufferingcCs|}||d}|j|ddd}|d||d|jdd||d |d ||d |d ||d |jdd||d |d||d ||jdd||jd|jdd||jdd||jddS)NrrFrzAB CrMT)rsAB CzDEF Gs AB CDEF GHs AB CDEF GHZIJ)rrrr6rr reconfigurerrrrrtest_reconfigure_line_bufferinga s,          z1TextIOWrapperTest.test_reconfigure_line_bufferingzutf-8 mode is enabledc Csttj}z`dD]}|tjvrtj|=qtd}|}||}||j|Wtj tj |ntj tj |0dS)N)LC_ALLLANGLC_CTYPEF) dictrenvironlocalegetpreferredencodingrrrr#clearupdate)r1Z old_environkeyZcurrent_locale_encodingr rsrrrtest_default_encoding| s       z'TextIOWrapperTest.test_default_encodingcsPddl|}fdd|_|t|j|fdd|_|t|j|dS)Nrcs jdSrj)ZINT_MAXr _testcapirrrI rMz8TextIOWrapperTest.test_device_encoding..cs jdSrj)ZUINT_MAXrrrrrI rM)rrr<rrrr5rrrtest_device_encoding s z&TextIOWrapperTest.test_device_encodingcCsJ|}|j|dd}||jd||}||jt|jdS)Nrr")rrrr#assertIsNotNonerrr1r rsrrr test_encoding s   zTextIOWrapperTest.test_encodingcCs|d}|j|dd}|t|j|d}|j|ddd}|t|j|d}|j|ddd}||d|d}|j|ddd}||d dS) Nsabc rr"rr#rrzabc replaceuabc � )rrr UnicodeErrorrPrrrrrtest_encoding_errors_reading s    z.TextIOWrapperTest.test_encoding_errors_readingcCs|}|j|dd}|t|jd|}|j|ddd}|t|jd|}|j|dddd}|d |||d |}|j|dd dd}|d |||d dS) Nrr"ÿrrrr)r#rryu abcÿdef sabcdef rsabc?def )rrrrr6rfrrrrrrtest_encoding_errors_writing s(    z.TextIOWrapperTest.test_encoding_errors_writingc Cs(gd}dgdgd|gdgdgdddggd gd gg}d }|D]}td||}d D]}td dD]}|D]\}} ||||} |j| ||d} |rg} | d} | dkrq|t | d| | | qnt | } t | | D]\}}|||q|t | t | qtqlq^qBdS)N)unix windows zos9 last nonl)rzwindows zos9 r!r"rr)rr z os9 last r"rzunix windows z os9 last nonl )z unix windows z os9 z last nonl)rr!utf-16 utf-16-le utf-16-beutf-32 utf-32-le utf-32-be)FTrDrryr#rV)rrrr.rrrrPrrr4rr,zip)r1Z input_linesr encodingsr#rZdo_readsrryZ exp_linesrtextioZ got_linesc2Zgot_lineZexp_linerrr test_newlines s8      zTextIOWrapperTest.test_newlinescCsd}|dddd}d|djddfd|djddfd gd fd gd fd gdffD]R\}}||}|j|d|d}||||d||d |qbdS)NsAAA BBB CCC DDD EEE FFF GGGs r rT)keependsrr)zAAA zBBB z CCC DDD EEE FFF GGGr)zAAA BBB CCC DDD EEE r2r3r#)z AAA BBB CCC zDDD zEEE z FFF z GGGrr) rr splitlinesrrrrrArPr)r1rrryrrFtxtrrrtest_newlines_input s     z%TextIOWrapperTest.test_newlines_inputcCsddddd}d|tjfgt|}|D]d\}}|}|j|d|d}|d|d|d |||j d || |q.dS) NsAAA BBB CCC X Y ZsAAA BBB CCC X Y ZsAAA BBB CCC X Y Z)rrr#rrrzAAA BzBB CCC zX Y ZF) rlinesepsorteditemsrrr6rfrrlr)r1ZtestdictrryrrFr5rrrtest_newlines_output s    z&TextIOWrapperTest.test_newlines_outputcsZg|jGfddd}|}|j|dd}|d~t|dgdS)NcseZdZfddZdS)z4TextIOWrapperTest.test_destructor..MyBytesIOcs||dSr3)r4rrnr8r#r(rrrn sz:TextIOWrapperTest.test_destructor..MyBytesIO.closeNrrr;rr MyBytesIO sr<rr"rcrS)rrr6rrr)r1r<r rsrr;rr s z!TextIOWrapperTest.test_destructorcsLgGfddd|j}|}||dd}~t|gddS)Ncs:eZdZfddZfddZfddZZS)z.MyTextIOcs4dz tj}Wnty(Yn0|dSrjrrrrrr* s    zDTextIOWrapperTest.test_override_destructor..MyTextIO.__del__csdtdSrUrr8rrrrn2 s zBTextIOWrapperTest.test_override_destructor..MyTextIO.closecsdtdSrrr8rrrrf5 s zBTextIOWrapperTest.test_override_destructor..MyTextIO.flushrrrrXrMyTextIO) sr=rr"r)rrrrr)r1r=r rsrrrr' s z*TextIOWrapperTest.test_override_destructorc Cs|}tr}|t||jWdn1s>0YtsZ||j n|j durt| |j j t Wdn1s0YdSr3) rirrrrrrrr>rrrrmrrrrr> s  * z/TextIOWrapperTest.test_error_through_destructorcCsdD]}dD]t}|jtjd|d}||_||dd||jtjd|d}||_||d||d|}|| dd||dd| d||d d ||d d ||d d ||d ||||| dd|| dd |||dd|| ||||d| dr|| |||qqdS)N)rDrVrrr[rIr !?@A)rr!rw+r"rcrr+rrVr rDr*rdefutf) r$rrr&rr6rnrBrPrArmulti_line_test)r1 chunksizeencr(cookierrr test_basic_ioM s6     zTextIOWrapperTest.test_basic_ioc Cs|d|d}g}dD]V}g}t|D]}|||t|q.d|d}|||f||q|dg} |} |}|sq| | |fq| | |dS)Nru sÿ࿿￿)rrDrVrrr[r?r@rA>rBrCrDrrr) rArIr.r4rrrBr6rr) r1r(rKsampleZwlinesr}charsr+lineZrlinesrrrrrIj s&    z!TextIOWrapperTest.multi_line_testcCs|jtjddd}|}|d|}|d|}|d|||||d|||||d||||d|D]}||d|t |jq|||| dS)NrErr"uÿ r) r$rrrBr6rArrrrmrn)r1r(p0p1Zp2rRrrr test_telling s$     zTextIOWrapperTest.test_tellingc Cst}|d}d|}t|d}|t|t|d}t|d}||}|tjd}||dWdn1s0Y|jtjdddL}| |} || t |d|| ||| |Wdn1s0YdS) NrVr r袈 rr r"r) r)rrrrr$rrr6rPrjrBr) r1 chunk_sizeZ prefix_sizeZu_prefixprefixZu_suffixsuffixrRr(rrrr test_seeking s, zTextIOWrapperTest.test_seekingcCsd}|tjd}||Wdn1s20Y|jtjddd,}|jd|_||Wdn1s0YdS)Ns࿿ rr rr"rV)r$rrr6r&rrB)r1rr(rrrtest_seeking_too s(z"TextIOWrapperTest.test_seeking_toocsddfdd }dt_zdtjD]\}}}||q"tjD]8\}}}t|d}d|}|d}||||q.test_seek_and_tell_with_datarDrV.)r)rrrrr)r1r_r_offsetrXr]rr^rr s z$TextIOWrapperTest.test_seek_and_tellcCs|jtjddd}|d||jtjddd}||d|}||d|}||||d||||dS)Nreuc_jpr"u AB うえ r zAB uうえ ) r$rrr6rnrrrBrA)r1r(rSrTrrrtest_multibyte_seek_and_tell s  z.TextIOWrapperTest.test_multibyte_seek_and_tellcCsx|jtjddd}|d|}|d|||d||jtjddd}||d|dS) Nr euc_jis_2004r"uæ̀æùr uæ̀̀) r$rrr6rBrArnrr)r1r(rSrrrtest_seek_with_encoder_state s    z.TextIOWrapperTest.test_seek_with_encoder_statecCsd}d}|D]}|}|j||d}|||||d|||d|d|||d|||d|q dS)NZ 1234567890)r$r%r&r'r(r)r"rrV)rrr6rArrPrr)r1rrr#rFr(rrrtest_encoded_writes s    z%TextIOWrapperTest.test_encoded_writescCs0Gddd|j}||}|t|jdS)Nc@seZdZddZdS)z5TextIOWrapperTest.test_unreadable..UnReadablecSsdSrxrr8rrrr= sz>TextIOWrapperTest.test_unreadable..UnReadable.readableNr{rrrr UnReadable sri)rrrrmrP)r1rir5rrrtest_unreadable s z!TextIOWrapperTest.test_unreadablecCs>||d}d}|d}|s$q.||7}q||ddS)NsAA BBrrDzAA BBrrrPrr1r5readsr*rrrtest_read_one_by_one s  z&TextIOWrapperTest.test_read_one_by_onecCsh||d}||gd|d||dgd|d||dddgdS)NsAA BB CC)AA BB ZCCrr[rorp)rrrrrAr1r5rrrr s   z TextIOWrapperTest.test_readlinescCs>||d}d}|d}|s$q.||7}q||ddS)NsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Brr\zAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Brkrlrrrtest_read_by_chunk) s  z$TextIOWrapperTest.test_read_by_chunkcCs@gd}|}||}|||||ddSN)r ZcdZefrD)rrrrfrrr1r(rFr5rrrra4 s   z!TextIOWrapperTest.test_writelinescCsDtgd}|}||}|||||ddSrs)rrrrrfrrrtrrrrb< s    z*TextIOWrapperTest.test_writelines_userlistcCsF||}|t|jgd|t|jd|t|jddS)NrrS)rrrrrrqrrrrdD sz'TextIOWrapperTest.test_writelines_errorcCsF|j||jdd}d}|d}|s*q4||7}q|||jdS)Nrr"rrD)rrrrPrrrlrrrtest_issue1395_1J s  z"TextIOWrapperTest.test_issue1395_1cCsL|j||jdd}d|_d}|d}|s0q:||7}q |||jdS)Nrr"rrrrrr&rPrrrlrrrtest_issue1395_2V s  z"TextIOWrapperTest.test_issue1395_2cCsj|j||jdd}d|_|d}||d7}||7}||7}||7}|||jdSNrr"r)rrrr&rPrrrr1r5rmrrrtest_issue1395_3b s    z"TextIOWrapperTest.test_issue1395_3cCsD|j||jdd}d|_|d}||7}|||jdSrxrvryrrrtest_issue1395_4m s   z"TextIOWrapperTest.test_issue1395_4cCsX|j||jdd}d|_|d}|}|d||||dddS)Nrr"rrzBBB )rrrr&rPrBrAr)r1r5rmrrrrtest_issue1395_5u s   z"TextIOWrapperTest.test_issue1395_5cCs2||j}|j|dd}|||dSNrr")rrrrr>)r1rr5rrrtest_issue2282 s z TextIOWrapperTest.test_issue2282c Cstj}dD]}|j|d|d"}|d|}Wdn1sH0Y||d&}||d|Wdn1s0Y|j|d|d}|dWdn1s0Y||d&}||d|Wdq 1s0Yq dS) N utf-8-sigr$r'rr"aaarr xxxaaaxxx)rrr$r6rBrrPrr1filenamecharsetr(rrrrtest_append_bom s  &4(z!TextIOWrapperTest.test_append_bomc Cstj}dD]}|j|d|d"}|d|}Wdn1sF0Y|j|d|d8}|||d|d|dWdn1s0Y||d &}||d |Wdq 1s0Yq dS) Nrrr"rrFZzzzrbbbrZbbbzzz) rrr$r6rBrArrPrrrrr test_seek_bom s &   (zTextIOWrapperTest.test_seek_bomc Cstj}dD]}|j|d|d}|dWdn1s>0Y|j|d|d2}|d|d|j|dWdn1s0Y||d&}||d |Wdq 1s0Yq dS) Nrrr"rr rrrr) rrr$r6rArrrPr)r1rrr(rrrtest_seek_append_bom s( (z&TextIOWrapperTest.test_seek_append_bomcCs|tjd}||jdWdn1s20Y|jtjddd}||jdWdn1sr0YdS)Nrrrr)r$rrrrrrrrtest_errors_property s,z&TextIOWrapperTest.test_errors_propertyc st|jtjdddlfddfddtdD}t|jt d Wdn1sn0YWdn1s0Y|tj< }tdD]}| | d |dqWdn1s0YdS) NrrDrcsd|}|dS)N Thread%03d )rrr6)rGtext)eventr(rrrun sz1TextIOWrapperTest.test_threads_write..runcsg|]}tj|fdqS)rrr)rrrr  sz8TextIOWrapperTest.test_threads_write..rr!r) r`rar$rrr.r&rcrdrerPrr)r1r)ZcontentrGr)rr(rrtest_threads_write s F z$TextIOWrapperTest.test_threads_writecs|j||jddgfdd}|_|tj|j|j j|| d| ddd_dS) Nrr"cs jjjgdd<tdSr3)rlrrmrrlr5rrrH sz>TextIOWrapperTest.test_flush_error_on_close..bad_flushrrDcSsdSr3rrrrrrI rMz=TextIOWrapperTest.test_flush_error_on_close..) rrrrfrrmrnrJrlrrKrrrrrQ s  z+TextIOWrapperTest.test_flush_error_on_closecCs||j}dd}dd}||_|j|dd}||_|t}|Wdn1s^0Y||jj d| |jj t||jj j d| |j d d |_d d |_dS) NcSs tddSrrrrrrrH sz>TextIOWrapperTest.test_close_error_on_close..bad_flushcSs tddSrrrrrrr sz>TextIOWrapperTest.test_close_error_on_close..bad_closerr"rrcSsdSr3rrrrrrI rMz=TextIOWrapperTest.test_close_error_on_close..cSsdSr3rrrrrrI rM)rrrnrrfrrmrrkr}rrrKrlr1rrHrr5rrrrr s  &  z+TextIOWrapperTest.test_close_error_on_closecCs||j}dd}dd}||_|j|dd}||_|t}|Wdn1s^0Y|dt|j | |j j t|dt|j j | |j d d |_d d |_dS) NcSstdSr3rrrrrrH szLTextIOWrapperTest.test_nonnormalized_close_error_on_close..bad_flushcSstdSr3rrrrrr szLTextIOWrapperTest.test_nonnormalized_close_error_on_close..bad_closerr"rrcSsdSr3rrrrrrI rMzKTextIOWrapperTest.test_nonnormalized_close_error_on_close..cSsdSr3rrrrrrI rM)rrrnrrfrrrrjrkrrrKrlrrrrr s  &  z9TextIOWrapperTest.test_nonnormalized_close_error_on_closecCs@|j||jdd}||||t|jdSr})rrrrnrrrfrqrrrrR s z"TextIOWrapperTest.test_multi_closecCs8|||j}||j|j||j|jddSr+)rrwrrr{rBrArqrrrr sz!TextIOWrapperTest.test_unseekablecCsV|j||jdd}||j}|t||_Wdn1sH0YdSr})rrrrrr)r1r5rFrrrr s  z*TextIOWrapperTest.test_readonly_attributescCsX|gd}|j|ddd}||dd||d|t|dd gdS) NrSrBs ghi jkl opq rrrrZabcdzefghi zjkl zopq )rLrrrPrr,r1r:r5rrr test_rawio s zTextIOWrapperTest.test_rawiocCsV|gd}|j|dddd}|d|d|d|d |jd dS) NrrrT)r#ryr1z23 45rMs123 45)rLrr6rrr.rrrrtest_rawio_write_through s    z*TextIOWrapperTest.test_rawio_write_throughcsggGfddd|j}|}d}||t|d}|j|ddd}|d}|||||| dg||d ||| |d dS) Ncs,eZdZfddZfddZZS)zBTextIOWrapperTest.test_bufio_write_through..BufferedWritercsdtj|i|Sr7rr1r}rL)rY flush_calledrrrf. s zHTextIOWrapperTest.test_bufio_write_through..BufferedWriter.flushcsdtj|i|Sr7)r4rWr6r)rY write_calledrrr61 s zHTextIOWrapperTest.test_bufio_write_through..BufferedWriter.write)rrrrfr6r\rrrrXrr- srrrVrT)r#rrMrr) rrrrrr6rKrJrr)r1rr[rrr-rrrrtest_bufio_write_through) s"      z*TextIOWrapperTest.test_bufio_write_throughcCs|g}|j|ddd}|d|jdd||jd|d|jd|d |d|jd |jd d||jd |d ||d|jd ||jdd||jd |jdd||jdd||jddS)NrrrrT)rrMrZ23rFZ45r{) rLrr6rrrrr.rfrrrrtest_reconfigure_write_throughI s(         z0TextIOWrapperTest.test_reconfigure_write_throughcCs`||d}|t|jd||d}|t|j||d}|t|jdS)Nr rD)rrrrrPrrrrrtest_read_nonbytes` s z$TextIOWrapperTest.test_read_nonbytescCs`td}t|dd$tjtddd}Wdn1sB0Y|t|j ddS)Nrot13_is_text_encodingTfoor"Zbar) rrrrrrrrrr6)r1rrsrrrtest_illegal_encoderj s 2z&TextIOWrapperTest.test_illegal_encodercsfdd}t|jd}t|j}t|jfdd}|d}t|jd|d}t|jd|d}t|jddS) Ncs>td}d|_z jdddd}Wd|_nd|_0|S)NquopriTsaaaaaarr*F)rrrrr)rrsr8rr_make_illegal_wrapperu s  zETextIOWrapperTest.test_illegal_decoder.._make_illegal_wrapperrDcs`Gfdddfdd}td}t|d|WdS1sR0YdS)NcseZdZfddZdS)z^TextIOWrapperTest.test_illegal_decoder.._make_very_illegal_wrapper..BadDecodercsSr3rr8getstate_ret_valrrr szgTextIOWrapperTest.test_illegal_decoder.._make_very_illegal_wrapper..BadDecoder.getstateN)rrrrrrrr BadDecoder srcsSr3r)r)rrr_get_bad_decoder szdTextIOWrapperTest.test_illegal_decoder.._make_very_illegal_wrapper.._get_bad_decoderrr)rrrr)rrr)r)rrr_make_very_illegal_wrapper s  zJTextIOWrapperTest.test_illegal_decoder.._make_very_illegal_wrapperr;r)rDrV)rrrPr)r1rsrr)rr1rtest_illegal_decoderr s  z&TextIOWrapperTest.test_illegal_decodercKs |jj}dj||d}td|S)Naif 1: import codecs import {iomod} as io # Avoid looking up codecs at shutdown codecs.lookup('utf-8') class C: def __init__(self): self.buf = io.BytesIO() def __del__(self): io.TextIOWrapper(self.buf, **{kwargs}) print("ok") c = C() )iomodrL-c)rrrDr)r1rLrcoderrr_check_create_at_shutdown s z+TextIOWrapperTest._check_create_at_shutdowncCs>|\}}}|r&||j|n|d|dS)Nok)rrshutdown_errorrrstripr1rcoutrrrr(test_create_at_shutdown_without_encoding sz:TextIOWrapperTest.test_create_at_shutdown_without_encodingcCs6|jddd\}}}|||d|dS)Nrrrr)rrKrrrrrrr%test_create_at_shutdown_with_encoding s   z7TextIOWrapperTest.test_create_at_shutdown_with_encodingcCs@td}||d}t|}||d|ddS)NsJust some random string rrh)MemviewBytesIOr_to_memoryviewrr/rrPr)r1r rsZ bytes_valrrrtest_read_byteslike s z%TextIOWrapperTest.test_read_byteslikec CsdGdddt}tdD],}z|j|ddWqtyBYq0qdd|_|j|dd}dS)Nc@s$eZdZddZddZddZdS)z,TextIOWrapperTest.test_issue22849..FcSsdSr7rr8rrrr= rMz5TextIOWrapperTest.test_issue22849..F.readablecSsdSr7rr8rrrr9 rMz5TextIOWrapperTest.test_issue22849..F.writablecSsdSr7rr8rrrr> rMz5TextIOWrapperTest.test_issue22849..F.seekableN)rrrr=r9r>rrrrF srrrr"cSsdSr+rrrrrrI rMz3TextIOWrapperTest.test_issue22849..)objectr.rrrB)r1rr+rsrrrtest_issue22849 s   z!TextIOWrapperTest.test_issue22849cCsdddd}||}|j|ddd}||d||j|jddWdn1sl0Y||j|jdd Wdn1s0YdS) Nabcé rdéf utf8rrrr"rx)rrrrrrr{r)r1rr:r5rrrtest_reconfigure_encoding_read s *z0TextIOWrapperTest.test_reconfigure_encoding_readcCsT|}|j|ddd}|d|jdd|d|||ddS) Nrrrzfoo rr"rsfoo é )rrr6rrfrrrrrr test_reconfigure_write_fromascii s   z2TextIOWrapperTest.test_reconfigure_write_fromasciicCs|}|j|ddd}|d|jdd||d|d|||d |}|j|d dd}|d |jd d|d|||d dS)Nrrrrrr"sabc rs abc déf rabc rs abc déf )rrr6rrrrfrrrrtest_reconfigure_write s      z(TextIOWrapperTest.test_reconfigure_writecCsd|}dd|_d|_|j|ddd}|d|jdd|d |||d dS) NcSsdSrxrrrrrrIrMzGTextIOWrapperTest.test_reconfigure_write_non_seekable..rrrrrr"rs abc déf ) rr>rArr6rrfrrrrrr#test_reconfigure_write_non_seekables    z5TextIOWrapperTest.test_reconfigure_write_non_seekablecCs||ddd}|jdd||jd||jd|d|jdd||jd||jd|jdd ||jd||jd|d |jd dd ||jd |d||d|| ddS)Nrrrr"LF rrxrrCRLF rrrrzLF CRLF s LF CRLF ) rrrrr#rr6rArPrrrqrrrtest_reconfigure_defaultss"      z+TextIOWrapperTest.test_reconfigure_defaultscCs|d}|j|ddd}|jdd||d|d}|j|ddd}|jdd||d|d}|j|dd d}|jdd||d |d }|j|ddd}|jd d||d |d }|j|dd d}|jdd||d|j|dd d}|jdd|d|jdd|d|jdd|d|jd d|d|jdd|ddtjd}|| d|dS)NsCR EOFrrrxzCR rzCR s CR LF EOFr#zCR LF s LF CR EOFzLF CR s CR CRLF EOFrz CR CRLF zlinesep rrr7zLF LF CR CRLF ) rrrrrr6rr7rrr)r1r:r5rrrrtest_reconfigure_newline)sB                    z*TextIOWrapperTest.test_reconfigure_newlinecCsb|j|ddd}|d|||j|ddd}|d|d|dS)Nstestrr"rDr)rrrPrBr6rrrrtest_issue25862Ms   z!TextIOWrapperTest.test_issue25862N)TrrrrrrrrrrrrrunittestskipIfrr` utf8_moderrrrrrrr/r6r:rrrrMrIrUrZr[rrdrgrhrjrnrrrrarbrdrurwrzr{r|r~rrrr no_tracingrrQrrrRrrrrrrrrrrrrrrrrrrrrrrrrrr s       * /              (     $rcs(eZdZfddZfddZZS)rcstt|Sr3)rrWr~r1Zlen_rXrrr~]szMemviewBytesIO.read1cstt|Sr3)rrWrPrrXrrrP`szMemviewBytesIO.read)rrrr~rPr\rrrXrrYs rcCs:td}t|t||j}||d|t|S)Nr+)r ritemsize frombytesr)rFZarridxrrrrcs rc@s<eZdZeZdZddZddZddZdd Zd d Z d S) CTextIOWrapperTest$LookupError: unknown encoding: asciicCsb|d}||d}||}|jt|j|dd|t|j|j|j}|tt |dS)Nrrrrx) rrrrrr2rPrrrrrrrr9ps   z&CTextIOWrapperTest.test_initializationcCstdtfZttjd}||}|j|dd}|d||_ t |}~t Wdn1sn0Y| |||tjd }||dWdn1s0YdS)Nrrrr"Z456defrs456def)rrrrrrrrr6rr<r=rr>r$rrP)r1r[r rsr?r(rrrr@zs   &z*CTextIOWrapperTest.test_garbage_collectioncCsjtdD]T}|||}|j|dd}|||}|j|dd}||_||_qtdS)Nrrr")r.rrLrZbuddyrr)r1r+b1t1b2t2rrr!test_rwpair_cleared_before_textios z4CTextIOWrapperTest.test_rwpair_cleared_before_textiocCsD|j|dd}|t|`Wdn1s60YdSr})rrrrr&rrrr test_del__CHUNK_SIZE_SystemErrors z3CTextIOWrapperTest.test_del__CHUNK_SIZE_SystemErrorcsdGfddd|j}|}|j|dd}|j|d|d|g|j|t"|dd Wdn1s0Y|d g|j|d |d|d d d g|jdS)NrcseZdZfddZZS)z.MockIOcst|krtt|Sr3)rrrWr6rs)rYrWrrr6s zBCTextIOWrapperTest.test_internal_buffer_size..MockIO.write)rrrr6r\rrWrXrMockIOsrrr"rcrGrrDrDZghir@r)rLrr&r6rr.rr)r1rrFrsrrrtest_internal_buffer_sizes   0 z,CTextIOWrapperTest.test_internal_buffer_sizeN) rrrrrr9r@rrrrrrrrls rc@seZdZeZdZdS)PyTextIOWrapperTestrN)rrrrrrrrrrrsrc@s4eZdZddZddZddZddZd d Zd S) IncrementalNewlineDecoderTestcsfdd}|dd|dd|dd|dd|dd|dd|dd|ddjtjd d d |d d |dd|d d d d |dd d d |dd|dd|dd|dd|dd |dd|dd|dd|d d |dd|d d dS)NcsJ}j|fi|||j|fi||dSr3)rrrr)r rrLrdecoderr1rr _check_decodes zPIncrementalNewlineDecoderTest.check_newline_decoding_utf8.._check_decodes袈u袈rrMT)rrrr0rz a z s as袈 rVs袈 )rUnicodeDecodeErrorrr)r1rrrrrcheck_newline_decoding_utf8s4                    z9IncrementalNewlineDecoderTest.check_newline_decoding_utf8csg|dur*t|fdd}ndfdd}|jd|d|jd|d|jd|d|jd|d |jd |d|d d d }dur|}||d |jddS) Ncs*|D]}t|gq dSr3)rr4rr)rr rencoderrrr_decode_bytewiseszNIncrementalNewlineDecoderTest.check_newline_decoding.._decode_bytewisecs|D]}|qdSr3)r4r)rr*)rrrrrszabc rz abc)rrzabc rc)r#rrrzabc abcabc abcabc)rgetincrementalencoderrnewlinesrrrr)r1rr#rrrrrcheck_newline_decodings0  z4IncrementalNewlineDecoderTest.check_newline_decodingcCspd}|D].}|ot|}|j|dd}|||qtd}|j|dd}|||t|jddS)N) Nrr!r$r%r&r'r(r)T translaterr;)rgetincrementaldecoderIncrementalNewlineDecoderrrrrr)r1r,rKrrrrtest_newline_decoder s  z2IncrementalNewlineDecoderTest.test_newline_decodercs<fdd}jddd}||jddd}||dS)NcsR|jd|dd|jd|dd|jddS)Nuഀu਀)rrr)decr8rr_checks z@IncrementalNewlineDecoderTest.test_newline_bytes.._checkFrT)r)r1rrrr8rtest_newline_bytess  z0IncrementalNewlineDecoderTest.test_newline_bytescCs\dD]&}td}|||}||qtd}|j|dd}||dddS)N)rorrDrVrrrrz )rrrrrr)r1rrrrrtest_translate*s    z,IncrementalNewlineDecoderTest.test_translateN)rrrrrrrrrrrrrs *! rc@s eZdZdS)CIncrementalNewlineDecoderTestNrrrrrr4src@s eZdZdS)PyIncrementalNewlineDecoderTestNrrrrrr7src@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zeeed#d$d%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/S)0 MiscIOTestcCsttjdSr3rr8rrrr?szMiscIOTest.tearDowncCs||jjD]n}t|j|d}||||dvr2qqd|vsF|dkrZ|t|t|q|ds|t||j qdS)N)r$ open_codeerrorr{ZSEEK_) r__all__rrlowerrJ issubclassrrr)r1rrrrr test___all__Bs   zMiscIOTest.test___all__cCs||jtjddd}||jd|tdtf|tjd}Wdn1sZ0Y||jtj||j jtj||j j jtj||jd||j jd||j j jd||tjd}||jd||j jd||j j jd|j| dd d }||jd||j jd||j| ||j j| ||dS) NrrrrUrrErFr1) r$rrrrrnrrrrr:r<)r1r(grrrtest_attributesMs.,zMiscIOTest.test_attributescCsNt\}}|tj|||d}||jtjdkrJ||dS)Nr win32) rrrrnr$rrrKr>)r1r rr(rrrtest_open_pipe_with_appendis     z%MiscIOTest.test_open_pipe_with_appendcCsddiddidddddddddddidd iddddddd dddd idd id ddd ddd ddfD]}|jtjfi|}||t|j|t|j|t|j|t|j t |d r|t|j d|t|j t |d r|t|j d|t|j t |dr6|t|jt |drV|t|jtdt |drv|t|jtd|t|j|t|j|t|jd|t|jd|t|j|t|j|t|jd|dvrdnd|t|jg|tt|qpdS)NrrrrDrrrVrr rrErrr~rrrHrr rMr)r$rrrnrrrfr<r__iter__r^rrPr~rrHrrrrrArBrIr6rr)r1rLr(rrrtest_io_after_closetsZ       zMiscIOTest.test_io_after_closecCsXGdddt}|d}|d|}||_||_t|}~~t|||dS)Nc@s eZdZdS)z*MiscIOTest.test_blockingioerror..CNrrrrrCsr rrD) rjrr r*r<r=rrr>)r1r r*r r?rrrtest_blockingioerrors  zMiscIOTest.test_blockingioerrorcCsD||jtj||jtj||jtj||jtjdSr3)rrrcABCMetarrrr8rrr test_abcsszMiscIOTest.test_abcscCs<|jtjdddH}|||j|||j|||j|||jWdn1s`0Y|tjdH}|||j|||j|||j|||jWdn1s0Y|tjdH}|||j|||j|||j|||jWdn1s.0YdSNrrrr) r$rrrrrZassertNotIsInstancerr)r1Z abcmoduler(rrr_check_abc_inheritances,,z!MiscIOTest._check_abc_inheritancecCs||dSr3)rr8rrrtest_abc_inheritanceszMiscIOTest.test_abc_inheritancecCs|tdSr3)rrr8rrrtest_abc_inheritance_officialsz(MiscIOTest.test_abc_inheritance_officialcOsht|i|}t|}|t}d}tWdn1sB0Y||t|jj ddSr+) r$rZ assertWarnsrrrrrjwarningr})r1r}rLr(r rmrrr_check_warn_on_deallocs  &z!MiscIOTest._check_warn_on_dealloccCs2|jtjddd|tjd|tjddSr)rrrr8rrrtest_warn_on_deallocszMiscIOTest.test_warn_on_dealloccsgfdd}||t\}}||f7|j|g|Ri|t\}}||f7t|*t|g|Rddi|Wdn1s0YdS)Nc sPD]F}zt|WqtyH}z|jtjkr4WYd}~qd}~00qdSr3)rrnrmerrnoEBADF)rPrfdsrr cleanup_fdss  z9MiscIOTest._check_warn_on_dealloc_fd..cleanup_fdsr2F)rrrrrrur$)r1r}rLrr rrrr_check_warn_on_dealloc_fds       z$MiscIOTest._check_warn_on_dealloc_fdcCs&|jddd|d|ddS)Nrrrr )rr8rrrtest_warn_on_dealloc_fds z"MiscIOTest.test_warn_on_dealloc_fdc Csddiddidddddiddidddddidd id ddf D]^}ttjd D]J}|jtjfi|"}|ttj||WdqR1s0YqRq@dS) Nrrrrrr rrErrD) r.pickleHIGHEST_PROTOCOLr$rrrrdumps)r1rLprotocolr(rrr test_picklings zMiscIOTest.test_picklingcCs|ddS)Ni@_test_nonblock_pipe_writer8rrrtest_nonblock_pipe_write_bigbufsz*MiscIOTest.test_nonblock_pipe_write_bigbufcCs|ddS)Nrr"r8rrr!test_nonblock_pipe_write_smallbuf sz,MiscIOTest.test_nonblock_pipe_write_smallbuf set_blockingz(os.set_blocking() required for this testc CsFg}g}t\}}t|dt|d|j|dd|d}|j|dd|d}||xdD]}z.BadReaderrcSsddS)Nri@BrrOrrrrPszACMiscIOTest.test_readinto_buffer_overflow..BadReader.readN)rrQrrrr BadReadersr9rV)rrrrrrH)r1r9rr rrrtest_readinto_buffer_overflowsz)CMiscIOTest.test_readinto_buffer_overflowcCs\dt}td|\}}|j}|jdkrHdt}|||n||ddS)Naif 1: import sys import time import threading from test.support import SuppressCrashReport file = sys.{stream_name} def run(): while True: file.write('.') file.flush() crash = SuppressCrashReport() crash.__enter__() # don't call __exit__(): the crash occurs at Python shutdown thread = threading.Thread(target=run) thread.daemon = True thread.start() time.sleep(0.5) file.write('!') file.flush() rrzFatal Python error: _enter_buffered_busy: could not acquire lock for <(_io\.)?BufferedWriter name='<{stream_name}>'> at interpreter shutdown, possibly due to daemon threadsz.!) format_maplocalsr rrrrrKr)r1Z stream_namerrtrarpatternrrr&check_daemon_threads_shutdown_deadlocks  z2CMiscIOTest.check_daemon_threads_shutdown_deadlockcCs|ddS)Nstdoutr>r8rrr,test_daemon_threads_shutdown_stdout_deadlocksz8CMiscIOTest.test_daemon_threads_shutdown_stdout_deadlockcCs|ddS)Nstderrr@r8rrr,test_daemon_threads_shutdown_stderr_deadlocksz8CMiscIOTest.test_daemon_threads_shutdown_stderr_deadlockN)rrrrr:r>rArCrrrrr8s  )r8c@seZdZeZdS) PyMiscIOTestN)rrrrrrrrrrDsrDntz%POSIX signals required for this test.c@seZdZddZddZddZddZd d Zd d Zd dZ e j ddZ ddZ ddZddZddZddZddZddZdd Zd!S)" SignalsTestcCsttj|j|_dSr3)signalSIGALRMalarm_interruptoldalrmr8rrrrszSignalsTest.setUpcCsttj|jdSr3)rGrHrJr8rrrrszSignalsTest.tearDowncCs dddSrCr)r1sigframerrrrIszSignalsTest.alarm_interruptc  stgfdd}tj|d}d|_t\}d|d<|tjt|d}z(|j j |fi|}t t drt t jt jg|t t jt jgn|t dz&|t|j|Wt d |nt d |0td||d d|dd gWt|tz |Wn6ty~} z| jtjkrjWYd} ~ n d} ~ 00nZt|tz |Wn6ty} z| jtjkrĂWYd} ~ n d} ~ 000dS) Ncstd}|dSrj)rrPr4)rr read_resultsrrrs z2SignalsTest.check_interrupted_write.._readrTFr2rDpthread_sigmaskrrV)rrr`rdaemonrr PIPE_MAX_SIZErrr$r^rGrO SIG_BLOCKrHr SIG_UNBLOCKalarmrrr6rr4rPrrnrmrr) r1itemr fdopen_kwargsrrsr large_datawiorrrMrcheck_interrupted_writesL       "      z#SignalsTest.check_interrupted_writecCs|jddddddS)NrrrrrYr8rrr!test_interrupted_write_unbufferedsz-SignalsTest.test_interrupted_write_unbufferedcCs|jdddddSNrrrrZr8rrrtest_interrupted_write_bufferedsz+SignalsTest.test_interrupted_write_bufferedcCs|jddddddS)Nxyrrrrr#rZr8rrrtest_interrupted_write_text sz'SignalsTest.test_interrupted_write_textc sfdd}ttj|t\}}|jj|fi|ztd|tt fF}t dD]}  q`t |tdqXWdn1s0Y|j}t|t r|t|dt|Wtdt|ntdt|0dS)NcsdddSrC)r6)r}rrXrron_alarm%s z3SignalsTest.check_reentrant_write..on_alarmrDrzreentrant callr)rGrHrrrr$rTrrrr.r6rfrPrrkrrJrjrrn) r1rrVrcr rrmr+rrrbrcheck_reentrant_write#s(     4   z!SignalsTest.check_reentrant_writecCs|jddddSr\rdr8rrrtest_reentrant_write_buffered?sz)SignalsTest.test_reentrant_write_bufferedcCs|jdddddS)Nr_rrr`rer8rrrtest_reentrant_write_textBsz%SignalsTest.test_reentrant_write_textc st\}d|d<fdd}ttj|zj|jj|fi|}tdtd||| ddWtd | t t |n(td | t t |0dS) NFr2cstddS)Nsbar)rr6rKrLrrr alarm_handlerKsz?SignalsTest.check_interrupted_read_retry..alarm_handlerrrDrZfoobarr) rrrGrHrr$r6rTrrPrn)r1rrVr rjZriorrircheck_interrupted_read_retryEs"        z(SignalsTest.check_interrupted_read_retrycCs|jdddddS)NcSs |dS)Nr)rrrrrrI^rMzBSignalsTest.test_interrupted_read_retry_buffered..rr]rkr8rrr$test_interrupted_read_retry_buffered]s z0SignalsTest.test_interrupted_read_retry_bufferedcCs|jdddddS)NcSs|Sr3rrrrrrIbrMz>SignalsTest.test_interrupted_read_retry_text..r r]rlr8rrr test_interrupted_read_retry_textas z,SignalsTest.test_interrupted_read_retry_textc  stdtj}t\}d|d<gddfdd}tj|dd_fdd }fd d ||}ttj |z|j j |fi|}t d | |} ||| |d|||td dDWt ddt|tz |Wn6tyX} z| jtjkrDWYd} ~ n d} ~ 00nht ddt|tz |Wn6ty} z| jtjkrWYd} ~ n d} ~ 000dS)NselectFr2c sjz<s:gggddvrtd}|qqWn(tyd}z|WYd}~n d}~00dS)Ng?rr)rorrPr4 BaseException)rr)rr rNrowrite_finishedrrrws z8SignalsTest.check_interrupted_write_retry.._readrTcsttjtddSrj)rGrHrTrh)alarm2rralarm1sz9SignalsTest.check_interrupted_write_retry..alarm1cs dSr3)rrh)rsrrrrsz9SignalsTest.check_interrupted_write_retry..alarm2rDcss|]}t|VqdSr3)rrrrr rMz.r)r import_modulerQrrr`rrPrGrHrr$rTr6rrfrr>sumrnrmrr) r1rUrVr'rrrsrWrXrXrr)rrrr rNrorsrqrcheck_interrupted_write_retryesT                 z)SignalsTest.check_interrupted_write_retrycCs|jddddS)Nrrr]rwr8rrr%test_interrupted_write_retry_bufferedsz1SignalsTest.test_interrupted_write_retry_bufferedcCs|jdddddS)Nrrrr`rxr8rrr!test_interrupted_write_retry_textsz-SignalsTest.test_interrupted_write_retry_textN)rrrrrrIrYr[r^rarrrdrfrgrkrmrnrwryrzrrrrrFs"M DrFc@seZdZeZdS) CSignalsTestN)rrrrrrrrr{sr{c@seZdZeZdZdZdS) PySignalsTestN)rrrrrrfrgrrrrr|sr|c s tttttttttt t t t t ttttttf}ttttttttf}tjdg}dd|D}dd|D}t|fdd|D|fdd|Dt j!|d<|D]Z}|j"#d r|$D]\}}t%|||qq|j"#d r|$D]\}}t%|||qqt&'d d |D} | S) NrcSsi|]}|tt|qSr)rrrrrrr rMzload_tests..cSsi|]}|tt|qSr)rrr}rrrr~rMc3s"|]}|jd|jfVqdS)r NrrZglobsrrrtrMzload_tests..c3s"|]}|jd|jfVqdS)PyNrrrrrrtrMr$r rcSsg|]}t|qSr)rZ makeSuite)rrrrrr rMzload_tests..)(rrrr2r>rurvrrrrrrrrrr8rDr{r|rLrTrqrirrwr*r_rrglobalsrr OpenWrapperrrr9setattrrZ TestSuite) r}rZmocksZ all_membersZc_io_nsZpy_io_nsrrrZsuiterrr load_testss>    r__main__)rrcr rr rrr#rGrr3r`rdrrr< collectionsrr itertoolsrrrrZtest.support.script_helperrrr Z test.supportr r rrZ_pyiorr ImportErrorrZ Structurerr^r`dev_moderr)r*rrJrKrLrRrSrTr]r^r_rgrhrirorprqrrurvrwr~rrrrZTestCaserrrrrrrrr2r>r?rurvrwrrrrrrrregisterrrrrrrrrrrrr8rDrrrFr{r|rrmainrrrrs  8   0:.*3(0QjW +i  NuF<o %