ϪfQ*ddlmZddlZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZdZd ZGd d ej2ZGd d ZGddZGddej2ZGddej2Zy)) annotationsN)Callable)helper) BLINKBOLDG0G1G2G3NORMAL REVERSE_VIDEO UNDERLINEmodes privateModes)failure)unittestPceZdZd$dZd$dZd$dZd$dZd$dZd$dZd$dZ d$dZ d$d Z d$d Z d$d Z d$d Zd$d Zd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZd$dZ d$dZ!d$d Z"d$d!Z#d$d"Z$y#)% BufferTestscjtj|_|jjyN)rTerminalBuffertermconnectionMadeselfs @/usr/lib/python3/dist-packages/twisted/conch/test/test_helper.pysetUpzBufferTests.setUps"))+    "ch|j|jjt|j|jjt |j|jj dt dz z|j|jjdy)N rr) assertEqualrwidthWIDTHheightHEIGHT __bytes__reportCursorPositionrs rtestInitialStatezBufferTests.testInitialState#sw %0 ))62 ,,.!0DE 7796Br c|jtjdtjdi|jjy)z Verify that only DEC Auto Wrap Mode (DECAWM) and DEC Text Cursor Enable Mode (DECTCEM) are initially in the Set Mode (SM) state. TN)r%r AUTO_WRAP CURSOR_MODErrs rtest_initialPrivateModesz$BufferTests.test_initialPrivateModes)s7   # #T<+C+CT J II " " r cN|jjd|jjd|j|jj d|jj d|j|jj dy)zQ C{" "} moves the cursor to the first column in the current row. r2r3 rr3N)r cursorForward cursorDownr%r+insertAtCursorrs rtest_carriageReturnzBufferTests.test_carriageReturn3st " Q 7796B   ' 7796Br c|jjd|j|jjd|jj d|j|jjdy)zV C{" "} moves the cursor to the next row without changing the column. r2)r2rr"r2r#N)rr7r%r+r9rs r test_linefeedzBufferTests.test_linefeed=sb " 7796B   ' 7796Br cN|jjd|jjd|j|jj d|jj d|j|jj dy)z: C{write} transforms C{" "} into C{" "}. r2r3r4r"rN)rr7r8r%r+writers r test_newlinezBufferTests.test_newlineFsr " Q 7796B  7796Br cV|jjj}|jjtjtj gd|tj<d|tj <|j ||jjy)z Verify that L{helper.TerminalBuffer.setPrivateModes} changes the Set Mode (SM) state to "set" for the private modes it is passed. TN)rrcopysetPrivateModesSCROLLSCREENr%rexpecteds rtest_setPrivateModesz BufferTests.test_setPrivateModesPsy 99))..0 !!<#6#6 8K8K"LM(,$$%(,$$% 499#9#9:r cN|jjj}|jjtjtj g|tj=|tj =|j ||jjy)z Verify that L{helper.TerminalBuffer.resetPrivateModes} changes the Set Mode (SM) state to "reset" for the private modes it is passed. N)rrrDresetPrivateModesr.r/r%rHs rtest_resetPrivateModesz"BufferTests.test_resetPrivateModes[su 99))..0 ##\%;%;\=U=U$VW \++ , \-- . 499#9#9:r c|jjd|j|jjd|jj|j|jjd|jjt|j|jjdtdz fy)Nr3r6r?rr#)rr8r%r+r)rs rtestCursorDownzBufferTests.testCursorDownfs Q 7796B  7796B V$ 779Avz?Kr c|jjd|j|jjd|jj d|jjd|j|jjd|jjd|j|jjdy)Nr2r$r#)rrR)rcursorUpr%r+r8rs r testCursorUpzBufferTests.testCursorUpns 1 7796B R  1 7797C 2 7796Br c|jjd|j|jjd|jjd|j|jjd|jjt|j|jjtdfy)N)rVr)r@rr)rr7r%r+r'rs rtestCursorForwardzBufferTests.testCursorForwardys " 7796B " 7796B & 779E1:Fr cb|jjd|jjd|j|jj d|jjd|j|jj d|jjd|j|jj d|jjd|j|jj dy)N rV)r)r#rr#r$)rr7cursorBackwardr%r+rs rtestCursorBackwardzBufferTests.testCursorBackwards #   # 7796B   # 7796B   # 7796B   # 7796Br c|jjdd|j|jjdy)Nr3 )r3r_)rcursorPositionr%r+rs rtestCursorPositioningz!BufferTests.testCursorPositionings3   A& 7796Br cd}|jj||j|jj|dzdtdz zzy)N Hello, world.r"rV)rrAr%r*r)rss rtestSimpleWritingzBufferTests.testSimpleWritingsF   ,,.E EVaZ&ST*AU#U r c d}d}|jjdj||f|jjdd|jj |j |jj d|ddjt|zdzdtdz zzy)Nrrr"r2r#r3) rrArr`eraseToDisplayBeginningr%r*rtrir)rs rtestEraseToDisplayBeginningz'BufferTests.testEraseToDisplayBeginnings    B8,-   A& ))+  II   ! BqrFLLR) )E 1EVaZ4H H r cVd}d}|jjdj||f|jjdd|jj |j |jj |dzdz|zdzdtdz zzy)Nrrr"r[r#r@)rrArr` insertLiner%r*r)rs rtestLineInsertionzBufferTests.testLineInsertions    B8,-   A&   II   ! J  #e +evz.B B r cVd}d}d}|jjdj|||f|jjdd|jj |j |jj |dz|zdzdtdz zzy)Nrs Middle wordsrr"r_r#r3)rrArr` deleteLiner%r*r)rs rtestLineDeletionzBufferTests.testLineDeletions     BB<01   A&   II   !2:?U#:Ufqj=Q#Q r NreturnNone)%__name__ __module__ __qualname__rr,r0r:r=rBrJrMrOrTrWr]rarfrlrorrruryr}rrrrrrrrrrrrrrr rrrs#C  CCC ; ;L CG CCR     LC C C,.($-L=@  W F        r rcLeZdZdZdZ ddZddZd dZd dZy) FakeDelayedCallFcJ||_||_||_||_||_yr)fstimeoutfakw)rrrrrrs r__init__zFakeDelayedCall.__init__s' r c8|jxs |j Sr) cancelledcalledrs ractivezFakeDelayedCall.activesNN1dkk22r cd|_yNT)rrs rcancelzFakeDelayedCall.cancels r c^d|_|j|ji|jyr)rrrrrs rcallzFakeDelayedCall.calls$ "$''"r N) r FakeSchedulerrfloatrCallable[..., None]rztuple[object, ...]rzdict[str, object]rr)rboolr) rrrrrrrrrrr rrrsZ FI            3 #r rc0eZdZddZ ddZy)rcg|_yr)callsrs rrzFakeScheduler.__init__s ,. r c p|jjt||||||jdS)N)rappendr)rrrrrs r callLaterzFakeScheduler.callLaters1 /$ArBCzz"~r Nr) rrrrrobjectrrrr)rrrrrrr rrrs4/!4:@HN r rcTeZdZd dZd dZd dZd dZd dZd dZd dZ d dZ d d Z y ) ExpectTestsctj|_|jjt |_yr)rExpectableBufferrrrrrs rrzExpectTests.setUps+++-    "/r cNg}|jjdd|j}|j|j|jj d|j ||jj d|j||j|djd|jt|jjd|j |jjdjy)N hello worldr#r schedulersgreeting puny earthlings s hello world r) rexpectr addCallbackrrArrr%grouprirrrresultds rtestSimpleStringzExpectTests.testSimpleStrings(* II  ^Q$''  J fmm$ 56   ()  *N; TWW]]+Q/ q)0023r cg}|jjd}|j|j|j ||jj d|j ||jj d|j ||jj d|j ||j|djdy)Nrhello sworldr) rrrrrrArr%rrs rtestBrokenUpStringzExpectTests.testBrokenUpStrings(* II  ^ , fmm$    "         *N;r cg}|jjd}|j|j|jjd}|j|j|j ||jj d|j ||jj d|j t|d|jj d|j t|d|j |djd|j |djdy)Nrworldshello r#rVr) rrrrrrAr%rirrrd1d2s r testMultiplezExpectTests.testMultiples(* YY  i ( v}}% YY  h ' v}}%   !    Va( ! Va( *I6 *H5r c|jjdg}|jjd}|j|j|j ||j |djdy)Nrr)rrArrrrr%rrs rtestSynchronouszExpectTests.testSynchronoussb '(* II  ^ , fmm$  *N;r c|jjdg}|jjd}|j|j|jjd}|j|j|j t |d|j |djd|j |djdy)Ns goodbye worldsbyer rVrr#)rrArrrr%rirr s rtestMultipleSynchronousz#ExpectTests.testMultipleSynchronous s ()(* YY  f % v}}% YY  h ' v}}% Va( *F3 *H5r c|jt|d|j|jtj y)Ntype)rhasattrr%rrExpectationTimeout)rress r_cbTestTimeoutFailurez!ExpectTests._cbTestTimeoutFailures/ V,- 6#<#<=r c|jjdd|j}|j|j|jj dj y)Nrr#rr)rrraddBothrrr)rrs rtestTimeoutFailurezExpectTests.testTimeoutFailuresL II  ^Q$''  J $,,-  ar c|jjdg}|jjdd|j}|j |j |jjd}|j |j|jjdj|jt|d|j|djdy)Nsnot zoomtasticrr#rszoomr) rrArrrrrrrrr%rirr s rtestOverlappingTimeoutz"ExpectTests.testOverlappingTimeout#s )*(* YY  na477  K 4--. YY  g & v}}%  a Va( *G4r Nr)rzfailure.Failurerr) rrrrrr rrrrrrrr rrrs/" 4 <6"< 6> 5r rc eZdZdZddZddZy)CharacterAttributeTestszG Tests for L{twisted.conch.insults.helper.CharacterAttribute}. c |jtjtj|jtjtjt|jtjddddtjtjddddtj|j tjtjt |j tjdtjdy)z L{CharacterAttribute}s must have matching character attribute values (bold, blink, underline, etc) with the same values to be considered equal. )rTF)rrrrrrN)r%rCharacterAttributerBLUEassertNotEqualr rs r test_equalityz%CharacterAttributeTests.test_equality7s 224f6O6O6QR   % % ')B)B2)N    % %!!;;    % %!!;;   "   % % ')B)B2)N    % %4 0&2K2KQV2W r c,tjjd|j|jg}|j t |d|j |ddtd}|j |ddd|zy ) z~ L{twisted.conch.insults.helper.CharacterAttribute.wantOne} emits a deprecation warning when invoked. Tr#r#rcategoryz5twisted.conch.insults.helper._FormattingState.wantOnemessagez#%s was deprecated in Twisted 13.1.0N)r_FormattingStatewantOne flushWarningstest_wantOneDeprecatedr%riDeprecationWarning)r warningsShowndeprecatedClasss rr.z.CharacterAttributeTests.test_wantOneDeprecated\s !))t)4**D,G,G+HI  ]+Q/ q)*57IJQ  ! Y ' 1_ E r Nr)rrr__doc__r'r.rr rr!r!2s# J r r!) __future__rretypingrtwisted.conch.insultsrtwisted.conch.insults.insultsrrrr r r r r rrrtwisted.pythonr twisted.trialrr'r)TestCaserrrrr!rr rr;s# (    #"  G (##G T ##>]5(##]5@9 h//9 r