o
    Òó·is}  ã                   @   sb  d dl Z d dlmZmZ d dlmZmZ d dlmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d	d
„ Zdd„ Zdd„ Zdd„ Z e!ƒ Z"dd„ Z#dd„ Z$e$ddg d¢g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d ¢g d!¢g d"¢g d#¢g d$¢g d%¢g d&¢ge  %d'¡d(�Z&e$d)ddd*gdd+gd,d-gd.d/gdd0gd1d2gd3d4gd5d6gd7d8gd9dgd:d;gd<d=gd>d?gd@dAgdBdCgdDdEgge  %dF¡d(�Z'G dGdH„ dHƒZ(G dIdJ„ dJƒZ)dKZ*G dLdM„ dMe)ƒZ+[*G dNdO„ dOe+ej,ƒZ-G dPdQ„ dQe+ej,ƒZ.G dRdS„ dSe+ej,ƒZ/G dTdU„ dUe+ej,ƒZ0G dVdW„ dWej,e)ƒZ1G dXdY„ dYej,ƒZ2dS )Zé    N)ÚOptionalÚType)ÚValueConstantÚValues)ÚBLINKÚCS_ALTERNATEÚCS_ALTERNATE_SPECIALÚ
CS_DRAWINGÚCS_UKÚCS_USÚG0ÚG1Ú	UNDERLINEÚClientProtocolÚServerProtocolÚmodesÚprivateModes)ÚProtocol)ÚStringTransport)Ú	iterbytes)Úunittestc                 C   s   t t| ƒ |¡S ©N)ÚsuperÚMockÚ__getattribute__)ÚmockÚname© r   úeC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\twisted/conch/test/test_insults.pyÚ_getattr   s   r   c                 C   ó
   t | dƒS )NÚoccurrences©r   ©r   r   r   r   r!   #   ó   
r!   c                 C   r    )NÚmethodsr"   r#   r   r   r   r%   '   r$   r%   c                 C   s   t | ƒ |¡ d S r   )r!   Úappend)r   Úobjr   r   r   Ú_append+   s   r(   c                 C   s   t t| d> |B gƒƒS )a  
    Return the byte in 7- or 8-bit code table identified by C{column}
    and C{row}.

    "An 8-bit code table consists of 256 positions arranged in 16
    columns and 16 rows.  The columns and rows are numbered 00 to 15."

    "A 7-bit code table consists of 128 positions arranged in 8
    columns and 16 rows.  The columns are numbered 00 to 07 and the
    rows 00 to 15 (see figure 1)."

    p.5 of "Standard ECMA-35: Character Code Structure and Extension
    Techniques", 6th Edition (December 1994).
    é   N)ÚbytesÚ	bytearray)ÚcolumnÚrowr   r   r   Ú_ecmaCodeTableCoordinate2   s   r.   c                    s,   ‡ fdd„t |ƒD ƒ}||d< t| tf|ƒS )Nc                    s:   i | ]\}}t |ƒD ]\}}|r
|tt|ˆ  |ƒƒ“q
qS r   )Ú	enumerater   r.   )Ú.0Újr-   Úir   ©Ú	colOffsetr   r   Ú
<dictcomp>K   s    ýüÿz/_makeControlFunctionSymbols.<locals>.<dictcomp>Ú__doc__)r/   Útyper   )r   r4   ÚnamesÚdocÚattrsr   r3   r   Ú_makeControlFunctionSymbolsF   s
   
þr;   ÚCSFinalByter)   )ZICHÚDCHZHPA)ÚCUUZSSEZHPR)ÚCUDZCPRZREP)ÚCUFZSUZDA)ÚCUBZSDZVPA)ZCNLZNPZVPR)ZCPLZPPZHVP)ZCHAZCTCZTBC)ÚCUPZECHÚSM)ZCHTZCVTZMC)ÚEDZCBTZHPB)ÚELZSRSZVPB)ÚILZPTXÚRM)ÚDLZSDSÚSGR)ZEFZSIMDÚDSR)ZEANZDAQaW  
    Symbolic constants for all control sequence final bytes
    that do not imply intermediate bytes.  This happens to cover
    movement control sequences.

    See page 11 of "Standard ECMA 48: Control Functions for Coded
    Character Sets", 5th Edition (June 1991).

    Each L{ValueConstant} maps a control sequence name to L{bytes}
    )r4   r8   r9   Ú
