
    Vhs}                     D   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	 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 jJ                  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 jJ                  d@      "      Z' G dA dB      Z( G dC dD      Z)dEZ* G dF dGe)      Z+[* G dH dIe+ejX                        Z- G dJ dKe+ejX                        Z. G dL dMe+ejX                        Z/ G dN dOe+ejX                        Z0 G dP dQejX                  e)      Z1 G dR dSejX                        Z2y)T    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                 (    t         t        |   |      S N)superMock__getattribute__)mocknames     O/home/dcms/DCMS/lib/python3.12/site-packages/twisted/conch/test/test_insults.py_getattrr       s    t-d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                 8    t        |       j                  |       y r   )r#   append)r   objs     r   _appendr+   +   s    S!r!   c                 8    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   2   s     " Vq[C/0122r!   c                     t        |      D  ci c]3  \  }}t        |      D ]   \  }} | r| t        t        ||z   |            " 5 }}}}} ||d<   t         t        f|      S c c} }}}w )N__doc__)	enumerater   r2   typer   )r   	colOffsetnamesdocjr1   iattrss           r   _makeControlFunctionSymbolsr=   F   s      & As ~ At 	m4Q]AFGGE  E)vi''s   8A%
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}
    )r7   r8   r9   
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y)r   Nc                 H    g | _         |i }|| _        |t        ur|| _        yy)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__   s2    
 ?G')#2D  *r!   c                 b    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__   s7    t%67'!&Kz;267r!   c                 v    t        | d      }||v rt        ||         }n
t               }t        | ||f       |S )Nr'   )r   )r    r   r+   )r   r   r'   	attrValues       r   r   zMock.__getattribute__   s?    4+7?WT];IItY'(r!   )__name__
__module____qualname__r   r   r   r   r    r!   r   r   r      s    O#W 
3r!   r   c                       e Zd Zdi fdZy)	MockMixinr   c                    |\  }}| j                  ||       | j                  t        t        |            d       t        |      \  \  }}}	}
| j                  |d       | j                  |	|       | j                  |
|       |S )N   r   )assertEquallenr#   )r   
occurrence
methodNameexpectedPositionalArgsexpectedKeywordArgsattrr   callresultargsr   s              r   
assertCallzMockMixin.assertCall   s      
dz*[./3%0%6"	!$bz*5601r!   N)r   r   r   r   r   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                   b    e Zd ZU dZeee      ed<   dD ]  \  ZZ	 e
eee	dz          [[	d Zy)ByteGroupingsMixinNprotocolFactory))Pairs   )Triples   )Quadsr-   )Quints   )Sexes   )	groupNamebytesPerc                     | j                  t        |      j                  d      d|f      }| j                  t        |      g        y )Nr   makeConnection)r   r#   popr   )r   	transportprotoparserr   s        r   verifyResultsz ByteGroupingsMixin.verifyResults   s<    U!3!7!7!:<LviXV,b1r!   )r   r   r   r   r   r   r   __annotations__wordnexec_byteGroupingTestTemplater   r   r!   r   r   r      sM    04OXd8n-4 Ma 	&t)KKLM 	a2r!   r   c                       e Zd ZeZdZd Zy)ServerArrowKeysTestss   [A[B[C[Dc                 ^   t         j                  | |||       |j                  |j                  |j                  |j
                  fD ]J  }| j                  t        |      j                  d      d|d f      }| j                  t        |      g        L | j                  t        |             y )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 OO	
 		6E __E"&&q)+>F [0"5		6 	U+,r!   Nr   r   r   r   r   
