
    tf}                     J   d dl 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mZ d dlmZ d	 Zd
 Zd Zd Z  e!            Z"d Z#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 j%        d!          "          Z& e$d#ddd$gdd%gd&d'gd(d)gdd*gd+d,gd-d.gd/d0gd1d2gd3dgd4d5gd6d7gd8d9gd:d;gd<d=gd>d?gg e j%        d@          "          Z' G dA dB          Z( G dC dD          Z)dEZ* G dF dGe)          Z+[* G dH dIe+ej,                  Z- G dJ dKe+ej,                  Z. G dL dMe+ej,                  Z/ G dN dOe+ej,                  Z0 G dP dQej,        e)          Z1 G dR dSej,                  Z2dS )T    N)OptionalType)BLINKCS_ALTERNATECS_ALTERNATE_SPECIAL
CS_DRAWINGCS_UKCS_USG0G1	UNDERLINEClientProtocolServerProtocolmodesprivateModes)Protocol)StringTransport)	iterbytes)ValueConstantValues)unittestc                 R    t          t          |                               |          S N)superMock__getattribute__)mocknames     ^/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/conch/test/test_insults.py_getattrr       s     t--d333    c                 "    t          | d          S )Noccurrencesr    r   s    r   r#   r#   "   s    D-(((r!   c                 "    t          | d          S )Nmethodsr$   r%   s    r   r'   r'   &   s    D)$$$r!   c                 J    t          |                               |           d S r   )r#   append)r   objs     r   _appendr+   *   s$    S!!!!!r!   c                 H    t          t          | dz  |z  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).
       )bytes	bytearray)columnrows     r   _ecmaCodeTableCoordinater2   1   s&    " Vq[C/011222r!   c                 r    fdt          |          D             }||d<   t          | t          f|          S )Nc           
          i | ]=\  }}t          |          D ](\  }}||t          t          |z   |                    )>S  )	enumerater   r2   ).0jr1   ir   	colOffsets        r   
