HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/conch/test/__pycache__/test_helper.cpython-38.pyc
U


W[P�@s�ddlmZddlmZmZmZmZddlmZmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZdZdZGd	d
�d
ej�ZGdd�d�ZGd
d�d�ZGdd�dej�ZGdd�dej�ZdS)�)�helper)�G0�G1�G2�G3)�modes�privateModes)�NORMAL�BOLD�	UNDERLINE�BLINK�
REVERSE_VIDEO)�_PY3)�unittest�P�c@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dES)F�BufferTestscCst��|_|j��dS�N)rZTerminalBuffer�term�connectionMade��self�r�@/usr/lib/python3/dist-packages/twisted/conch/test/test_helper.py�setUps
zBufferTests.setUpcCsP|�|jjt�|�|jjt�|�|j��dtd�|�|j��d�dS)N�
��rr)�assertEqualr�width�WIDTHZheight�HEIGHT�	__bytes__�reportCursorPositionrrrr�testInitialStates
�zBufferTests.testInitialStatecCs |�tjdtjdi|jj�dS)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)rr�	AUTO_WRAP�CURSOR_MODErrrrr�test_initialPrivateModess��z$BufferTests.test_initialPrivateModescCsL|j�d�|j�d�|�|j��d�|j�d�|�|j��d�dS)zQ
        C{"
"} moves the cursor to the first column in the current row.
        ���r(r)�
�rr)N)r�
cursorForward�
cursorDownrr#�insertAtCursorrrrr�test_carriageReturn)s
zBufferTests.test_carriageReturncCs@|j�d�|�|j��d�|j�d�|�|j��d�dS)zV
        C{"
"} moves the cursor to the next row without changing the column.
        r()r(rr�r(rN)rr-rr#r/rrrr�
test_linefeed4szBufferTests.test_linefeedcCsL|j�d�|j�d�|�|j��d�|j�d�|�|j��d�dS)z:
        C{write} transforms C{"
"} into C{"
"}.
        r(r)r*r�r�N)rr-r.rr#�writerrrr�test_newline>s
zBufferTests.test_newlinecCsH|jj��}|j�tjtjg�d|tj<d|tj<|�||jj�dS)z�
        Verify that L{helper.TerminalBuffer.setPrivateModes} changes the Set
        Mode (SM) state to "set" for the private modes it is passed.
        TN)rr�copyZsetPrivateModesZSCROLLZSCREENr�rZexpectedrrr�test_setPrivateModesIs


z BufferTests.test_setPrivateModescCsD|jj��}|j�tjtjg�|tj=|tj=|�||jj�dS)z�
        Verify that L{helper.TerminalBuffer.resetPrivateModes} changes the Set
        Mode (SM) state to "reset" for the private modes it is passed.
        N)rrr7ZresetPrivateModesr%r&rr8rrr�test_resetPrivateModesUs
z"BufferTests.test_resetPrivateModescCsd|j�d�|�|j��d�|j��|�|j��d�|j�t�|�|j��dtdf�dS)Nr)r,r3rr)rr.rr#r!rrrr�testCursorDownas
zBufferTests.testCursorDowncCsj|j�d�|�|j��d�|j�d�|j�d�|�|j��d�|j�d�|�|j��d�dS)Nr(r�r)r�r=)rZcursorUprr#r.rrrr�testCursorUpiszBufferTests.testCursorUpcCsb|j�d�|�|j��d�|j�d�|�|j��d�|j�t�|�|j��tdf�dS)N�)r?r)r4rr)rr-rr#r rrrr�testCursorForwardtszBufferTests.testCursorForwardcCs�|j�d�|j�d�|�|j��d�|j�d�|�|j��d�|j�d�|�|j��d�|j�d�|�|j��d�dS)N�
r?)�r�)rrrr)rr-�cursorBackwardrr#rrrr�testCursorBackward|szBufferTests.testCursorBackwardcCs$|j�dd�|�|j��d�dS)Nr)�	)r)rF)r�cursorPositionrr#rrrr�testCursorPositioning�sz!BufferTests.testCursorPositioningcCs6d}|j�|�|�|j��|ddtd�dS)N�
Hello, world.rr?)rr5rr"r!�r�srrr�testSimpleWriting�s
��zBufferTests.testSimpleWritingcCsnd}|j�|�|j�t|��|j�tjg�|j�d�|�|j��d|dd�ddt	d�dS)Ns
hello, world.�Hrrr?)
rr5rD�lenZ
resetModesr�IRMrr"r!rJrrr�testOvertype�s
��zBufferTests.testOvertypecCsfd}|j�|�|j�t|��|j�tjg�|j�d�|�|j��d|ddt	d�dS)Nsello, world.rMrr?)
rr5rDrNZsetModesrrOrr"r!rJrrr�
testInsert�s

