%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/conch/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/conch/test/__pycache__/test_manhole.cpython-312.pyc

�

Ϫ�f�4����UdZddlZddlZddlmZdZeeed<ddlm	Z	ddl
mZddlm
Z
mZmZmZmZddlmZmZdd	lmZdd
lmZd�Ze�ZGd�d
ej4�ZGd�dej4�ZGd�dej4�ZGd�d�ZGd�deej4e�ZGd�de
ej4e�Z Gd�deej4e�Z!Gd�dej4�Z"y)z%
Tests for L{twisted.conch.manhole}.
�N)�Optional�ssh)�manhole)�insults)�	_SSHMixin�_StdioMixin�_TelnetMixinr�stdio)�defer�error)�StringTransport)�unittestc�b�	ddzy#t$rtj�ddcYSwxYw)z�
    Return the string used by Python as the name for code objects which are
    compiled from interactive input or at the top-level of modules.
    �r����N)�
BaseException�	traceback�
extract_stack���A/usr/lib/python3/dist-packages/twisted/conch/test/test_manhole.py�determineDefaultFunctionNamers8��
0�	�Q����0��&�&�(��,�Q�/�/�	0�s��#.�.c��eZdZdZd�Zy)�ManholeInterpreterTestsz2
    Tests for L{manhole.ManholeInterpreter}.
    c��tjd�}|jjddg�|j	�|j|j�y)zR
        L{ManholeInterpreter.resetBuffer} should empty the input buffer.
        N�1�2)r�ManholeInterpreter�buffer�extend�resetBuffer�assertFalse)�self�interpreters  r�test_resetBufferz(ManholeInterpreterTests.test_resetBuffer5sL���0�0��6�����!�!�3��*�-����!�����+�+�,rN)�__name__�
__module__�__qualname__�__doc__r&rrrrr0s���-rrc��eZdZdZd�Zy)�ManholeProtocolTestsz'
    Tests for L{manhole.Manhole}.
    c�@�t�}tjtj�}|j|�|j}|j}|jjddg�|j�|j|j�y)zn
        L{manhole.Manhole.handle_INT} should cause the interpreter input buffer
        to be reset.
        rrN)r
r�ServerProtocolr�Manhole�makeConnection�terminalProtocolr%r r!�
handle_INTr#)r$�	transport�terminal�protocolr%s     r�%test_interruptResetsInterpreterBufferz:ManholeProtocolTests.test_interruptResetsInterpreterBufferDs|��
$�%�	��)�)�'�/�/�:�����	�*��,�,���*�*�����!�!�3��*�-���������+�+�,rN)r'r(r)r*r6rrrr,r,?s���-rr,c�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�WriterTestsc�.�tjd�y)z&
        Colorize an integer.
        rN�r�lastColorizedLine�r$s r�test_IntegerzWriterTests.test_IntegerTs��	�!�!�#�&rc�.�tjd�y)z7
        Colorize an integer in double quotes.
        z"1"Nr:r<s r�test_DoubleQuoteStringz"WriterTests.test_DoubleQuoteStringZ���	�!�!�%�(rc�.�tjd�y)z7
        Colorize an integer in single quotes.
        z'1'Nr:r<s r�test_SingleQuoteStringz"WriterTests.test_SingleQuoteString`r@rc�.�tjd�y)z7
        Colorize an integer in triple quotes.
        z'''1'''Nr:r<s r�test_TripleSingleQuotedStringz)WriterTests.test_TripleSingleQuotedStringf���	�!�!�)�,rc�.�tjd�y)zB
        Colorize an integer in triple and double quotes.
        z"""1"""Nr:r<s r�test_TripleDoubleQuotedStringz)WriterTests.test_TripleDoubleQuotedStringlrErc�.�tjd�y)z1
        Colorize a function definition.
        z
def foo():Nr:r<s r�test_FunctionDefinitionz#WriterTests.test_FunctionDefinitionr���	�!�!�,�/rc�.�tjd�y)z.
        Colorize a class definition.
        z
class foo:Nr:r<s r�test_ClassDefinitionz WriterTests.test_ClassDefinitionxrJrc�l�tjd�}|jt|t��y)z,
        Colorize a Unicode string.
        �иN�rr;�
assertTrue�
isinstance�bytes�r$�ress  r�test_unicodezWriterTests.test_unicode~s'���'�'��1�����
�3��.�/rc�l�tjd�}|jt|t��y)z/
        Colorize a UTF-8 byte string.
        �иNrOrSs  r�
test_byteszWriterTests.test_bytes�s'���'�'��4�����
�3��.�/rc�t�|jtjd�tjd��y)zT
        The output of UTF-8 bytestrings and Unicode strings are identical.
        rWrNN)�assertEqualrr;r<s r�test_identicalOutputz WriterTests.test_identicalOutput�s-��	
����%�%�k�2�G�4M�4M�h�4W�	
rN)
r'r(r)r=r?rBrDrGrIrLrUrXr[rrrr8r8Ss4��'�)�)�-�-�0�0�0�0�
rr8c���eZdZejZd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zej d
��Zej d��Zd�Zd
�Zej d��Zy)�ManholeLoopbackMixinc����jjd�}�jd��fd�}|j|�S)z-
        Evaluate simple expression.
        �dones
1 + 1
donec�,���jgd��y)N)�	>>> 1 + 1�2�>>> done��
_assertBuffer��ignr$s �r�finishedz<ManholeLoopbackMixin.test_SimpleExpression.<locals>.finished�s������@�Ar��recvlineClient�expect�
_testwrite�addCallback�r$�donerhs`  r�test_SimpleExpressionz*ManholeLoopbackMixin.test_SimpleExpression�sA����"�"�)�)�'�2�����*�+�	B�����)�)rc����jjd�}�jd��fd�}|j|�S)z>
        Evaluate line continuation in triple quotes.
        r_s'''
'''
donec�,���jgd��y)N)s>>> '''s... '''s'\n'rcrdrfs �rrhzGManholeLoopbackMixin.test_TripleQuoteLineContinuation.<locals>.finished�s������N�Orrirns`  r� test_TripleQuoteLineContinuationz5ManholeLoopbackMixin.test_TripleQuoteLineContinuation�sA����"�"�)�)�'�2�����-�.�	P�����)�)rc����jjd�}�jd��fd�}|j|�S)z/
        Evaluate function definition.
        r_s'def foo(bar):
	print(bar)

foo(42)
donec�,���jgd��y)N)s>>> def foo(bar):s...     print(bar)�... s>>> foo(42)s42rcrdrfs �rrhz>ManholeLoopbackMixin.test_FunctionDefinition.<locals>.finished�s�������	
rrirns`  rrIz,ManholeLoopbackMixin.test_FunctionDefinition�s@����"�"�)�)�'�2�����S�T�
	�����)�)rc����jjd�}�jd��fd�}|j|�S)z,
        Evaluate class definition.
        r_sEclass Foo:
	def bar(self):
		print('Hello, world!')

Foo().bar()
donec�,���jgd��y)N)s>>> class Foo:s...     def bar(self):s"...         print('Hello, world!')rvs>>> Foo().bar()s
Hello, world!rcrdrfs �rrhz;ManholeLoopbackMixin.test_ClassDefinition.<locals>.finished�s�������

rrirns`  rrLz)ManholeLoopbackMixin.test_ClassDefinition�sD����"�"�)�)�'�2�����
�	
�	�����)�)rc����jjd�}�jd��fd�}|j|�|S)z0
        Evaluate raising an exception.
        r_s#raise Exception('foo bar baz')