<dictcomp>z/_makeControlFunctionSymbols.<locals>.<dictcomp>J   sm       As ~~  At	m4Q]AFFGG   r!   __doc__)r6   typer   )r   r:   namesdocattrss    `   r   _makeControlFunctionSymbolsrA   E   sS    
   &&  E E)vi'''r!   CSFinalByter-   )ICHDCHHPA)CUUSSEHPR)CUDCPRREP)CUFSUDA)CUBSDVPA)CNLNPVPR)CPLPPHVP)CHACTCTBC)CUPECHSM)CHTCVTMC)EDCBTHPB)ELSRSVPB)ILPTXRM)DLSDSSGR)EFSIMDDSR)EAN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}
    )r:   r>   r?   
C1SevenBitDCSPU1BPHPU2NBHSTSCCHNELMWSSASPAESAEPAHTSSOSHTJVTSSCIPLDCSIPLUSTRIOSCSS2PMSS3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                   *    e Zd ZeZdefdZd Zd ZdS )r   Nc                 N    g | _         |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'   r   s      r   __init__zMock.__init__   s>    
 ?G'))#2D    *)r!   c                 |    t          | d          }|t          u rt                      }t          | d|||f           |S )Nr   __call__)r    r   r   r+   )r   akwreturnValues       r   r   zMock.__call__   sE    t%677'!!&&Kz;26777r!   c                     t          | d          }||v rt          ||                   }nt                      }t          | ||f           |S )Nr'   )r   )r    r   r+   )r   r   r'   	attrValues       r   r   zMock.__getattribute__   sT    4++7??WT];;;IIItY'(((r!   )__name__
__module____qualname__r   r   r   r   r   r5   r!   r   r   r      sP        O#W 
3 
3 
3 
3      r!   r   c                       e Zd Zdi fdZdS )	MockMixinr5   c                 L   |\  }}|                      ||           |                      t          t          |                    d           t          |          \  \  }}}	}
|                      |d           |                      |	|           |                      |
|           |S )N   r   )assertEquallenr#   )r   
occurrence
methodNameexpectedPositionalArgsexpectedKeywordArgsattrr   callresultargsr   s              r   
assertCallzMockMixin.assertCall   s      
dz***[..//333%0%6%6"	!$bz***56660111r!   N)r   r   r   r   r5   r!   r   r   r      s.        =?UW
 
 
 
 
 
r!   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                   r    e Zd ZU dZeee                  ed<   dD ]\  ZZ	 e
eee	dz             [[	d ZdS )ByteGroupingsMixinNprotocolFactory))Pairs   )Triples   )Quadsr-   )Quints   )Sexes   )	groupNamebytesPerc                     |                      t          |                              d          d|f          }|                     t          |          g            d S )Nr   makeConnection)r   r#   popr   )r   	transportprotoparserr   s        r   verifyResultsz ByteGroupingsMixin.verifyResults   sT    U!3!3!7!7!:!:<LviXXV,,b11111r!   )r   r   r   r   r   r   r   __annotations__wordnexec_byteGroupingTestTemplater   r5   r!   r   r   r      s}         04OXd8n-444 M Ma 	&t)K)KKLLLLa2 2 2 2 2r!   r   c                       e Zd ZeZdZd ZdS )ServerArrowKeysTestss   [A[B[C[Dc                 v   t                               | |||           |j        |j        |j        |j        fD ]^}|                     t          |                              d          d|d f          }| 	                    t          |          g            _| 
                    t          |                     d S )Nr   keystrokeReceived)r   r   UP_ARROW
DOWN_ARROWRIGHT_ARROW
LEFT_ARROWr   r#   r   r   assertFalse)r   r   r   r   arrowr   s         r   r   z"ServerArrowKeysTests.verifyResults   s    ((y%HHH O	
 		6 		6E __E""&&q))+> F [00"5555U++,,,,,r!   Nr   r   r   r   r   
TEST_BYTESr   r5   r!   r   r   r      s/        $O -J- - - - -r!   r   c                       e Zd ZeZdZd ZdS )PrintableCharactersTestss   abc123ABC!@#abc123c                 R   t                               | |||           t          d          D ]^}|                     t	          |                              d          d|d f          }|                     t	          |          g            _t          d          D ]c}|                     t	          |                              d          d||j        f          }|                     t	          |          g            dt	          |          }|                     ||d           d S )Ns   abc123ABC!@#r   r   s   abc123z should have been [])	r   r   r   r   r#   r   r   ALTr   )r   r   r   r   charr   occss          r   r   z&PrintableCharactersTests.verifyResults  s/   ((y%HHHo.. 	6 	6D__E""&&q))+>t F [00"5555i(( 	6 	6D__E""&&q))+>vz@R F [00"55555!!$>>>?????r!   Nr   r5   r!   r   r   r     s4        $O
 ?J@ @ @ @ @r!   r   c                       e Zd ZdZeZg ZdD ]Ze                    dez              d	                    e          Z
[[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~   [r!   c                    t                               | |||           t          dd          D ]r}t          |d|fz            }|                     t          |                              d          d|d f          }|                     t          |          g            s|                     t          |                     d S )Nr      zF%dr   r   )	r   r   rangegetattrr   r#   r   r   r   )r   r   r   r   funcNumfuncArgr   s          r   r   z%ServerFunctionKeysTests.verifyResults;  s    ((y%HHHQ|| 	6 	6Gfewj&899G__E""&&q))+>$ F [00"5555U++,,,,,r!   N)r   r   r   r<   r   r   byteList	byteCodesr)   joinr   r   r5   r!   r   r   r   #  sv        CC$OH . .	 	9,----(##J)- - - - -r!   r   c                   R    e Zd ZeZdZdZdZdZeez   ez   ez   ez   ez   Z	[[[[d Z
dS )ClientCursorMovementTestss   [2Bs   [4Cs   [As   [2Dc                 P   t                               | |||           dD ]c\  }}|                     t          |                              d          d|z   |f          }|                     t          |          g            d|                     t          |                     d S )N))Downr   )Forwardr-   Upr   Backwardr   r   r   r   cursor)r   r   r   r#   r   r   r   )r   r   r   r   methodcountr   s          r   r   z'ClientCursorMovementTests.verifyResultsQ  s    ((y%HHH
 	6 	6MFE __E""&&q))8f+<uh F [00"5555U++,,,,,r!   N)r   r   r   r   r   d2r4u1l2r   r   r5   r!   r   r   r   F  sa        $O	B	B	B	Bb2"R'",J
BB- - - - -r!   r   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )ClientControlSequencesTestsc                     t                       _        t                       _        t	           fd           _          j        _         j                             j                                        t           j                  
                    d          d j        f          }                     t          |                     d S )Nc                       j         S r   )r   r   s   r   <lambda>z3ClientControlSequencesTests.setUp.<locals>.<lambda>g  s	    TZ r!   r   r   )r   r   r   r   r   r   factoryr   r   r#   r   r   )r   r   s   ` r   setUpz!ClientControlSequencesTests.setUpd  s    (**VV
$%7%7%7%788"""4>222
##''**,<t{n
 
 	V,,-----r!   c                    | j                             d                    d t          d          D                                  t	          | j                  }dD ]W}dD ]R}|                     |                    d          d|z   |f          }|                     t	          |                     SX|                     |           d S )Nr!   c              3   0   K   | ]}d D ]}d|z   |z   V  dS ))r!      2s   20s   200r   Nr5   )r7   chr   s      r   	<genexpr>zBClientControlSequencesTests.testSimpleCardinals.<locals>.<genexpr>q  sV        3   1r!      r!   s   BACD)r   r   r   r   )r   r         r   r   )	r   dataReceivedr   r   r#   r   r   r   r   )r   r   methr   r   s        r   testSimpleCardinalsz/ClientControlSequencesTests.testSimpleCardinalso  s      HH  #G,,    	
 	
 	
 4:&&9 	6 	6D( 6 6!hoxPP  V!4!455556 	r!   c                    | j                             d           t          | j                  }|                     |                    d          dd          }|                     t          |                     |                     |                    d          dd          }|                     t          |                     |                     |           d S )Ns
   [5;22r[rr   setScrollRegion)r      )NNr   r  r#   r   r   r   r   r   r   r   s      r   testScrollRegionz,ClientControlSequencesTests.testScrollRegion  s      !45554:&&!.?IIV,,---!.?NNV,,---r!   c                    | 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   doubleHeightLine)T)FsingleWidthLinedoubleWidthLiner  r  s      r   testHeightAndWidthz.ClientControlSequencesTests.testHeightAndWidth  s.     !<===4:&&!.@'JJV,,---!.@(KKV,,---!.?@@V,,---!.?@@V,,---r!   c                    | j                             d                    d t          d          D                                  t	          | j                  }t          t          fD ]s}t          t          t          t          t          fD ]P}|                     |                    d          d||f          }|                     t	          |                     Qt|                     |           d S )Nr!   c                 l    g | ]0d                      fdt          d          D                       1S )r!   c                      g | ]
}d z   |z   S )   r5   )r7   r   gs     r   
<listcomp>zKClientControlSequencesTests.testCharacterSet.<locals>.<listcomp>.<listcomp>  s!    KKK!gkAoKKKr!   s   AB012)r   r   )r7   r  s    @r   r  z@ClientControlSequencesTests.testCharacterSet.<locals>.<listcomp>  sR        HHKKKKy7J7JKKKLL  r!   s   ()r   selectCharacterSet)r   r  r   r   r#   r   r   r   r	   r
   r   r   r   r   r   r   )r   r   whichcharsetr   s        r   testCharacterSetz,ClientControlSequencesTests.testCharacterSet  s     HH &u--   	
 	
 	
 4:&&"X 	6 	6E$ 
6 
6 HHQKK!57G    V!4!45555
6 	r!   c                    | j                             d           t          | j                  }|                     |                    d          d          }|                     t          |                     |                     |                    d          d          }|                     t          |                     |                     |           d S )Ns   r   shiftInshiftOutr  r  s      r   testShiftingz(ClientControlSequencesTests.testShifting  s      ---4:&&!i88V,,---!j99V,,---r!   c                    | j                             d           t          | j                  }|                     |                    d          d          }|                     t          |                     |                     |                    d          d          }|                     t          |                     |                     |           d S )Ns   NOr   singleShift2singleShift3r  r  s      r   testSingleShiftsz,ClientControlSequencesTests.testSingleShifts  s      ///4:&&!n==V,,---!n==V,,---r!   c                    | j                             d           t          | j                  }|                     |                    d          d          }|                     t          |                     |                     |                    d          d          }|                     t          |                     |                     |           d S )Ns   =>r   applicationKeypadModenumericKeypadModer  r  s      r   testKeypadModez*ClientControlSequencesTests.testKeypadMode  s      ///4:&&!.EFFV,,---!.ABBV,,---r!   c                    | j                             d           t          | j                  }|                     |                    d          d          }|                     t          |                     |                     |                    d          d          }|                     t          |                     |                     |           d S )Ns   78r   
saveCursorrestoreCursorr  r  s      r   
testCursorz&ClientControlSequencesTests.testCursor  s      ///4:&&!l;;V,,---!o>>V,,---r!   c                 "   | j                             d           t          | j                  }|                     |                    d          d          }|                     t          |                     |                     |           d S )Ns   cr   resetr  r  s      r   	testResetz%ClientControlSequencesTests.testReset  sz      ***4:&&!g66V,,---r!   c                 N   | j                             d           t          | j                  }|                     |                    d          d          }|                     t          |                     |                     |                    d          d          }|                     t          |                     |                     |                    d          d          }|                     t          |                     |                     |           d S )Ns   DMEr   indexreverseIndexnextLiner  r  s      r   	testIndexz%ClientControlSequencesTests.testIndex  s      !34444:&&!g66V,,---!n==V,,---!j99V,,---r!   c           	         | j                             dd                    d t          j        t          j        t          j        fD                       z   dz              | j                             dd                    d t          j        t          j        t          j        fD                       z   dz              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              3   "   K   | ]
}d |fz  V  dS s   %dNr5   r7   ms     r   r  z8ClientControlSequencesTests.testModes.<locals>.<genexpr>  (      PPPPPPPPr!      hc              3   "   K   | ]
}d |fz  V  dS r8  r5   r9  s     r   r  z8ClientControlSequencesTests.testModes.<locals>.<genexpr>  r;  r!      lr   setModes
resetModes)r   r  r   r   KAMIRMLNMr#   r   r   r   r   r  s      r   	testModesz%ClientControlSequencesTests.testModes  s     iiPPuy%)UY.OPPPPPQ	
 	
 	

 	  iiPPuy%)UY.OPPPPPQ	
 	
 	

 4:&&HHQKKuy%)UY&G%I
 
 	V,,---HHQKKEIuy(I'K
 
 	V,,---r!   c                    | j                             d           t          | j                  }dD ]M}|                     |                    d          |          }|                     t          |                     N|                     |                    d          dd          }|                     t          |                     |                     |           d S )Ns   [K[1K[2K[J[1J[2J[3P)eraseToLineEnderaseToLineBeginning	eraseLineeraseToDisplayEnderaseToDisplayBeginningeraseDisplayr   deleteCharacter)r   r  )r   r   r  r   s       r   testErasurez'ClientControlSequencesTests.testErasure  s      !STTT4:&&
 		2 		2D __TXXa[[$77F[001111!.?FFV,,---r!   c                 0   | j                             d           t          | j                  }dD ]O}|                     |                    d          d|f          }|                     t          |                     P|                     |           d S )Ns   [M[3Mr   r   r   
deleteLiner  r   r   argr   s       r   testLineDeletionz,ClientControlSequencesTests.testLineDeletion!        !12224:&& 	2 	2C__TXXa[[,GGF[001111r!   c                 0   | j                             d           t          | j                  }dD ]O}|                     |                    d          d|f          }|                     t          |                     P|                     |           d S )Ns   [L[3LrO  r   
insertLiner  rQ  s       r   testLineInsertionz-ClientControlSequencesTests.testLineInsertion*  rT  r!   c                 h   dt          | j                  d<   | j                            d           |                     | j                                        d           t          | j                  }|                     |	                    d          d          }|                     |d           d S )N)r      reportCursorPositions   [6ns   [7;8Rr   )
r'   r   r   r  r   r   valuer#   r   r   r  s      r   testCursorPositionz.ClientControlSequencesTests.testCursorPosition3  s    6<
23  ,,,--//>>>4:&&!.DEE 	(((((r!   c                 >   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#   r   r   r  r   r   )r   r   s     r   test_applicationDataBytesz5ClientControlSequencesTests.test_applicationDataBytes>  s     4:&&  &&&Wg666  '''Wh77777r!   c                    t          | j                  }| j                            |           |r6 | j        |                    d          g|                    d          R   |6|                     |d|           d S )Nr   zNo other calls should happen: )r#   r   r   r  r   r   r   )r   datacallsr   s       r   _applicationDataTestz0ClientControlSequencesTests._applicationDataTestJ  s    4:&&  &&& 	8DODHHQKK7%))A,,7777  	8HHHIIIIIr!   c                 6    |                      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re  r   s    r    test_shiftInAfterApplicationDataz<ClientControlSequencesTests.test_shiftInAfterApplicationDataQ  s&    
 	!!).A<-PQQQQQr!   c                 6    |                      dddg           dS )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rg  )r  Nrh  r   s    r   !test_shiftOutAfterApplicationDataz=ClientControlSequencesTests.test_shiftOutAfterApplicationDataX  s&    
 	!!).A=-QRRRRRr!   c                 6    |                      dddg           dS )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rg  )cursorBackwardNrh  r   s    r   'test_cursorBackwardAfterApplicationDatazCClientControlSequencesTests.test_cursorBackwardAfterApplicationData_  s'     	!!).ACV-WXXXXXr!   c                 n    |                      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Drg  )r1  s   ab[4hr?  r-   Nrh  r   s    r   test_escapeAfterApplicationDataz;ClientControlSequencesTests.test_escapeAfterApplicationDatag  sX     	!!*/BJ.OPPP 	!!.qcV0DE	
 	
 	
 	
 	
r!   N)r   r   r   r   r  r  r  r  r   r$  r(  r,  r/  r4  rD  rM  rS  rW  r\  ra  re  ri  rk  rn  rp  r5   r!   r   r   r   c  sj       	. 	. 	.   	 	 	  "  2	 	 		 	 		 	 		 	 	      0  &    	) 	) 	)
8 
8 
8J J JR R RS S SY Y Y
 
 
 
 
r!   r   c                      e Zd ZdZ edd          Ze edd          z   Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$S )%ServerProtocolOutputTestszh
    Tests for the bytes L{ServerProtocol} writes to its transport when its
    methods are called.
    r      r   c                     t                      | _        t                      | _        | j                            | j                   d S r   )r   protocolr   r   r   r   s    r   r   zServerProtocolOutputTests.setUp  s:    &(((**$$T^44444r!   c                     | j                             d           |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.cursorUp} writes the control sequence
        ending with L{CSFinalByte.CUU} to its transport.
        r      1N)ru  cursorUpr   r   r[  r   rB   rF   r   s    r   test_cursorUpz'ServerProtocolOutputTests.test_cursorUp  s_    
 	q!!!N  ""DHtOko6K$K	
 	
 	
 	
 	
r!   c                     | j                             d           |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.cursorDown} writes the control sequence
        ending with L{CSFinalByte.CUD} to its transport.
        r   rw  N)ru  
cursorDownr   r   r[  r   rB   rI   r   s    r   test_cursorDownz)ServerProtocolOutputTests.test_cursorDown  s_    
 	  ###N  ""DHtOko6K$K	
 	
 	
 	
 	
r!   c                     | j                             d           |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.cursorForward} writes the control sequence
        ending with L{CSFinalByte.CUF} to its transport.
        r   rw  N)ru  cursorForwardr   r   r[  r   rB   rL   r   s    r   test_cursorForwardz,ServerProtocolOutputTests.test_cursorForward  s_    
 	##A&&&N  ""DHtOko6K$K	
 	
 	
 	
 	
r!   c                     | j                             d           |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.cursorBackward} writes the control sequence
        ending with L{CSFinalByte.CUB} to its transport.
        r   rw  N)ru  rm  r   r   r[  r   rB   rO   r   s    r   test_cursorBackwardz-ServerProtocolOutputTests.test_cursorBackward  s_    
 	$$Q'''N  ""DHtOko6K$K	
 	
 	
 	
 	
r!   c                     | j                             dd           |                     | j                                        | j        dz   t          j        j        z              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)ru  cursorPositionr   r   r[  r   rB   r[   r   s    r   test_cursorPositionz-ServerProtocolOutputTests.test_cursorPosition  sb     	$$Q***N  ""DHv$58M$M	
 	
 	
 	
 	
r!   c                     | j                                          |                     | j                                        | j        t          j        j        z              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)ru  
cursorHomer   r   r[  r   rB   r[   r   s    r   test_cursorHomez)ServerProtocolOutputTests.test_cursorHome  sN     	  """--//KO<Q1QRRRRRr!   c                     | j                                          |                     | j                                        | j        t          dd          z              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)ru  r1  r   r   r[  ESCr2   r   s    r   
test_indexz$ServerProtocolOutputTests.test_index  s_     	N  ""DH/G1/M/M$M	
 	
 	
 	
 	
r!   c                     | j                                          |                     | j                                        | j        t          j        j        z              dS )zt
        L{ServerProtocol.reverseIndex} writes the control sequence
        ending in the L{C1SevenBit.RI}.
        N)ru  r2  r   r   r[  r  rr   r   r   s    r   test_reverseIndexz+ServerProtocolOutputTests.test_reverseIndex  sN    
 	""$$$--//JM<O1OPPPPPr!   c                     | j                                          |                     | j                                        d           dS )zM
        L{ServerProtocol.nextLine} writes C{"
"} to its transport.
        s   
N)ru  r3  r   r   r[  r   s    r   test_nextLinez'ServerProtocolOutputTests.test_nextLine  sB     	   --//99999r!   c                 H   t           j        t           j        t           j        g}| j                            |           |                     | j                                        | j	        d
                    d |D                       z   t          j        j        z              dS )z
        L{ServerProtocol.setModes} writes a control sequence
        containing the requested modes and ending in the
        L{CSFinalByte.SM}.
        r6  c              3   "   K   | ]
}d |fz  V  dS r8  r5   r9  s     r   r  z:ServerProtocolOutputTests.test_setModes.<locals>.<genexpr>  (      99999999r!   N)r   rA  rB  rC  ru  r?  r   r   r[  r   r   rB   r]   r   
modesToSets     r   test_setModesz'ServerProtocolOutputTests.test_setModes  s     iEI6
z***N  ""Hii99j99999:n"#	
 	
 	
 	
 	
r!   c                 H   t           j        t           j        t           j        g}| j                            |           |                     | j                                        | j	        d
                    d |D                       z   t          j        j        z              dS )z
        L{ServerProtocol.setPrivatesModes} writes a control sequence
        containing the requested private modes and ending in the
        L{CSFinalByte.SM}.
        r6  c              3   "   K   | ]
}d |fz  V  dS r8  r5   r9  s     r   r  zAServerProtocolOutputTests.test_setPrivateModes.<locals>.<genexpr>  s(      @@@@@@@@r!   N)r   ERRORCOLUMNORIGINru  r?  r   r   r[  r   r   rB   r]   )r   privateModesToSets     r   test_setPrivateModesz.ServerProtocolOutputTests.test_setPrivateModes  s     

 	0111N  ""Hii@@.?@@@@@An"#	
 	
 	
 	
 	