��zBufferTests.testInsertcCs^d}|j�d�|j�d�|j�|�|�|j��d|jjd|ddtd�dS)NrIr(s




rrC)rr.r-r5rr"Zfillr!rJrrr�testWritingInTheMiddle�s 
���
��z"BufferTests.testWritingInTheMiddlecCsdd}|j�td�|j�|�|�|j��|dd��t�d|dd�ddtd�dS)NrIr(rr))rr-r r5rr"�rjustr!rJrrr�testWritingWrappedAtEndOfLine�s
��
��z)BufferTests.testWritingWrappedAtEndOfLinecCsj|j��|�|j��d�|j�t�|�|j��dtdf�|j��|�|j��dtdf�dS)N�rrrr)r�indexrr#r.r!rrrr�	testIndex�s

zBufferTests.testIndexcCsZ|j��|�|j��d�|j�d�|�|j��d�|j��|�|j��d�dS)Nrr?�rr?rU)rZreverseIndexrr#r.rrrr�testReverseIndex�s

zBufferTests.testReverseIndexcCsZ|j��|�|j��d�|j�d�|�|j��d�|j��|�|j��d�dS)zm
        C{nextLine} positions the cursor at the beginning of the row below the
        current row.
        rUr(r1rXN)rZnextLinerr#r-rrrr�
test_nextLine�s

zBufferTests.test_nextLinecCs~|j�d�|j�d�|�|j��d�|j��|j�d�|j�d�|�|j��d�|j��|�|j��d�dS)Nr(rC)rCr(r))r4�)rr.r-rr#Z
saveCursorrDZ
restoreCursorrrrr�testSaveCursor�s

zBufferTests.testSaveCursorcCs�|j��|j�d�|j�dd�}|�|dd�|�|djt�|j�dd�}|�|dd�|�|djt�|j��|j�d�|j�dd�}|�|dd�|�|djt	�|j�d	d�}|�|dd�|�|djt�dS)
NsHirrMr�is!!r?�!r))
rZsingleShift2r5�getCharacterr�charsetrrZsingleShift3r�r�chrrr�testSingleShifts�s 

zBufferTests.testSingleShiftsc		Cs�d}d}d}|j�d�|j��|j�d�|j��|j�d�t}d}|||fD]j}tt|��D]@}|j�||�}|�|d|||d��|�|dj	|�qf|tkr�t
p�t}|d7}qVdS)	NsHellosWorldsBye!sHello
sWorld
sBye!
rr)rr5ZshiftOutZshiftInr�rangerNr_rr`r)	r�s1�s2�s3�g�hrK�irbrrr�testShiftings"

zBufferTests.testShiftingcCs�|j�tttt�|j�d�|j�t�|j�d�|j�t�|j�d�|j�t�|j�d�|j�dd�}|�	|dd�|�
|dj�|�
|dj�|�
|dj
�|�
|dj�|j�dd�}|�	|dd�|�|dj�|�|dj�|�|dj
�|�|dj�|j�dd�}|�	|dd�|�
|dj
�|�|dj�|�|dj�|�|dj�|j�dd�}|�	|dd�|�
|dj
�|�
|dj�|�|dj�|�|dj�dS)	N�W�X�Y�Zrrr?r))r�selectGraphicRenditionr
rrr
r5r	r_r�
assertTrue�bold�	underline�blink�reverseVideo�assertFalserarrr�testGraphicRenditions@z BufferTests.testGraphicRenditioncCs�d}d}|j�tjtjtjtj�|j�|d�|j�t�|j�|d�t	t
|��D]�}|j�|d�}|�|d|||d��|�|dj
t�|�|dj�|�|dj�|�|dj�|�|dj�|�|djtj�|�|djtj�q^t	t
|��D]�}|j�|d�}|�|d|||d��|�|dj
t�|�|dj�|�|dj�|�|dj�|�|dj�|�|djtj�|�|djtj��qdS)Ns
Merry xmassJust kiddingrrr)rrprZ
FOREGROUNDZREDZ
BACKGROUNDZGREENr5r	rdrNr_rr`rrvrrrsrtru�
foregroundZ
backgroundZWHITEZBLACK)rrerfrjrbrrr�testColorAttributesDs8
�zBufferTests.testColorAttributescCsrd}d}d}|j�d�|||f�d�|j�dd�|j��|�|j��|dd|ddtd�dS)Nsline 1sline 2sline 3rrr4)rr5�joinrGZ	eraseLinerr"r!�rrerfrgrrr�
testEraseLineds$
���
��zBufferTests.testEraseLinecCsTd}|j�|�|j�d�|j��|�|j��|dd�ddtd�dS)NrIr(���rr?)rr5rDZeraseToLineEndrr"r!rJrrr�testEraseToLineEndts

