%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f���`�dZddlmZddlmZmZmZddlZddl	m
Z
ddlmZddl
mZmZddlmZd	d
lmZd	dlmZd	dlmZd	d
lmZmZd	dlmZddlmZddlmZGd�dej@jBjD�Z#Gd�dej@jBjD�Z$y)z0
Tests for L{twisted.application.twist._twist}.
�)�stdout)�Any�Dict�ListN)�IReactorCore)�
MemoryReactor)�LogLevel�jsonFileLogObserver)�SignalCapturingMemoryReactor�)�
ExitStatus)�Runner)�	DummyExit)�IService�MultiService)�_twist�)�TwistOptions)�Twistc�`�eZdZdZd
d�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Z	d
d	�Z
d
d
�Zd
d�Zd
d�Z
y)�
TwistTestsz
    Tests for L{Twist}.
    Nc�$�|j�y�N)�patchInstallReactor��selfs �K/usr/lib/python3/dist-packages/twisted/application/twist/test/test_twist.py�setUpzTwistTests.setUps��� � �"�c�d�t�|_|jtd|j�y)zX
        Patch L{_twist.exit} so we can capture usage and prevent actual exits.
        �exitN)rr!�patchrrs r�	patchExitzTwistTests.patchExit!s!���K��	��
�
�6�6�4�9�9�-rc�r��i�_dtdtdtf�fd�}�j	td|�y)zo
        Patch C{_options.installReactor} so we can capture usage and prevent
        actual installs.
        �_�name�returnc�:��t�}|�j|<|Sr)r�installedReactors)r%r&�reactorrs   �r�installReactorz6TwistTests.patchInstallReactor.<locals>.installReactor/s���#�o�G�+2�D�"�"�4�(��Nrr+N)r)r�strrr")rr+s` rrzTwistTests.patchInstallReactor(s:���
;=���	�l�	�#�	�,�	�
	
�
�
�<�!1�>�Brc�^��g�_dtddf�fd�}�jtd|�y)zo
        Patch L{MultiService.startService} so we can capture usage and prevent
        actual starts.
        �servicer'Nc�<���jj|�yr)�
serviceStarts�append)r.rs �r�startServicez2TwistTests.patchStartService.<locals>.startService=s������%�%�g�.rr2)r0rr"r)rr2s` r�patchStartServicezTwistTests.patchStartService6s2���
.0���	/�(�	/�t�	/�	
�
�
�<���>rc�^�tjddg�}|j|t�y)zI
        L{Twist.options} given valid arguments returns options.
        �twist�webN)r�options�assertIsInstancer)rr7s  r�test_optionsValidArgumentsz%TwistTests.test_optionsValidArgumentsBs'���-�-��%� 0�1�����g�|�4rc���|j�tjddg�|j|jj
tj�|j|jj�|j|jjjd��|j|jjjdt�����y)z�
        L{Twist.options} given invalid arguments exits with
        L{ExitStatus.EX_USAGE} and an error/usage message.
        r5z--bogus-bagelszError: z

N)r#rr7�assertIdenticalr!�statusr
�EX_USAGE�assertIsNotNone�message�
assertTrue�
startswith�endswithrrs r�test_optionsInvalidArgumentsz'TwistTests.test_optionsInvalidArgumentsJs���
	
����
�
�
�w� 0�1�2����T�Y�Y�-�-�z�/B�/B�C����T�Y�Y�.�.�/�����I�I���(�(��3�	
�	
����I�I���&�&��|�~�&�'�
�	
rc���tjddg�}tj|jd|j�}|jt
j|��y)z:
        L{Twist.service} returns an L{IService}.
        r5r6N)rr7r.�plugins�
subOptionsr@r�
providedBy)rr7r.s   r�test_servicezTwistTests.test_service^sM���-�-��%� 0�1���-�-����� 6��8J�8J�K������+�+�G�4�5rc��tjddg�}|d}|j}|�J�tj|j||j
��}|j
�tj||�|j|j|g�|j|jdd|jdifg�y)	z�
        L{Twist.startService} starts the service and registers a trigger to
        stop the service when the reactor shuts down.
        r5r6r*N)�pluginr7�before�shutdown�)rr7�
subCommandr.rErFr3r2�assertEqualr0�triggers�stopService)rr7r*rNr.s     r�test_startServicezTwistTests.test_startServicefs���
�-�-��%� 0�1���)�$���'�'�
��%�%�%��-�-��?�?�:�.��&�&�
��
	
��� �
���7�G�,�����+�+�g�Y�7�������X�&�z�2�g�6I�6I�2�r�5R�4S�	
rc	���g�|jtd�fd��|jtdd��tjgd��}tj|�|jt
��d�|j�dt|jdtjtt�	��y
)zi
        L{Twist.run} runs the runner with arguments corresponding to the given
        options.
        �__init__c�&���j|�Sr)r1)r�args�argsSeens  �r�<lambda>z%TwistTests.test_run.<locals>.<lambda>�s���H�O�O�D�<Q�r�runc��yrrMrs rrXz%TwistTests.test_run.<locals>.<lambda>���r�r5z--reactor=defaultz--log-format=jsonr6�r�default�r*�defaultLogLevel�logFile�fileLogObserverFactoryN)