donec�^���jdddtjd�zddg�y)Ns">>> raise Exception('foo bar baz')s"Traceback (most recent call last):s  File "<console>", line 1, in zutf-8sException: foo bar bazrc)re�defaultFunctionName�encoderfs �rrhz5ManholeLoopbackMixin.test_Exception.<locals>.finished�s8������9�9�6�)�0�0��9�:�-��
�	
rrirns`  r�test_Exceptionz#ManholeLoopbackMixin.test_Exception�sB����"�"�)�)�'�2�����C�D�
	�	
����"��rc�R�|jtdd��|j�S)z�
        Raised exceptions are handled the same way even if L{sys.excepthook}
        has been modified from its original value.
        �
excepthookc��y)Nr)�argss r�<lambda>zIManholeLoopbackMixin.test_ExceptionWithCustomExcepthook.<locals>.<lambda>s�r)�patch�sysr}r<s r�"test_ExceptionWithCustomExcepthookz7ManholeLoopbackMixin.test_ExceptionWithCustomExcepthook�s$��	
�
�
�3��&8�9��"�"�$�$rc����jjd�}�jdtjzdz��fd�}|j|�S)z4
        Evaluate interrupting with CTRL-C.
        r_�cancelled linec�,���jgd��y)N)�>>> cancelled line�KeyboardInterruptrcrdrfs �rrhz4ManholeLoopbackMixin.test_ControlC.<locals>.finished
s������J�
r)rjrkrlr�CTRL_Crmrns`  r�
test_ControlCz"ManholeLoopbackMixin.test_ControlCsN����"�"�)�)�'�2�����)�G�N�N�:�W�D�E�	�
����)�)rc����jjd�}�jd��fd�}|j|��fd�}|j|�|S)z�
        Sending ^C to Manhole while in a state where more input is required to
        complete a statement should discard the entire ongoing statement and
        reset the input prompt to the non-continuation prompt.
        sthingss(
thingsc����jddg��jjd�}�jtj
�|S)N�>>> (�
... things�>>> )rerjrkrlrr�)�ignored�interruptedr$s  �r�gotContinuationzNManholeLoopbackMixin.test_interruptDuringContinuation.<locals>.gotContinuationsB�������-�8�9��-�-�4�4�W�=�K��O�O�G�N�N�+��rc�,���jgd��y)N)r�r�r�r�rd)r�r$s �r�gotInterruptionzNManholeLoopbackMixin.test_interruptDuringContinuation.<locals>.gotInterruption&s������W�Xrri)r$�
continuingr�r�s`   r� test_interruptDuringContinuationz5ManholeLoopbackMixin.test_interruptDuringContinuationsX����(�(�/�/�	�:�
�����%�	�	����/�	Y�	����/��rc����jd��jjd�}�fd�}�fd�}|j|�j|�S)z2
        Evaluate cancelling with CTRL-\.
        r�c�����jdg��jtj��jj
}�j
|tj�S)Nr�)	rerlr�CTRL_BACKSLASHrj�onDisconnection�
assertFailurer�ConnectionDone)rg�dr$s  �r�gotPartialLinezBManholeLoopbackMixin.test_ControlBackslash.<locals>.gotPartialLine3sQ������ 5�6�7��O�O�G�2�2�3��#�#�3�3�A��%�%�a��)=�)=�>�>rc�*���jdg�y)Nrrdrfs �r�gotClearedLinezBManholeLoopbackMixin.test_ControlBackslash.<locals>.gotClearedLine:s�������u�%r�rlrjrkrm)r$�partialLiner�r�s`   r�test_ControlBackslashz*ManholeLoopbackMixin.test_ControlBackslash,sQ���	
���)�*��)�)�0�0�1B�C��	?�	&��&�&�~�6�B�B�>�R�Rrc#�8K�|jd�|jjd���|jdg�|jtj
dz�|jjd���|jdg�|jd�|jjd���|jtj
�|jj}|j|tj���y�w)	z~
        A CTRL+D in the middle of a line doesn't close a connection,
        but at the beginning of a line it does.
        s1 + 1�\+ 1ra� + 1�
>>> 1 + 1 + 1�
s3
>>> N)
rlrjrkrer�CTRL_Dr�r�rr�)r$r�s  r�
test_controlDz"ManholeLoopbackMixin.test_controlD?s�����	
����!��!�!�(�(��2�2����L�>�*��������0�1��!�!�(�(��2�2����,�-�.�������!�!�(�(��4�4�������'����/�/��� � ��E�$8�$8�9�9�s�DDc#�0K�|jd�|jjd���|jddg�|jtj
dz�|jjd���|jdg�y�w)	a
        CTRL+L is generally used as a redraw-screen command in terminal
        applications.  Manhole doesn't currently respect this usage of it,
        but it should at least do something reasonable in response to this
        event (rather than, say, eating your face).
        s
1 + 1r�r�rar�s1 \+ 1 \+ 1r�N)rlrjrkrer�CTRL_Lr<s r�
test_ControlLz"ManholeLoopbackMixin.test_ControlLTs|����	
���
�#��!�!�(�(��2�2����G�\�2�3��������0�1��!�!�(�(��9�9����,�-�.�s�BBc����jd��jjd�}�fd�}|j|�S)zl
        CTRL-A can be used as HOME - returning cursor to beginning of
        current line buffer.
        srint "hello"p�
print "hello"c�*���jdg�y�Ns>>> print "hello"rd��ignorer$s �r�cbz.ManholeLoopbackMixin.test_controlA.<locals>.cbn������� 4�5�6rr��r$r�r�s`  r�
test_controlAz"ManholeLoopbackMixin.test_controlAfs?���
	
���8�9����&�&�'7�8��	7��}�}�R� � rc����jd��jjd�}�fd�}|j|�S)zc
        CTRL-E can be used as END - setting cursor to end of current
        line buffer.
        srint "hellop"r�c�*���jdg�yr�rdr�s �rr�z.ManholeLoopbackMixin.test_controlE.<locals>.cb{r�rr�r�s`  r�
test_controlEz"ManholeLoopbackMixin.test_controlEss?���
	
���H�I����&�&�'7�8��	7��}�}�R� � rc#�$K�|jd�|jjd���|jd�|jjd���|jjd���|jgd��y�w)z�
        When a deferred is returned to the manhole REPL, it is displayed with
        a sequence number, and when the deferred fires, the result is printed.
        sCfrom twisted.internet import defer, reactor
d = defer.Deferred()
d
�
<Deferred #0>s.c = reactor.callLater(0.1, d.callback, 'Hi!')
r�s#Deferred #0 called back: 'Hi!'
>>> )s/>>> from twisted.internet import defer, reactors>>> d = defer.Deferred()s>>> dr�s1>>> c = reactor.callLater(0.1, d.callback, 'Hi!')sDeferred #0 called back: 'Hi!'r�N)rlrjrkrer<s r�
test_deferredz"ManholeLoopbackMixin.test_deferred�s�����	
���
�	
��!�!�(�(�)9�:�:����J�K��!�!�(�(��1�1��!�!�(�(�)P�Q�Q����
�
	
�s�BBN)r'r(r)r�ColoredManhole�serverProtocolrprsrIrLr}r�r�r�r�r�inlineCallbacksr�r�r�r�r�rrrr]r]�s����+�+�N�*�*�*�,*�8�.%�
*��0S�&���:��:�(���/��/�"!�!����
��
rr]c��eZdZdZy)�ManholeLoopbackTelnetTestsz,
    Test manhole loopback over Telnet.
    N)r'r(r)r*rrrr�r��s���	rr�c��eZdZdZe�dZyy)�ManholeLoopbackSSHTestsz)
    Test manhole loopback over SSH.
    Nz!cryptography requirements missing)r'r(r)r*r�skiprrrr�r��s����{�2��rr�c�2�eZdZdZe�dZyejZy)�ManholeLoopbackStdioTestsz1
    Test manhole loopback over standard IO.
    N�Terminal requirements missing)r'r(r)r*r
r��ConsoleManholer�rrrr�r��s���
�}�.���-�-�rr�c��eZdZdZe�dZd�Zy)�ManholeMainTestsz=
    Test the I{main} method from the I{manhole} module.
    Nr�c��|jttjdg��}|j	d|j
d�y)z�
        Will raise an exception when called with an argument which is a
        dotted patch which can not be imported..
        z
no-such-class)�argvzEmpty module namerN)�assertRaises�
ValueErrorr
�mainrZr�)r$�	exceptions  r�test_mainClassNotFoundz'ManholeMainTests.test_mainClassNotFound�sE��
�%�%���J�J�!�"�&�
�	�	
���,�i�n�n�Q�.?�@r)r'r(r)r*r
r�r�rrrr�r��s���
�}�.��Arr�)#r*r�r�typingrr�bool�__annotations__�
twisted.conchr�twisted.conch.insultsr� twisted.conch.test.test_recvlinerrr	r
�twisted.internetrr�twisted.internet.testingr
�
twisted.trialrrr{�TestCaserr,r8r]r�r�r�r�rrr�<module>r�s���������X�d�^��!�)���*�4�"�0�3�4��-�h�/�/�-�-�8�,�,�-�(?
�(�#�#�?
�DG
�G
�T	��x�/@�/@�BV�	�3�i��):�):�<P�3�.��X�->�->�@T�.�A�x�(�(�Ar

Zerion Mini Shell 1.0