r!   c                 H   t           j        t           j        t           j        g}| j                            |           |                     | j                                        | j	        d
                    d |D                       z   t          j        j        z              dS )zs
        L{ServerProtocol.resetModes} writes the control sequence
        ending in the L{CSFinalByte.RM}.
        r6  c              3   "   K   | ]
}d |fz  V  dS r8  r5   r9  s     r   r  z<ServerProtocolOutputTests.test_resetModes.<locals>.<genexpr>  r  r!   N)r   rA  rB  rC  ru  r@  r   r   r[  r   r   rB   ri   r  s     r   test_resetModesz)ServerProtocolOutputTests.test_resetModes  s    
 iEI6
  ,,,N  ""Hii99j99999:n"#	
 	
 	
 	
 	
r!   c                     | j                                          |                     | j                                        | j        t          j        j        z              dS )zp
        L{ServerProtocol.singleShift2} writes an escape sequence
        followed by L{C1SevenBit.SS2}
        N)ru  r"  r   r   r[  r  rr   r   r   s    r   test_singleShift2z+ServerProtocolOutputTests.test_singleShift2  N    
 	""$$$--//JN<P1PQQQQQr!   c                     | j                                          |                     | j                                        | j        t          j        j        z              dS )zp
        L{ServerProtocol.singleShift3} writes an escape sequence
        followed by L{C1SevenBit.SS3}
        N)ru  r#  r   r   r[  r  rr   r   r   s    r   test_singleShift3z+ServerProtocolOutputTests.test_singleShift3  r  r!   c                 0   | j                             t          t                    t          t                               |                     | j                                        | j        dt          t          fz  z   t          j
        j        z              dS )z
        L{ServerProtocol.selectGraphicRendition} writes a control
        sequence containing the requested attributes and ending with
        L{CSFinalByte.SGR}
        s   %d;%dN)ru  selectGraphicRenditionstrr   r   r   r   r[  r   rB   rl   r   s    r   test_selectGraphicRenditionz5ServerProtocolOutputTests.test_selectGraphicRendition$  sy     	,,SZZYHHHN  ""Hx5)"444{7LL	
 	
 	
 	
 	