TEST_BYTESr   r   r!   r   r   r      s    $O -J-r!   r   c                       e Zd ZeZdZd Zy)PrintableCharactersTestss   abc123ABC!@#abc123c                    t         j                  | |||       t        d      D ]J  }| j                  t	        |      j                  d      d|d f      }| j                  t	        |      g        L t        d      D ]T  }| j                  t	        |      j                  d      d||j                  f      }| j                  t	        |      g        V t	        |      }| j                  ||d       y )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o. 	6D__E"&&q)+>tF [0"5		6 i( 	6D__E"&&q)+>vzz@RF [0"5		6 5!$)=>?r!   Nr   r   r!   r   r   r   	  s    $O
 ?J@r!   r   c                   z    e Zd ZdZeZg ZdD ]  Zej                  dez           dj                  e      Z
[[d Zy)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         j                  | |||       t        dd      D ]Z  }t        |d|fz        }| j	                  t        |      j                  d      d|d f      }| j                  t        |      g        \ | j                  t        |             y )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Q| 	6Gfewj&89G__E"&&q)+>$F [0"5	6 	U+,r!   N)r   r   r   r4   r   r   byteList	byteCodesr)   joinr   r   r   r!   r   r   r   $  sM    C$OH .	 	9,-. (#J)-r!   r   c                   P    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
y)ClientCursorMovementTestss   [2Bs   [4Cs   [As   [2Dc                    t         j                  | |||       dD ]O  \  }}| j                  t        |      j	                  d      d|z   |f      }| j                  t        |      g        Q | j                  t        |             y )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.verifyResultsR  s    ((y%H
 	6MFE __E"&&q)8f+<uhF [0"5	6 	U+,r!   N)r   r   r   r   r   d2r4u1l2r   r   r   r!   r   r   r   G  sE    $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y)ClientControlSequencesTestsc                     t                _        t                _        t	         fd       _          j
                  _         j
                  j                   j                          j                  t         j                        j                  d      d j
                  f      } j                  t        |             y )Nc                       j                   S r   )r   r   s   r   <lambda>z3ClientControlSequencesTests.setUp.<locals>.<lambda>h  s    TZZ r!   r   r   )r   r   r   r   r   r   factoryr   r   r#   r   r   )r   r   s   ` r   setUpz!ClientControlSequencesTests.setUpe  s    (*V