C1SevenBitZDCSZPU1ZBPHZPU2ZNBHZSTSZCCHZNELZMWZSSAZSPAZESAZEPAÚHTSZSOSZHTJZVTSZSCIZPLDÚCSIZPLUZSTÚRIÚOSCÚSS2ZPMÚSS3ZAPCa   
    Symbolic constants for all 7 bit versions of the C1 control functions

    See page 9 "Standard ECMA 48: Control Functions for Coded
    Character Sets", 5th Edition (June 1991).

    Each L{ValueConstant} maps a control sequence name to L{bytes}
    c                   @   s.   e Zd ZeZdefdd„Zdd„ Zdd„ ZdS )r   Nc                 C   s.   g | _ |du r	i }|| _|tur|| _dS dS )z�
        @param methods: Mapping of names to return values
        @param callReturnValue: object __call__ should return
        N)r!   r%   ÚdefaultÚcallReturnValue)Úselfr%   rS   r   r   r   Ú__init__Ÿ   s   
ÿzMock.__init__c                 O   s.   t | dƒ}|tu rtƒ }t| d|||fƒ |S )NrS   Ú__call__)r   rR   r   r(   )rT   ÚaÚkwZreturnValuer   r   r   rV   «   s
   
zMock.__call__c                 C   s:   t | dƒ}||v rt|| d�}ntƒ }t| ||fƒ |S )Nr%   )rS   )r   r   r(   )rT   r   r%   Ú	attrValuer   r   r   r   ³   s   
zMock.__getattribute__)Ú__name__Ú
__module__Ú__qualname__rR   rS   rU   rV   r   r   r   r   r   r   œ   s
    r   c                   @   s   e Zd Zdi fdd„ZdS )Ú	MockMixinr   c                 C   sb   |\}}|   ||¡ |   tt|ƒƒd¡ t|ƒ\\}}}	}
|   |d¡ |   |	|¡ |   |
|¡ |S )Né   rV   )ÚassertEqualÚlenr!   )rT   Z
occurrenceÚ
methodNameZexpectedPositionalArgsZexpectedKeywordArgsÚattrr   ÚcallÚresultÚargsrX   r   r   r   Ú
assertCall¿   s   zMockMixin.assertCallN)rZ   r[   r\   rf   r   r   r   r   r]   ¾   s    ÿr]   a“  def testByte%(groupName)s(self):
    transport = StringTransport()
    proto = Mock()
    parser = self.protocolFactory(lambda: proto)
    parser.factory = self
    parser.makeConnection(transport)

    bytes = self.TEST_BYTES
    while bytes:
        chunk = bytes[:%(bytesPer)d]
        bytes = bytes[%(bytesPer)d:]
        parser.dataReceived(chunk)

    self.verifyResults(transport, proto, parser)