��zBufferTests.testEraseToLineEndcCs^d}|j�|�|j�d�|j��|�|j��|dd��t|��ddtd�dS)NrIr(���rr?)	rr5rDZeraseToLineBeginningrr"rSrNr!rJrrr�testEraseToLineBeginnings

��z$BufferTests.testEraseToLineBeginningcCs@|j�d�|j�d�|j��|�|j��dtd�dS)NsHello world
sGoodbye world
rr)rr5ZeraseDisplayrr"r!rrrr�testEraseDisplay�s

�zBufferTests.testEraseDisplaycCsnd}d}|j�d�||df��|j�dd�|j��|�|j��|d|dd�ddtd�dS)N�Hello world�
Goodbye worldr�r(rr))rr5rzrGZeraseToDisplayEndrr"r!�rrerfrrr�testEraseToDisplayEnd�s

��
��z!BufferTests.testEraseToDisplayEndcCsrd}d}|j�d�||f��|j�dd�|j��|�|j��d|dd��t|��ddt	d�dS)Nr�r�rr(r�r))
rr5rzrGZeraseToDisplayBeginningrr"rSrNr!r�rrr�testEraseToDisplayBeginning�s
��
��z'BufferTests.testEraseToDisplayBeginningcCshd}d}|j�d�||f��|j�dd�|j��|�|j��|dd|ddtd�dS)Nr�r�rrCrr4)rr5rzrGZ
insertLinerr"r!r�rrr�testLineInsertion�s"
���
��zBufferTests.testLineInsertioncCsjd}d}d}|j�d�|||f��|j�dd�|j��|�|j��|d|ddtd�dS)Nr�sMiddle wordsr�rrFrr))rr5rzrGZ
deleteLinerr"r!r{rrr�testLineDeletion�s 
��
��zBufferTests.testLineDeletionN)%�__name__�
__module__�__qualname__rr$r'r0r2r6r9r:r;r>r@rErHrLrPrQrRrTrWrYrZr\rcrkrwryr|r~r�r�r�r�r�r�rrrrrsD
			
' 
rc@s4eZdZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�FakeDelayedCallFcCs"||_||_||_||_||_dSr)�fs�timeout�f�a�kw)rr�r�r�r�r�rrr�__init__�s
zFakeDelayedCall.__init__cCs|jp
|jSr)�	cancelled�calledrrrr�active�szFakeDelayedCall.activecCs
d|_dS�NT)r�rrrr�cancel�szFakeDelayedCall.cancelcCsd|_|j|j|j�dSr�)r�r�r�r�rrrr�call�szFakeDelayedCall.callN)	r�r�r�r�r�r�r�r�r�rrrrr��sr�c@seZdZdd�Zdd�ZdS)�
FakeSchedulercCs
g|_dSr)�callsrrrrr��szFakeScheduler.__init__cOs"|j�t|||||��|jdS)N���)r��appendr�)rr�r�r�r�rrr�	callLater�szFakeScheduler.callLaterN)r�r�r�r�r�rrrrr��sr�c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�ExpectTestscCs t��|_|j��t�|_dSr)rZExpectableBufferrrr�r�rrrrr�s