$%78"""4>>2

#''*,<t{{n
 	V,-r!   c                 `   | j                   j                  dj                  d t        d      D                     t	        | j
                        }dD ]I  }dD ]B  }| j                  |j                  d      d|z   |f      }| j                  t	        |             D K | j                  |       y )Nr!   c              3   :   K   | ]  }d D ]  }d|z   |z      yw))r!      2s   20s   200r   Nr   ).0chr   s      r   	<genexpr>zBClientControlSequencesTests.testSimpleCardinals.<locals>.<genexpr>r  s6      3  1r!!s   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.testSimpleCardinalsp  s      HH #G, 	
 4::&9 	6D( 6!hoxP  V!456	6 	r!   c                 v   | j                   j                  d       t        | j                        }| j	                  |j                  d      dd      }| j                  t        |             | j	                  |j                  d      dd      }| j                  t        |             | j                  |       y )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4::&!.?IV,-!.?NV,-r!   c                 b   | j                   j                  d       t        | j                        }| j	                  |j                  d      dd      }| j                  t        |             | j	                  |j                  d      dd      }| j                  t        |             | j	                  |j                  d      d      }| j                  t        |             | j	                  |j                  d      d      }| j                  t        |             | j                  |       y )Ns   #3#4#5#6r   doubleHeightLine)T)FsingleWidthLinedoubleWidthLiner	  r
  s      r   testHeightAndWidthz.ClientControlSequencesTests.testHeightAndWidth  s      !<=4::&!.@'JV,-!.@(KV,-!.?@V,-!.?@V,-r!   c                 "   | j                   j                  dj                  t        d      D cg c]0  }dj                  t        d      D cg c]
  }d|z   |z    c}      2 c}}             t	        | j
                        }t        t        fD ]`  }t        t        t        t        t        fD ]@  }| j                  |j                  d      d||f      }| j                  t	        |             B b | j                  |       y c c}w c c}}w )Nr!   s   ()s   AB012   r   selectCharacterSet)r   r  r   r   r#   r   r   r   r   r   r
   r   r	   r   r   r   )r   gr   r   whichcharsetr   s          r   testCharacterSetz,ClientControlSequencesTests.testCharacterSet  s      HH 'u- HHy7JK!gkAoKL	
 4::&"X 	6E$ 
6 HHQK!57G   V!45
6	6 	' Ls   DD	DDc                 r   | j                   j                  d       t        | j                        }| j	                  |j                  d      d      }| j                  t        |             | j	                  |j                  d      d      }| j                  t        |             | j                  |       y )Ns   r   shiftInshiftOutr	  r
  s      r   testShiftingz(ClientControlSequencesTests.testShifting  s      -4::&!i8V,-!j9V,-r!   c                 r   | j                   j                  d       t        | j                        }| j	                  |j                  d      d      }| j                  t        |             | j	                  |j                  d      d      }| j                  t        |             | j                  |       y )Ns   NOr   singleShift2singleShift3r	  r
  s      r   testSingleShiftsz,ClientControlSequencesTests.testSingleShifts  s      /4::&!n=V,-!n=V,-r!   c                 r   | j                   j                  d       t        | j                        }| j	                  |j                  d      d      }| j                  t        |             | j	                  |j                  d      d      }| j                  t        |             | j                  |       y )Ns   =>r   applicationKeypadModenumericKeypadModer	  r
  s      r   testKeypadModez*ClientControlSequencesTests.testKeypadMode  s      /4::&!.EFV,-!.ABV,-r!   c                 r   | j                   j                  d       t        | j                        }| j	                  |j                  d      d      }| j                  t        |             | j	                  |j                  d      d      }| j                  t        |             | j                  |       y )Ns   78r   
saveCursorrestoreCursorr	  r
  s      r   
testCursorz&ClientControlSequencesTests.testCursor  s      /4::&!l;V,-!o>V,-r!   c                     | j                   j                  d       t        | j                        }| j	                  |j                  d      d      }| j                  t        |             | j                  |       y )Ns   cr   resetr	  r
  s      r   	testResetz%ClientControlSequencesTests.testReset  s[      *4::&!g6V,-r!   c                    | j                   j                  d       t        | j                        }| j	                  |j                  d      d      }| j                  t        |             | j	                  |j                  d      d      }| j                  t        |             | j	                  |j                  d      d      }| j                  t        |             | j                  |       y )Ns   DMEr   indexreverseIndexnextLiner	  r
  s      r   	testIndexz%ClientControlSequencesTests.testIndex  s      !344::&!g6V,-!n=V,-!j9V,-r!   c           	         | j                   j                  ddj                  d t        j                  t        j
                  t        j                  fD              z   dz          | j                   j                  ddj                  d t        j                  t        j
                  t        j                  fD              z   dz          t        | j                        }| j                  |j                  d      dt        j                  t        j
                  t        j                  gf      }| j                  t        |             | j                  |j                  d      d	t        j                  t        j
                  t        j                  gf      }| j                  t        |             | j                  |       y )
Nr      ;c              3   (   K   | ]
  }d |fz    yws   %dNr   r   ms     r   r   z8ClientControlSequencesTests.testModes.<locals>.<genexpr>       PP      hc              3   (   K   | ]
  }d |fz    ywr3  r   r4  s     r   r   z8ClientControlSequencesTests.testModes.<locals>.<genexpr>  r6  r7     lr   setModes
resetModes)r   r  r   r   KAMIRMLNMr#   r   r   r   r   r
  s      r   	testModesz%ClientControlSequencesTests.testModes  sB     iiPuyy%))UYY.OPPQ	

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

 4::&HHQKuyy%))UYY&G%I
 	V,-HHQKEIIuyy(I'K
 	V,-r!   c                    | j                   j                  d       t        | j                        }dD ]=  }| j	                  |j                  d      |      }| j                  t        |             ? | j	                  |j                  d      dd      }| j                  t        |             | j                  |       y )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4::&
 		2D __TXXa[$7F[01		2 !.?FV,-r!   c                    | j                   j                  d       t        | j                        }dD ]?  }| j	                  |j                  d      d|f      }| j                  t        |             A | j                  |       y )Ns   [M[3Mr   r   r   
deleteLiner	  r   r   argr   s       r   testLineDeletionz,ClientControlSequencesTests.testLineDeletion"  q      !124::& 	2C__TXXa[,GF[01	2 	r!   c                    | j                   j                  d       t        | j                        }dD ]?  }| j	                  |j                  d      d|f      }| j                  t        |             A | j                  |       y )Ns   [L[3LrK  r   
insertLiner	  rM  s       r   testLineInsertionz-ClientControlSequencesTests.testLineInsertion+  rP  r!   c                 N   dt        | j                        d<   | j                  j                  d       | j	                  | j
                  j                         d       t        | j                        }| j                  |j                  d      d      }| j	                  |d       y )N)r      reportCursorPositions   [6ns   [7;8Rr   )
r'   r   r   r  r   r   valuer#   r   r   r
  s      r   testCursorPositionz.ClientControlSequencesTests.testCursorPosition4  s~    6<

23  ,--/>4::&!.DE 	(r!   c                 "   t        | j                        }| j                  j                  d       | j	                  |j                  d      dd       | j                  j                  d       | j	                  |j                  d      dd       y)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)rZ     bc)r\  N)r#   r   r   r  r   r   )r   r   s     r   test_applicationDataBytesz5ClientControlSequencesTests.test_applicationDataBytes?  sf     4::&  &Wg6  'Wh7r!   c                     t        | j                        }| j                  j                  |       |r4 | j                  |j                  d      g|j                  d        |r4| j                  |d|       y )Nr   zNo other calls should happen: )r#   r   r   r  r   r   r   )r   datacallsr   s       r   _applicationDataTestz0ClientControlSequencesTests._applicationDataTestK  se    4::&  &DOODHHQK7%))A,7 !?xHIr!   c                 ,    | j                  dddg       y)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ra  r   s    r    test_shiftInAfterApplicationDataz<ClientControlSequencesTests.test_shiftInAfterApplicationDataR  s    
 	!!).A<-PQr!   c                 ,    | j                  dddg       y)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rc  )r  Nrd  r   s    r   !test_shiftOutAfterApplicationDataz=ClientControlSequencesTests.test_shiftOutAfterApplicationDataY  s    
 	!!).A=-QRr!   c                 ,    | j                  dddg       y)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rc  )cursorBackwardNrd  r   s    r   'test_cursorBackwardAfterApplicationDatazCClientControlSequencesTests.test_cursorBackwardAfterApplicationData`  s     	!!).ACV-WXr!   c                 \    | j                  dddg       | j                  ddddgffg       y)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Drc  )r,  s   ab[4hr;  r-   Nrd  r   s    r   test_escapeAfterApplicationDataz;ClientControlSequencesTests.test_escapeAfterApplicationDatah  s>     	!!*/BJ.OP 	!!.qcV0DE	
r!   N)r   r   r   r   r  r  r  r  r  r  r#  r'  r*  r/  r@  rI  rO  rS  rX  r]  ra  re  rg  rj  rl  r   r!   r   r   r   d  st    	. 	"2				0&	)
8JRS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%y$)%ServerProtocolOutputTestszh
    Tests for the bytes L{ServerProtocol} writes to its transport when its
    methods are called.
    r      r   c                     t               | _        t               | _        | j                  j	                  | j                         y r   )r   protocolr   r   r   r   s    r   r   zServerProtocolOutputTests.setUp  s,    &((*$$T^^4r!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.cursorUp} writes the control sequence
        ending with L{CSFinalByte.CUU} to its transport.
        r      1N)rq  cursorUpr   r   rW  r   r>   rB   r   s    r   test_cursorUpz'ServerProtocolOutputTests.test_cursorUp  sM    
 	q!NN  "DHHtOkoo6K6K$K	
r!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.cursorDown} writes the control sequence
        ending with L{CSFinalByte.CUD} to its transport.
        r   rs  N)rq  
cursorDownr   r   rW  r   r>   rE   r   s    r   test_cursorDownz)ServerProtocolOutputTests.test_cursorDown  sM    
 	  #NN  "DHHtOkoo6K6K$K	
r!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.cursorForward} writes the control sequence
        ending with L{CSFinalByte.CUF} to its transport.
        r   rs  N)rq  cursorForwardr   r   rW  r   r>   rH   r   s    r   test_cursorForwardz,ServerProtocolOutputTests.test_cursorForward  sM    
 	##A&NN  "DHHtOkoo6K6K$K	
r!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.cursorBackward} writes the control sequence
        ending with L{CSFinalByte.CUB} to its transport.
        r   rs  N)rq  ri  r   r   rW  r   r>   rK   r   s    r   test_cursorBackwardz-ServerProtocolOutputTests.test_cursorBackward  sM    
 	$$Q'NN  "DHHtOkoo6K6K$K	
r!   c                     | j                   j                  dd       | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)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)rq  cursorPositionr   r   rW  r   r>   rW   r   s    r   test_cursorPositionz-ServerProtocolOutputTests.test_cursorPosition  sP     	$$Q*NN  "DHHv$58M8M$M	
r!   c                     | j                   j                          | j                  | j                  j	                         | j
                  t        j                  j                  z          y)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)rq  
cursorHomer   r   rW  r   r>   rW   r   s    r   test_cursorHomez)ServerProtocolOutputTests.test_cursorHome  sD     	  "--/KOO<Q<Q1QRr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  t        dd      z          y)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)rq  r,  r   r   rW  ESCr2   r   s    r   
test_indexz$ServerProtocolOutputTests.test_index  sE     	NN  "DHH/G1/M$M	
r!   c                     | j                   j                          | j                  | j                  j	                         | j
                  t        j                  j                  z          y)zt
        L{ServerProtocol.reverseIndex} writes the control sequence
        ending in the L{C1SevenBit.RI}.
        N)rq  r-  r   r   rW  r  rn   r   r   s    r   test_reverseIndexz+ServerProtocolOutputTests.test_reverseIndex  sD    
 	""$--/JMM<O<O1OPr!   c                     | j                   j                          | j                  | j                  j	                         d       y)zM
        L{ServerProtocol.nextLine} writes C{"
"} to its transport.
        s   
N)rq  r.  r   r   rW  r   s    r   test_nextLinez'ServerProtocolOutputTests.test_nextLine  s1     	 --/9r!   c                 h   t         j                  t         j                  t         j                  g}| j                  j                  |       | j                  | j                  j                         | j                  dj                  d |D              z   t        j                  j                  z          y)z
        L{ServerProtocol.setModes} writes a control sequence
        containing the requested modes and ending in the
        L{CSFinalByte.SM}.
        r1  c              3   (   K   | ]
  }d |fz    ywr3  r   r4  s     r   r   z:ServerProtocolOutputTests.test_setModes.<locals>.<genexpr>       99r7  N)r   r=  r>  r?  rq  r;  r   r   rW  r   r   r>   rY   r   
modesToSets     r   test_setModesz'ServerProtocolOutputTests.test_setModes  s|     iiEII6
z*NN  "HHii9j99:nn""#	
r!   c                 h   t         j                  t         j                  t         j                  g}| j                  j                  |       | j                  | j                  j                         | j                  dj                  d |D              z   t        j                  j                  z          y)z
        L{ServerProtocol.setPrivatesModes} writes a control sequence
        containing the requested private modes and ending in the
        L{CSFinalByte.SM}.
        r1  c              3   (   K   | ]
  }d |fz    ywr3  r   r4  s     r   r   zAServerProtocolOutputTests.test_setPrivateModes.<locals>.<genexpr>  s     @@r7  N)r   ERRORCOLUMNORIGINrq  r;  r   r   rW  r   r   r>   rY   )r   privateModesToSets     r   test_setPrivateModesz.ServerProtocolOutputTests.test_setPrivateModes  s     

 	01NN  "HHii@.?@@Ann""#	
r!   c                 h   t         j                  t         j                  t         j                  g}| j                  j                  |       | j                  | j                  j                         | j                  dj                  d |D              z   t        j                  j                  z          y)zs
        L{ServerProtocol.resetModes} writes the control sequence
        ending in the L{CSFinalByte.RM}.
        r1  c              3   (   K   | ]
  }d |fz    ywr3  r   r4  s     r   r   z<ServerProtocolOutputTests.test_resetModes.<locals>.<genexpr>  r  r7  N)r   r=  r>  r?  rq  r<  r   r   rW  r   r   r>   re   r  s     r   test_resetModesz)ServerProtocolOutputTests.test_resetModes  s|    
 iiEII6
  ,NN  "HHii9j99:nn""#	
r!   c                     | j                   j                          | j                  | j                  j	                         | j
                  t        j                  j                  z          y)zp
        L{ServerProtocol.singleShift2} writes an escape sequence
        followed by L{C1SevenBit.SS2}
        N)rq  r  r   r   rW  r  rn   r   r   s    r   test_singleShift2z+ServerProtocolOutputTests.test_singleShift2  D    
 	""$--/JNN<P<P1PQr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  t        j                  j                  z          y)zp
        L{ServerProtocol.singleShift3} writes an escape sequence
        followed by L{C1SevenBit.SS3}
        N)rq  r  r   r   rW  r  rn   r   r   s    r   test_singleShift3z+ServerProtocolOutputTests.test_singleShift3  r  r!   c                 .   | j                   j                  t        t              t        t                     | j                  | j                  j                         | j                  dt        t        fz  z   t        j                  j                  z          y)z
        L{ServerProtocol.selectGraphicRendition} writes a control
        sequence containing the requested attributes and ending with
        L{CSFinalByte.SGR}
        s   %d;%dN)rq  selectGraphicRenditionstrr   r   r   r   rW  r   r>   rh   r   s    r   test_selectGraphicRenditionz5ServerProtocolOutputTests.test_selectGraphicRendition%  sc     	,,SZYHNN  "HHx5)"444{7L7LL	
r!   c                     | j                   j                          | j                  | j                  j	                         | j
                  t        j                  j                  z          y)zz
        L{ServerProtocol.horizontalTabulationSet} writes the escape
        sequence ending in L{C1SevenBit.HTS}
        N)rq  horizontalTabulationSetr   r   rW  r  rn   r|   r   s    r   test_horizontalTabulationSetz6ServerProtocolOutputTests.test_horizontalTabulationSet1  sD    
 	--/--/JNN<P<P1PQr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  t        j                  j                  z          y)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)rq  rB  r   r   rW  r   r>   r`   r   s    r   test_eraseToLineEndz-ServerProtocolOutputTests.test_eraseToLineEnd9  sD     	$$&--/KNN<P<P1PQr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)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.)
        rs  N)rq  rC  r   r   rW  r   r>   r`   r   s    r   test_eraseToLineBeginningz3ServerProtocolOutputTests.test_eraseToLineBeginningC  sH     	**,--/D;>>CWCW1WXr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.eraseLine} writes the control
        sequence sequence ending in L{CSFinalByte.EL} and a parameter
        of 2 (the entire line.)
        r   N)rq  rD  r   r   rW  r   r>   r`   r   s    r   test_eraseLinez(ServerProtocolOutputTests.test_eraseLineM  sH     	!--/D;>>CWCW1WXr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  t        j                  j                  z          y)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)rq  rE  r   r   rW  r   r>   r]   r   s    r   test_eraseToDisplayEndz0ServerProtocolOutputTests.test_eraseToDisplayEndV  sD     	'')--/KNN<P<P1PQr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)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.)
        rs  N)rq  rF  r   r   rW  r   r>   r]   r   s    r   test_eraseToDisplayBeginningz6ServerProtocolOutputTests.test_eraseToDisplayBeginning`  sH     	--/--/D;>>CWCW1WXr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.eraseDisplay} writes the control sequence
        sequence ending in L{CSFinalByte.ED} a parameter of 2 (the
        entire page)
        r   N)rq  rG  r   r   rW  r   r>   r]   r   s    r   test_eraseToDisplayz-ServerProtocolOutputTests.test_eraseToDisplayj  sH     	""$--/D;>>CWCW1WXr!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.deleteCharacter} writes the control sequence
        containing the number of characters to delete and ending in
        L{CSFinalByte.DCH}
        r-      4N)rq  rH  r   r   rW  r   r>   r@   r   s    r   test_deleteCharacterz.ServerProtocolOutputTests.test_deleteCharacters  sM     	%%a(NN  "DHHtOkoo6K6K$K	
r!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.insertLine} writes the control sequence
        containing the number of lines to insert and ending in
        L{CSFinalByte.IL}
        r      5N)rq  rR  r   r   rW  r   r>   rc   r   s    r   test_insertLinez)ServerProtocolOutputTests.test_insertLine~  J     	  #--/D;>>CWCW1WXr!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)z
        L{ServerProtocol.deleteLine} writes the control sequence
        containing the number of lines to delete and ending in
        L{CSFinalByte.DL}
        r      6N)rq  rL  r   r   rW  r   r>   rf   r   s    r   test_deleteLinez)ServerProtocolOutputTests.test_deleteLine  r  r!   c                     | j                   j                          | j                  | j                  j	                         | j
                  dz   dz          y)z
        With no arguments, L{ServerProtocol.setScrollRegion} writes a
        control sequence with no parameters, but a parameter
        separator, and ending in C{b'r'}.
        r1     rNrq  r  r   r   rW  r   r   s    r   test_setScrollRegionNoArgsz4ServerProtocolOutputTests.test_setScrollRegionNoArgs  s>     	%%'--/D41GHr!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   dz          y)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  sD     	%%A%.--/E1AD1HIr!   c                     | j                   j                  d       | j                  | j                  j	                         | j
                  dz   dz          y)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  sD     	%%1%---/E1AD1HIr!   c                     | j                   j                  dd       | j                  | j                  j	                         | j
                  dz   dz          y)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  sF     	%%AA%6--/F1BT1IJr!   c                     | j                   j                          | j                  | j                  j	                         | j
                  dz   t        j                  j                  z          y)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)rq  rV  r   r   rW  r   r>   rk   r   s    r   test_reportCursorPositionz3ServerProtocolOutputTests.test_reportCursorPosition  sK     	**,NN  "DHHtOkoo6K6K$K	
r!   N)&r   r   r   r4   r2   r  r   r   ru  rx  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   rn  rn  z  s     #1b
)C
(B/
/C5




	
S

Q:

&
RR

RRYYRYY	
YYIJJK

r!   rn  )3textwraptypingr   r   
constantlyr   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.trialr   r    r#   r'   r+   objectr   r2   r=   dedentr>   rn   r   r   r   r   TestCaser   r   r   r   r   rn  r   r!   r   <module>r     s  
  ! ,    / 4 + "4)%" (3(( * 	#& 				-"J )	u	u			u									u		!$ 				+
D D  $2 2$ --x/@/@ -,@183D3D @6 -0(2C2C  -F- 2H4E4E -:P
("3"3Y P
lE
 1 1 E
r!   