r!   c                     | j                                          |                     | j                                        | j        t          j        j        z              dS )zz
        L{ServerProtocol.horizontalTabulationSet} writes the escape
        sequence ending in L{C1SevenBit.HTS}
        N)ru  horizontalTabulationSetr   r   r[  r  rr   r   r   s    r   test_horizontalTabulationSetz6ServerProtocolOutputTests.test_horizontalTabulationSet0  sN    
 	--///--//JN<P1PQQQQQr!   c                     | j                                          |                     | j                                        | j        t          j        j        z              dS )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)ru  rF  r   r   r[  r   rB   rd   r   s    r   test_eraseToLineEndz-ServerProtocolOutputTests.test_eraseToLineEnd8  sN     	$$&&&--//KN<P1PQQQQQr!   c                     | j                                          |                     | j                                        | j        dz   t          j        j        z              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.)
        rw  N)ru  rG  r   r   r[  r   rB   rd   r   s    r   test_eraseToLineBeginningz3ServerProtocolOutputTests.test_eraseToLineBeginningB  sR     	**,,,--//D;>CW1WXXXXXr!   c                     | j                                          |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.eraseLine} writes the control
        sequence sequence ending in L{CSFinalByte.EL} and a parameter
        of 2 (the entire line.)
        r   N)ru  rH  r   r   r[  r   rB   rd   r   s    r   test_eraseLinez(ServerProtocolOutputTests.test_eraseLineL  sR     	!!!--//D;>CW1WXXXXXr!   c                     | j                                          |                     | j                                        | j        t          j        j        z              dS )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)ru  rI  r   r   r[  r   rB   ra   r   s    r   test_eraseToDisplayEndz0ServerProtocolOutputTests.test_eraseToDisplayEndU  sN     	'')))--//KN<P1PQQQQQr!   c                     | j                                          |                     | j                                        | j        dz   t          j        j        z              dS )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.)
        rw  N)ru  rJ  r   r   r[  r   rB   ra   r   s    r   test_eraseToDisplayBeginningz6ServerProtocolOutputTests.test_eraseToDisplayBeginning_  sR     	--///--//D;>CW1WXXXXXr!   c                     | j                                          |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.eraseDisplay} writes the control sequence
        sequence ending in L{CSFinalByte.ED} a parameter of 2 (the
        entire page)
        r   N)ru  rK  r   r   r[  r   rB   ra   r   s    r   test_eraseToDisplayz-ServerProtocolOutputTests.test_eraseToDisplayi  sR     	""$$$--//D;>CW1WXXXXXr!   c                     | j                             d           |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.deleteCharacter} writes the control sequence
        containing the number of characters to delete and ending in
        L{CSFinalByte.DCH}
        r-      4N)ru  rL  r   r   r[  r   rB   rD   r   s    r   test_deleteCharacterz.ServerProtocolOutputTests.test_deleteCharacterr  s_     	%%a(((N  ""DHtOko6K$K	
 	
 	
 	
 	
r!   c                     | j                             d           |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.insertLine} writes the control sequence
        containing the number of lines to insert and ending in
        L{CSFinalByte.IL}
        r      5N)ru  rV  r   r   r[  r   rB   rg   r   s    r   test_insertLinez)ServerProtocolOutputTests.test_insertLine}  T     	  ###--//D;>CW1WXXXXXr!   c                     | j                             d           |                     | j                                        | j        dz   t          j        j        z              dS )z
        L{ServerProtocol.deleteLine} writes the control sequence
        containing the number of lines to delete and ending in
        L{CSFinalByte.DL}
        r      6N)ru  rP  r   r   r[  r   rB   rj   r   s    r   test_deleteLinez)ServerProtocolOutputTests.test_deleteLine  r  r!   c                     | j                                          |                     | j                                        | j        dz   dz              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'}.
        r6     rNru  r	  r   r   r[  r   r   s    r   test_setScrollRegionNoArgsz4ServerProtocolOutputTests.test_setScrollRegionNoArgs  sM     	%%'''--//D41GHHHHHr!   c                     | j                             d           |                     | j                                        | j        dz   dz              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   s    r   test_setScrollRegionJustFirstz7ServerProtocolOutputTests.test_setScrollRegionJustFirst  sS     	%%A%...--//E1AD1HIIIIIr!   c                     | j                             d           |                     | j                                        | j        dz   dz              dS )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   s    r   test_setScrollRegionJustLastz6ServerProtocolOutputTests.test_setScrollRegionJustLast  sS     	%%1%-----//E1AD1HIIIIIr!   c                     | j                             dd           |                     | j                                        | j        dz   dz              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   r   )r  r  s   1;2r  Nr  r   s    r    test_setScrollRegionFirstAndLastz:ServerProtocolOutputTests.test_setScrollRegionFirstAndLast  sU     	%%AA%666--//F1BT1IJJJJJr!   c                     | j                                          |                     | j                                        | j        dz   t          j        j        z              dS )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)ru  rZ  r   r   r[  r   rB   ro   r   s    r   test_reportCursorPositionz3ServerProtocolOutputTests.test_reportCursorPosition  s]     	**,,,N  ""DHtOko6K$K	
 	
 	
 	
 	
r!   N)&r   r   r   r<   r2   r  r   r   ry  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  r5   r!   r   rr  rr  y  sN         #
"1b
)
)C
((B//
/C5 5 5

 
 

 
 

 
 

 
 
	
 	
 	
S S S

 

 

Q Q Q: : :
 
 

 
 
&
 
 
R R RR R R

 

 

R R RR R RY Y YY Y YR R RY Y YY Y Y	
 	
 	
Y Y YY Y YI I IJ J JJ J JK K K

 

 

 

 

r!   rr  )3textwraptypingr   r   twisted.conch.insults.insultsr   r   r   r   r	   r
   r   r   r   r   r   r   r   twisted.internet.protocolr   twisted.internet.testingr   twisted.python.compatr   twisted.python.constantsr   r   twisted.trialr   r    r#   r'   r+   objectr   r2   rA   dedentrB   rr   r   r   r   r   TestCaser   r   r   r   r   rr  r5   r!   r   <module>r     s  
  ! ! ! ! ! ! ! !                              / . . . . . 4 4 4 4 4 4 + + + + + + : : : : : : : : " " " " " "4 4 4) ) )% % %" " " &((3 3 3(( ( ( *) 	#& 				 	-" " "J )(	u	u			u									u		!$ 				 		+  
D       D        $2 2 2 2 2 2 2 2$ - - - - --x/@ - - -,@ @ @ @ @183D @ @ @6 -  -  -  -  -0(2C  -  -  -F- - - - - 2H4E - - -:P
 P
 P
 P
 P
("3Y P
 P
 P
lE
 E
 E
 E
 E
 1 E
 E
 E
 E
 E
r!   