r"rrr7rYrO�len�dictr)r	�inforr
)r�twistOptionsrWs  @r�test_runzTwistTests.test_run~s����
���
�
�6�:�'Q�R��
�
�6�5�"3�4��}�}�F�
��	�	�	�,������X���*�����Q�K���.�.�y�9� (�
�
��':�	
�	
rc	���|j�g�G�fd�d�}|jtd|�tjgd��|jt
|j�d�|jt
��d�|j�djt|jdtjtt���|j�djd�y)	zy
        L{Twist.main} runs the runner with arguments corresponding to the given
        command line arguments.
        c�*��eZdZdeddf�fd�Zdd�Zy)�$TwistTests.test_main.<locals>.Runner�kwargsr'Nc�D��||_d|_�j|�y)Nr)rV�runsr1)rrk�runnerss  �rrTz-TwistTests.test_main.<locals>.Runner.__init__�s���"��	���	����t�$rc�.�|xjdz
c_y)Nr])rmrs rrYz(TwistTests.test_main.<locals>.Runner.run�s���	�	�Q��	r�r'N)�__name__�
__module__�__qualname__rrTrY)rns�rrrj�s���
%��
%��
%�

rrr\r]rr^r_N)r3r"rr�mainrOrcr0rVrdr)r	rerr
rm)rrrns  @r�	test_mainzTwistTests.test_main�s����
	
��� ���	�	�	
�
�
�6�8�V�,�
�
�
�M�N�����T�/�/�0�!�4�����W��q�)�����A�J�O�O���.�.�y�9� (�
�
��':�	
�	
�	
��������!�,rrp)rqrrrs�__doc__rr#rr3r9rCrHrRrgrurMrrrrs:���#�.�C�
?�5�
�(6�
�0
�4!-rrc�0�eZdZdZdd�Zdd�Zdd�Zdd�Zy)�TwistExitTestszr
    Tests to verify that the Twist script takes the expected actions related
    to signals and the reactor.
    Nc���d�_dtddf�fd�}�jtd|�dtddfd�}�jtd|�y)	NF�sigr'c���d�_y)z�
            Fake to capture whether L{twisted.application._exitWithSignal
            was called.

            @param sig: Signal value
            @type sig: C{int}
            TN)�exitWithSignalCalled)rzrs �r�fakeExitWithSignalz0TwistExitTests.setUp.<locals>.fakeExitWithSignal�s
���)-�D�%r�_exitWithSignalr%c��y)z�
            Prevent Runner from adding new log observers or other
            tests outside this module will fail.

            @param _: Unused self param
            NrM)r%s r�startLoggingz*TwistExitTests.setUp.<locals>.startLogging�r[rr�)r|�intr"rr)rr}r�s`  rrzTwistExitTests.setUp�sW���$)��!�	-�C�	-�D�	-�	
�
�
�6�,�.@�A�	�F�	�t�	�	
�
�
�6�>�<�8rc��t�}d|_t�}||d<t|d<t	j
|�|j
|j�y)zg
        _exitWithSignal is not called if the reactor's _exitSignal attribute
        is zero.
        Nr*rb)r�_exitSignalrr
rrY�assertFalser|�rr*r7s   r�%test_twistReactorDoesntExitWithSignalz4TwistExitTests.test_twistReactorDoesntExitWithSignal�sP��
/�0��"����.��$��	��,?��(�)�
�	�	�'������2�2�3rc��t�}t�}||d<t|d<tj|�|j|j�y)z�
        _exitWithSignal is not called if the runner's reactor does not
        implement L{twisted.internet.interfaces._ISupportsExitSignalCapturing}
        r*rbN)rrr
rrYr�r|r�s   r�$test_twistReactorHasNoExitSignalAttrz3TwistExitTests.test_twistReactorHasNoExitSignalAttr�sG��
 �/���.��$��	��,?��(�)�
�	�	�'������2�2�3rc��t�}d|_t�}||d<t|d<t	j
|�|j
|j�y)zb
        _exitWithSignal is called if the runner's reactor exits due
        to a signal.
        rr*rbN)rr�rr
rrYr@r|r�s   r� test_twistReactorExitsWithSignalz/TwistExitTests.test_twistReactorExitsWithSignal�sN��
/�0������.��$��	��,?��(�)�
�	�	�'������1�1�2rrp)rqrrrsrvrr�r�r�rMrrrxrx�s���
9�24�
4�3rrx)%rv�sysr�typingrrr�twisted.trial.unittest�twisted�twisted.internet.interfacesr�twisted.internet.testingr�twisted.loggerr	r
�twisted.test.test_twistdr�runner._exitr
�runner._runnerr�runner.test.test_runnerrr.rrr5r�_optionsrr�trial�unittest�TestCaserrxrMrr�<module>r�sv����"�"��4�2�8�A�&�$�0�-��#��`-����'�'�0�0�`-�FD3�W�]�]�+�+�4�4�D3r

Zerion Mini Shell 1.0