c                   @   sN   e Zd ZU dZeee  ed< dD ]\ZZ	e
eee	dœ ƒ q[[	dd„ ZdS )ÚByteGroupingsMixinNÚprotocolFactory))ZPairsé   )ZTriplesé   )ZQuadsr)   )ZQuintsé   )ZSexesé   )Z	groupNameZbytesPerc                 C   s.   |   t|ƒ d¡d|f¡}|  t|ƒg ¡ d S )Nr   ÚmakeConnection)rf   r!   Úpopr_   )rT   Ú	transportÚprotoÚparserrd   r   r   r   ÚverifyResultsë   s   z ByteGroupingsMixin.verifyResults)rZ   r[   r\   rh   r   r   r   Ú__annotations__ÚwordÚnÚexecÚ_byteGroupingTestTemplaterr   r   r   r   r   rg   Þ   s   
 rg   c                   @   ó   e Zd ZeZdZdd„ ZdS )ÚServerArrowKeysTestss   [A[B[C[Dc                 C   sh   t  | |||¡ |j|j|j|jfD ]}|  t|ƒ d¡d|d f¡}|  	t|ƒg ¡ q|  
t|ƒ¡ d S )Nr   ÚkeystrokeReceived)rg   rr   ZUP_ARROWZ
DOWN_ARROWZRIGHT_ARROWZ
LEFT_ARROWrf   r!   rn   r_   ÚassertFalse)rT   ro   rp   rq   Zarrowrd   r   r   r   rr   ù   s   üÿz"ServerArrowKeysTests.verifyResultsN©rZ   r[   r\   r   rh   Ú
TEST_BYTESrr   r   r   r   r   ry   ó   s    ry   c                   @   rx   )ÚPrintableCharactersTestss   abc123ABC!@#abc123c                 C   s¤   t  | |||¡ tdƒD ]}|  t|ƒ d¡d|d f¡}|  t|ƒg ¡ qtdƒD ]}|  t|ƒ d¡d||jf¡}|  t|ƒg ¡ q)t|ƒ}|  ||›d�¡ d S )Ns   abc123ABC!@#r   rz   s   abc123z should have been [])	rg   rr   r   rf   r!   rn   r_   ZALTr{   )rT   ro   rp   rq   Úcharrd   Úoccsr   r   r   rr     s   ÿÿz&PrintableCharactersTests.verifyResultsNr|   r   r   r   r   r~   	  s    r~   c                   @   sF   e Zd ZdZeZg ZdD ]	Ze de ¡ qd 	e¡Z
[[dd„ ZdS )ÚServerFunctionKeysTestsz9Test for parsing and dispatching function keys (F1 - F12))s   OPs   OQs   ORs   OSs   15~s   17~s   18~s   19~s   20~s   21~s   23~s   24~ó   [ó    c                 C   sn   t  | |||¡ tddƒD ] }t|d|f ƒ}|  t|ƒ d¡d|d f¡}|  t|ƒg ¡ q|  t|ƒ¡ d S )Nr^   é   zF%dr   rz   )	rg   rr   ÚrangeÚgetattrrf   r!   rn   r_   r{   )rT   ro   rp   rq   ZfuncNumZfuncArgrd   r   r   r   rr   <  s   ÿz%ServerFunctionKeysTests.verifyResultsN)rZ   r[   r\   r6   r   rh   ZbyteListZ	byteCodesr&   Újoinr}   rr   r   r   r   r   r�   $  s    
r�   c                   @   sH   e Zd ZeZdZdZdZdZee e e e e Z	[[[[dd„ Z
dS )ÚClientCursorMovementTestss   [2Bs   [4Cs   [As   [2Dc                 C   s^   t  | |||¡ dD ]\}}|  t|ƒ d¡d| |f¡}|  t|ƒg ¡ q
|  t|ƒ¡ d S )N))ÚDownri   )ÚForwardr)   ©ÚUpr^   ©ÚBackwardri   r‹   r�   r   Úcursor)rg   rr   rf   r!   rn   r_   r{   )rT   ro   rp   rq   ÚmethodÚcountrd   r   r   r   rr   R  s   ÿz'ClientCursorMovementTests.verifyResultsN)rZ   r[   r\   r   rh   Zd2Zr4Úu1Úl2r}   rr   r   r   r   r   rˆ   G  s    rˆ   c                   @   s¼   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-S ).ÚClientControlSequencesTestsc                    sh   t ƒ ˆ _tƒ ˆ _t‡ fdd„ƒˆ _ˆ ˆ j_ˆ j ˆ j¡ ˆ  t	ˆ jƒ 
d¡dˆ jf¡}ˆ  t	|ƒ¡ d S )Nc                      s   ˆ j S r   )rp   r   ©rT   r   r   Ú<lambda>h  s    z3ClientControlSequencesTests.setUp.<locals>.<lambda>r   rm   )r   ro   r   rp   r   rq   Úfactoryrm   rf   r!   rn   r{   )rT   rd   r   r•   r   ÚsetUpe  s   ÿz!ClientControlSequencesTests.setUpc                 C   st   | j  d dd„ tdƒD ƒ¡¡ t| jƒ}dD ]}dD ]}|  | d¡d| |f¡}|  t|ƒ¡ qq|  |¡ d S )	Nrƒ   c                 s   s&   � | ]}d D ]	}d| | V  qqdS ))rƒ   ó   2s   20s   200r‚   Nr   )r0   Úchru   r   r   r   Ú	<genexpr>r  s   € ý
þÿzBClientControlSequencesTests.testSimpleCardinals.<locals>.<genexpr>s   BACD)r‰   rŒ   rŠ   rŽ   )r^   ri   é   éÈ   r   r�   )	rq   ÚdataReceivedr‡   r   r!   rp   rf   rn   r{   )rT   r€   Úmethr‘   rd   r   r   r   ÚtestSimpleCardinalsp  s   
þÿ
þz/ClientControlSequencesTests.testSimpleCardinalsc                 C   sh   | j  d¡ t| jƒ}|  | d¡dd¡}|  t|ƒ¡ |  | d¡dd¡}|  t|ƒ¡ |  |¡ d S )Ns
   [5;22r[rr   ÚsetScrollRegion)rk   é   )NN©rq   rž   r!   rp   rf   rn   r{   ©rT   r€   rd   r   r   r   ÚtestScrollRegion€  s   
z,ClientControlSequencesTests.testScrollRegionc                 C   s¨   | j  d¡ t| jƒ}|  | d¡dd¡}|  t|ƒ¡ |  | d¡dd¡}|  t|ƒ¡ |  | d¡d¡}|  t|ƒ¡ |  | d¡d¡}|  t|ƒ¡ |  |¡ d S )Ns   #3#4#5#6r   ZdoubleHeightLine)T)FZsingleWidthLineZdoubleWidthLiner£   r¤   r   r   r   ÚtestHeightAndWidth‹  s   
z.ClientControlSequencesTests.testHeightAndWidthc                 C   s€   | j  d dd„ tdƒD ƒ¡¡ t| jƒ}ttfD ]}tt	t
ttfD ]}|  | d¡d||f¡}|  t|ƒ¡ q"q|  |¡ d S )Nrƒ   c                    s(   g | ]‰ d   ‡ fdd„tdƒD ƒ¡‘qS )rƒ   c                    s   g | ]}d ˆ  | ‘qS )ó   r   )r0   ru   ©Úgr   r   Ú
<listcomp>   s    zKClientControlSequencesTests.testCharacterSet.<locals>.<listcomp>.<listcomp>s   AB012)r‡   r   )r0   r   r¨   r   rª   Ÿ  s    ÿÿz@ClientControlSequencesTests.testCharacterSet.<locals>.<listcomp>s   ()r   ZselectCharacterSet)rq   rž   r‡   r   r!   rp   r   r   r
   r   r	   r   r   rf   rn   r{   )rT   r€   ÚwhichÚcharsetrd   r   r   r   ÚtestCharacterSetœ  s*   þÿÿ