zExpectTests.setUpcCs�g}|jjdd|jd�}|�|j�|j�d�|�|�|j�d�|�|�|�|d�	�d�|�t
|jj�d�|�|jjd���dS)N�hello worldr�r�Z	schedulersgreeting puny earthlings
shello world
r)
r�expectr��addCallbackr�r5rvrqr�grouprNr�r��r�result�drrr�testSimpleString�s

zExpectTests.testSimpleStringcCs�g}|j�d�}|�|j�|�|�|j�d�|�|�|j�d�|�|�|j�d�|�|�|�|d��d�dS)Nr��hello sworl�dr)	rr�r�r�rvr5rqrr�r�rrr�testBrokenUpString	s



zExpectTests.testBrokenUpStringcCs�g}|j�d�}|�|j�|j�d�}|�|j�|�|�|j�d�|�|�|j�d�|�t|�d�|j�d�|�t|�d�|�|d��d�|�|d��d�dS)Nr��worldshello� rr?r)	rr�r�r�rvr5rrNr��rr�Zd1Zd2rrr�testMultiples

zExpectTests.testMultiplecCsJ|j�d�g}|j�d�}|�|j�|�|�|�|d��d�dS)Nr�r)rr5r�r�r�rqrr�r�rrr�testSynchronous*s
zExpectTests.testSynchronouscCs||j�d�g}|j�d�}|�|j�|j�d�}|�|j�|�t|�d�|�|d��d�|�|d��d�dS)Ns
goodbye worldsbyer�r?rr)rr5r�r�r�rrNr�r�rrr�testMultipleSynchronous4sz#ExpectTests.testMultipleSynchronouscCs$|�t|d��|�|jtj�dS)N�type)rq�hasattrrr�rZExpectationTimeout)r�resrrr�_cbTestTimeoutFailureBsz!ExpectTests._cbTestTimeoutFailurecCs4|jjdd|jd�}|�|j�|jjd��dS)Nr�rr�r)rr�r��addBothr�r�r�)rr�rrr�testTimeoutFailureGszExpectTests.testTimeoutFailurecCs�|j�d�g}|jjdd|jd�}|�|j�|j�d�}|�|j�|jjd�	�|�
t|�d�|�
|d��d�dS)Nsnot zoomtasticr�rr�szoomr)
rr5r�r�r�r�r�r�r�r�rrNr�r�rrr�testOverlappingTimeoutMsz"ExpectTests.testOverlappingTimeoutN)r�r�r�rr�r�r�r�r�r�r�r�rrrrr��s
r�c@s eZdZdZdd�Zdd�ZdS)�CharacterAttributeTestszG
    Tests for L{twisted.conch.insults.helper.CharacterAttribute}.
    c
Cs�|�t��t���|�t��tjtd��|�tjddddtjd�tjddddtjd��|�t��tjtd��|�tjdd�tjdd��dS)z�
        L{CharacterAttribute}s must have matching character attribute values
        (bold, blink, underline, etc) with the same values to be considered
        equal.
        )r`TF)rrrsrtrurx�rrN)rrZCharacterAttributerZBLUEZassertNotEqualrrrrr�
test_equalityas@�
����
�

�z%CharacterAttributeTests.test_equalitycCslt��jdd�|�|jg�}|�t|�d�|�|ddt�trLd}nd}|�|ddd	|�d
S)z~
        L{twisted.conch.insults.helper.CharacterAttribute.wantOne} emits
        a deprecation warning when invoked.
        Tr�rr�categoryz5twisted.conch.insults.helper._FormattingState.wantOnez$twisted.conch.insults.helper.wantOne�messagez#%s was deprecated in Twisted 13.1.0N)	rZ_FormattingStateZwantOneZ
flushWarnings�test_wantOneDeprecatedrrN�DeprecationWarningr)rZ
warningsShownZdeprecatedClassrrrr��s�
�z.CharacterAttributeTests.test_wantOneDeprecatedN)r�r�r��__doc__r�r�rrrrr�]sr�N)Ztwisted.conch.insultsrZtwisted.conch.insults.insultsrrrrrrr	r
rrr
Ztwisted.python.compatrZ
twisted.trialrr r!ZTestCaserr�r�r�r�rrrr�<module>sAi