ûÿöz,ClientControlSequencesTests.testCharacterSetc                 C   ód   | j  d¡ t| jƒ}|  | d¡d¡}|  t|ƒ¡ |  | d¡d¡}|  t|ƒ¡ |  |¡ d S )Ns   r   ÚshiftInÚshiftOutr£   r¤   r   r   r   ÚtestShiftingµ  ó   
z(ClientControlSequencesTests.testShiftingc                 C   r®   )Ns   NOr   ÚsingleShift2ÚsingleShift3r£   r¤   r   r   r   ÚtestSingleShiftsÀ  r²   z,ClientControlSequencesTests.testSingleShiftsc                 C   r®   )Ns   =>r   ZapplicationKeypadModeZnumericKeypadModer£   r¤   r   r   r   ÚtestKeypadModeË  r²   z*ClientControlSequencesTests.testKeypadModec                 C   r®   )Ns   78r   Z
saveCursorZrestoreCursorr£   r¤   r   r   r   Ú
testCursorÖ  r²   z&ClientControlSequencesTests.testCursorc                 C   sD   | j  d¡ t| jƒ}|  | d¡d¡}|  t|ƒ¡ |  |¡ d S )Ns   cr   Úresetr£   r¤   r   r   r   Ú	testResetá  s
   
z%ClientControlSequencesTests.testResetc                 C   s„   | j  d¡ t| jƒ}|  | d¡d¡}|  t|ƒ¡ |  | d¡d¡}|  t|ƒ¡ |  | d¡d¡}|  t|ƒ¡ |  |¡ d S )Ns   DMEr   ÚindexÚreverseIndexÚnextLiner£   r¤   r   r   r   Ú	testIndexé  s   
z%ClientControlSequencesTests.testIndexc              	   C   sØ   | j  dd dd„ tjtjtjfD ƒ¡ d ¡ | j  dd dd„ tjtjtjfD ƒ¡ d ¡ t| jƒ}|  	| 
d¡d	tjtjtjgf¡}|  t|ƒ¡ |  	| 
d¡d
tjtjtjgf¡}|  t|ƒ¡ |  |¡ d S )Nr‚   ó   ;c                 s   ó   � | ]}d |f V  qdS ©s   %dNr   ©r0   Úmr   r   r   r›   ú  ó   € z8ClientControlSequencesTests.testModes.<locals>.<genexpr>ó   hc                 s   r¿   rÀ   r   rÁ   r   r   r   r›   ÿ  rÃ   ó   lr   ÚsetModesÚ
resetModes)rq   rž   r‡   r   ÚKAMÚIRMÚLNMr!   rp   rf   rn   r{   r¤   r   r   r   Ú	testModes÷  s0   ÿþÿÿþÿ
ÿÿz%ClientControlSequencesTests.testModesc                 C   sp   | j  d¡ t| jƒ}dD ]}|  | d¡|¡}|  t|ƒ¡ q|  | d¡dd¡}|  t|ƒ¡ |  |¡ d S )Ns   [K[1K[2K[J[1J[2J[3P)ÚeraseToLineEndÚeraseToLineBeginningÚ	eraseLineÚeraseToDisplayEndÚeraseToDisplayBeginningÚeraseDisplayr   ÚdeleteCharacter)rj   r£   )rT   r€   rŸ   rd   r   r   r   ÚtestErasure  s   
z'ClientControlSequencesTests.testErasurec                 C   óR   | j  d¡ t| jƒ}dD ]}|  | d¡d|f¡}|  t|ƒ¡ q|  |¡ d S )Ns   [M[3M©r^   rj   r   Ú
deleteLiner£   ©rT   r€   Úargrd   r   r   r   ÚtestLineDeletion"  ó   
z,ClientControlSequencesTests.testLineDeletionc                 C   rÔ   )Ns   [L[3LrÕ   r   Ú
insertLiner£   r×   r   r   r   ÚtestLineInsertion+  rÚ   z-ClientControlSequencesTests.testLineInsertionc                 C   sX   dt | jƒd< | j d¡ |  | j ¡ d¡ t| jƒ}|  | 	d¡d¡}|  |d¡ d S )N)rl   é   ÚreportCursorPositions   [6ns   [7;8Rr   )
r%   rp   rq   rž   r_   ro   Úvaluer!   rf   rn   r¤   r   r   r   ÚtestCursorPosition4  s   
z.ClientControlSequencesTests.testCursorPositionc                 C   sN   t | jƒ}| j d¡ |  | d¡dd¡ | j d¡ |  | d¡dd¡ dS )z®
        Contiguous non-control bytes are passed to a single call to the
        C{write} method of the terminal to which the L{ClientProtocol} is
        connected.
        ó   ar   Úwrite)rá   ó   bc)rã   N)r!   rp   rq   rž   rf   rn   )rT   r€   r   r   r   Útest_applicationDataBytes?  s
   
z5ClientControlSequencesTests.test_applicationDataBytesc                 C   sR   t | jƒ}| j |¡ |r| j| d¡g| d¡¢R Ž  |s|  |d|›�¡ d S )Nr   zNo other calls should happen: )r!   rp   rq   rž   rf   rn   r{   )rT   ÚdataZcallsr€   r   r   r   Ú_applicationDataTestK  s   
ÿz0ClientControlSequencesTests._applicationDataTestc                 C   ó   |   dddg¡ dS )z£
        Application data bytes followed by a shift-in command are passed to a
        call to C{write} before the terminal's C{shiftIn} method is called.
        s   ab©râ   )s   ab)r¯   N©ræ   r•   r   r   r   Ú test_shiftInAfterApplicationDataR  ó   z<ClientControlSequencesTests.test_shiftInAfterApplicationDatac                 C   rç   )z¥
        Application data bytes followed by a shift-out command are passed to a
        call to C{write} before the terminal's C{shiftOut} method is called.
        s   abrè   )r°   Nré   r•   r   r   r   Ú!test_shiftOutAfterApplicationDataY  rë   z=ClientControlSequencesTests.test_shiftOutAfterApplicationDatac                 C   rç   )z¹
        Application data bytes followed by a cursor-backward command are passed
        to a call to C{write} before the terminal's C{cursorBackward} method is
        called.
        s   abrè   )ÚcursorBackwardNré   r•   r   r   r   Ú'test_cursorBackwardAfterApplicationData`  s   zCClientControlSequencesTests.test_cursorBackwardAfterApplicationDatac                 C   s,   |   dddg¡ |   ddddgffg¡ dS )z¸
        Application data bytes followed by an escape character are passed to a
        call to C{write} before the terminal's handler method for the escape is
        called.
        s   abDrè   )rº   s   ab[4hrÆ   r)   Nré   r•   r   r   r   Útest_escapeAfterApplicationDatah  s   ÿz;ClientControlSequencesTests.test_escapeAfterApplicationDataN)rZ   r[   r\   r˜   r    r¥   r¦   r­   r±   rµ   r¶   r·   r¹   r½   rË   rÓ   rÙ   rÜ   rà   rä   ræ   rê   rì   rî   rï   r   r   r   r   r”   d  s.    		r”   c                   @   s   e Zd ZdZeddƒZeeddƒ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Z d9d:„ Z!d;d<„ Z"d=d>„ Z#d?d@„ Z$dAdB„ Z%dCS )DÚServerProtocolOutputTestszh
    Tests for the bytes L{ServerProtocol} writes to its transport when its
    methods are called.
    r^   é   rk   c                 C   s"   t ƒ | _tƒ | _| j | j¡ d S r   )r   Úprotocolr   ro   rm   r•   r   r   r   r˜   †  s   zServerProtocolOutputTests.setUpc                 C   ó0   | j  d¡ |  | j ¡ | jd tjj ¡ dS )z�
        L{ServerProtocol.cursorUp} writes the control sequence
        ending with L{CSFinalByte.CUU} to its transport.
        r^   ó   1N)rò   ZcursorUpr_   ro   rß   rM   r<   r>   r•   r   r   r   Útest_cursorUp‹  ó   ÿz'ServerProtocolOutputTests.test_cursorUpc                 C   ró   )zƒ
        L{ServerProtocol.cursorDown} writes the control sequence
        ending with L{CSFinalByte.CUD} to its transport.
        r^   rô   N)rò   Z
cursorDownr_   ro   rß   rM   r<   r?   r•   r   r   r   Útest_cursorDown•  rö   z)ServerProtocolOutputTests.test_cursorDownc                 C   ró   )z†
        L{ServerProtocol.cursorForward} writes the control sequence
        ending with L{CSFinalByte.CUF} to its transport.
        r^   rô   N)rò   ZcursorForwardr_   ro   rß   rM   r<   r@   r•   r   r   r   Útest_cursorForwardŸ  rö   z,ServerProtocolOutputTests.test_cursorForwardc                 C   ró   )z‡
        L{ServerProtocol.cursorBackward} writes the control sequence
        ending with L{CSFinalByte.CUB} to its transport.
        r^   rô   N)rò   rí   r_   ro   rß   rM   r<   rA   r•   r   r   r   Útest_cursorBackward©  rö   z-ServerProtocolOutputTests.test_cursorBackwardc                 C   s2   | j  dd¡ |  | j ¡ | jd tjj ¡ dS )zµ
        L{ServerProtocol.cursorPosition} writes a control sequence
        ending with L{CSFinalByte.CUP} and containing the expected
        coordinates to its transport.
        r   s   1;1N)rò   ZcursorPositionr_   ro   rß   rM   r<   rB   r•   r   r   r   Útest_cursorPosition³  s   ÿz-ServerProtocolOutputTests.test_cursorPositionc                 C   ó*   | j  ¡  |  | j ¡ | jtjj ¡ dS )z±
        L{ServerProtocol.cursorHome} writes a control sequence ending
        with L{CSFinalByte.CUP} and no parameters, so that the client
        defaults to (1, 1).
        N)rò   Z
cursorHomer_   ro   rß   rM   r<   rB   r•   r   r   r   Útest_cursorHome¾  ó   
 z)ServerProtocolOutputTests.test_cursorHomec                 C   s,   | j  ¡  |  | j ¡ | jtddƒ ¡ dS )z´
        L{ServerProtocol.index} writes the control sequence ending in
        the 8-bit code table coordinates 4, 4.

        Note that ECMA48 5th Edition removes C{IND}.
        r)   N)rò   rº   r_   ro   rß   ÚESCr.   r•   r   r   r   Ú
test_indexÇ  s   
ÿz$ServerProtocolOutputTests.test_indexc                 C   rû   )zt
        L{ServerProtocol.reverseIndex} writes the control sequence
        ending in the L{C1SevenBit.RI}.
        N)rò   r»   r_   ro   rß   rþ   rK   rN   r•   r   r   r   Útest_reverseIndexÓ  ó   
 z+ServerProtocolOutputTests.test_reverseIndexc                 C   s    | j  ¡  |  | j ¡ d¡ dS )zM
        L{ServerProtocol.nextLine} writes C{"
"} to its transport.
        s   
N)rò   r¼   r_   ro   rß   r•   r   r   r   Útest_nextLineÛ  s   
z'ServerProtocolOutputTests.test_nextLinec                 C   óP   t jt jt jg}| j |¡ |  | j ¡ | j	d 
dd„ |D ƒ¡ tjj ¡ dS )zš
        L{ServerProtocol.setModes} writes a control sequence
        containing the requested modes and ending in the
        L{CSFinalByte.SM}.
        r¾   c                 s   r¿   rÀ   r   rÁ   r   r   r   r›   ð  rÃ   z:ServerProtocolOutputTests.test_setModes.<locals>.<genexpr>N)r   rÈ   rÉ   rÊ   rò   rÆ   r_   ro   rß   rM   r‡   r<   rC   ©rT   Z
modesToSetr   r   r   Útest_setModeså  s   ÿþþz'ServerProtocolOutputTests.test_setModesc                 C   r  )zª
        L{ServerProtocol.setPrivatesModes} writes a control sequence
        containing the requested private modes and ending in the
        L{CSFinalByte.SM}.
        r¾   c                 s   r¿   rÀ   r   rÁ   r   r   r   r›     rÃ   zAServerProtocolOutputTests.test_setPrivateModes.<locals>.<genexpr>N)r   ÚERRORZCOLUMNZORIGINrò   rÆ   r_   ro   rß   rM   r‡   r<   rC   )rT   ZprivateModesToSetr   r   r   Útest_setPrivateModesô  s   ýÿþþz.ServerProtocolOutputTests.test_setPrivateModesc                 C   r  )zs
        L{ServerProtocol.resetModes} writes the control sequence
        ending in the L{CSFinalByte.RM}.
        r¾   c                 s   r¿   rÀ   r   rÁ   r   r   r   r›     rÃ   z<ServerProtocolOutputTests.test_resetModes.<locals>.<genexpr>N)r   rÈ   rÉ   rÊ   rò   rÇ   r_   ro   rß   rM   r‡   r<   rG   r  r   r   r   Útest_resetModes  s   ÿþþz)ServerProtocolOutputTests.test_resetModesc                 C   rû   )zp
        L{ServerProtocol.singleShift2} writes an escape sequence
        followed by L{C1SevenBit.SS2}
        N)rò   r³   r_   ro   rß   rþ   rK   rP   r•   r   r   r   Útest_singleShift2  r  z+ServerProtocolOutputTests.test_singleShift2c                 C   rû   )zp
        L{ServerProtocol.singleShift3} writes an escape sequence
        followed by L{C1SevenBit.SS3}
        N)rò   r´   r_   ro   rß   rþ   rK   rQ   r•   r   r   r   Útest_singleShift3  r  z+ServerProtocolOutputTests.test_singleShift3c                 C   sB   | j  ttƒttƒ¡ |  | j ¡ | jdttf  t	j
j ¡ dS )z«
        L{ServerProtocol.selectGraphicRendition} writes a control
        sequence containing the requested attributes and ending with
        L{CSFinalByte.SGR}
        s   %d;%dN)rò   ZselectGraphicRenditionÚstrr   r   r_   ro   rß   rM   r<   rI   r•   r   r   r   Útest_selectGraphicRendition%  s
   þz5ServerProtocolOutputTests.test_selectGraphicRenditionc                 C   rû   )zz
        L{ServerProtocol.horizontalTabulationSet} writes the escape
        sequence ending in L{C1SevenBit.HTS}
        N)rò   ZhorizontalTabulationSetr_   ro   rß   rþ   rK   rL   r•   r   r   r   Útest_horizontalTabulationSet1  r  z6ServerProtocolOutputTests.test_horizontalTabulationSetc                 C   rû   )a  
        L{ServerProtocol.eraseToLineEnd} writes the control sequence
        sequence ending in L{CSFinalByte.EL} and no parameters,
        forcing the client to default to 0 (from the active present
        position's current location to the end of the line.)
        N)rò   rÌ   r_   ro   rß   rM   r<   rE   r•   r   r   r   Útest_eraseToLineEnd9  ó   
 z-ServerProtocolOutputTests.test_eraseToLineEndc                 C   ó.   | j  ¡  |  | j ¡ | jd tjj ¡ dS )a	  
        L{ServerProtocol.eraseToLineBeginning} writes the control
        sequence sequence ending in L{CSFinalByte.EL} and a parameter
        of 1 (from the beginning of the line up to and include the
        active present position's current location.)
        rô   N)rò   rÍ   r_   ro   rß   rM   r<   rE   r•   r   r   r   Útest_eraseToLineBeginningC  ó   
$z3ServerProtocolOutputTests.test_eraseToLineBeginningc                 C   r  )z¦
        L{ServerProtocol.eraseLine} writes the control
        sequence sequence ending in L{CSFinalByte.EL} and a parameter
        of 2 (the entire line.)
        r™   N)rò   rÎ   r_   ro   rß   rM   r<   rE   r•   r   r   r   Útest_eraseLineM  ó   
$z(ServerProtocolOutputTests.test_eraseLinec                 C   rû   )a  
        L{ServerProtocol.eraseToDisplayEnd} writes the control
        sequence sequence ending in L{CSFinalByte.ED} and no parameters,
        forcing the client to default to 0 (from the active present
        position's current location to the end of the page.)
        N)rò   rÏ   r_   ro   rß   rM   r<   rD   r•   r   r   r   Útest_eraseToDisplayEndV  r  z0ServerProtocolOutputTests.test_eraseToDisplayEndc                 C   r  )a  
        L{ServerProtocol.eraseToDisplayBeginning} writes the control
        sequence sequence ending in L{CSFinalByte.ED} a parameter of 1
        (from the beginning of the page up to and include the active
        present position's current location.)
        rô   N)rò   rÐ   r_   ro   rß   rM   r<   rD   r•   r   r   r   Útest_eraseToDisplayBeginning`  r  z6ServerProtocolOutputTests.test_eraseToDisplayBeginningc                 C   r  )z¤
        L{ServerProtocol.eraseDisplay} writes the control sequence
        sequence ending in L{CSFinalByte.ED} a parameter of 2 (the
        entire page)
        r™   N)rò   rÑ   r_   ro   rß   rM   r<   rD   r•   r   r   r   Útest_eraseToDisplayj  r  z-ServerProtocolOutputTests.test_eraseToDisplayc                 C   ró   )z®
        L{ServerProtocol.deleteCharacter} writes the control sequence
        containing the number of characters to delete and ending in
        L{CSFinalByte.DCH}
        r)   ó   4N)rò   rÒ   r_   ro   rß   rM   r<   r=   r•   r   r   r   Útest_deleteCharacters  s   ÿz.ServerProtocolOutputTests.test_deleteCharacterc                 C   ró   )z£
        L{ServerProtocol.insertLine} writes the control sequence
        containing the number of lines to insert and ending in
        L{CSFinalByte.IL}
        rk   ó   5N)rò   rÛ   r_   ro   rß   rM   r<   rF   r•   r   r   r   Útest_insertLine~  ó   $z)ServerProtocolOutputTests.test_insertLinec                 C   ró   )z£
        L{ServerProtocol.deleteLine} writes the control sequence
        containing the number of lines to delete and ending in
        L{CSFinalByte.DL}
        rl   ó   6N)rò   rÖ   r_   ro   rß   rM   r<   rH   r•   r   r   r   Útest_deleteLine‡  r  z)ServerProtocolOutputTests.test_deleteLinec                 C   s*   | j  ¡  |  | j ¡ | jd d ¡ dS )z¶
        With no arguments, L{ServerProtocol.setScrollRegion} writes a
        control sequence with no parameters, but a parameter
        separator, and ending in C{b'r'}.
        r¾   ó   rN©rò   r¡   r_   ro   rß   rM   r•   r   r   r   Útest_setScrollRegionNoArgs�  rý   z4ServerProtocolOutputTests.test_setScrollRegionNoArgsc                 C   ó.   | j jdd� |  | j ¡ | jd d ¡ dS )zÍ
        With just a value for its C{first} argument,
        L{ServerProtocol.setScrollRegion} writes a control sequence with
        that parameter, a parameter separator, and finally a C{b'r'}.
        r^   )Úfirsts   1;r  Nr   r•   r   r   r   Útest_setScrollRegionJustFirst™  ó    z7ServerProtocolOutputTests.test_setScrollRegionJustFirstc                 C   r"  )zÌ
        With just a value for its C{last} argument,
        L{ServerProtocol.setScrollRegion} writes a control sequence with
        a parameter separator, that parameter, and finally a C{b'r'}.
        r^   )Úlasts   ;1r  Nr   r•   r   r   r   Útest_setScrollRegionJustLast¢  r%  z6ServerProtocolOutputTests.test_setScrollRegionJustLastc                 C   s0   | j jddd� |  | j ¡ | jd d ¡ dS )zæ
        When given both C{first} and C{last}
        L{ServerProtocol.setScrollRegion} writes a control sequence with
        the first parameter, a parameter separator, the last
        parameter, and finally a C{b'r'}.
        r^   ri   )r#  r&  s   1;2r  Nr   r•   r   r   r   Ú test_setScrollRegionFirstAndLast«  s    z:ServerProtocolOutputTests.test_setScrollRegionFirstAndLastc                 C   r  )zÝ
        L{ServerProtocol.reportCursorPosition} writes a control
        sequence ending in L{CSFinalByte.DSR} with a parameter of 6
        (the Device Status Report returns the current active
        position.)
        r  N)rò   rÞ   r_   ro   rß   rM   r<   rJ   r•   r   r   r   Útest_reportCursorPositionµ  s   
ÿz3ServerProtocolOutputTests.test_reportCursorPositionN)&rZ   r[   r\   r6   r.   rþ   rM   r˜   rõ   r÷   rø   rù   rú   rü   rÿ   r   r  r  r  r  r	  r
  r  r  r  r  r  r  r  r  r  r  r  r!  r$  r'  r(  r)  r   r   r   r   rð   z  sF    




	


	

						
rð   )3ÚtextwrapÚtypingr   r   Z
constantlyr   r   Ztwisted.conch.insults.insultsr   r   r   r	   r
   r   r   r   r   r   r   r   r   Ztwisted.internet.protocolr   Ztwisted.internet.testingr   Ztwisted.python.compatr   Ztwisted.trialr   r   r!   r%   r(   ÚobjectrR   r.   r;   Údedentr<   rK   r   r]   rw   rg   ZTestCasery   r~   r�   rˆ   r”   rð   r   r   r   r   Ú<module>   s˜   <ïÿê%ðÿë""#  