%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlmZddlmZddlmZej�sddlm	Z	Gd�de�Z
e�je
j��y)	z&
Tests for L{twisted.internet.stdio}.
�)�Protocol)�ReactorBuilder)�platform)�
StandardIOc�h�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zej�rd
Zyy)�StdioFilesTestszI
    L{StandardIO} supports reading and writing to filesystem files.
    c���|j�}t|d�j�t|d�|_|j	|jj�y)N�wbzrb+)�mktemp�open�close�	extraFile�
addCleanup)�self�paths  �B/usr/lib/python3/dist-packages/twisted/internet/test/test_stdio.py�setUpzStdioFilesTests.setUpsD���{�{�}���T�4���� ��d�E�*���������,�,�-�c����|j��G�fd�dt�}|j�}t|d�5}|j	d�ddd�t|d�5}|�}t||j
�|jj
����|j��ddd�|jjd�y#1swY��xYw#1swY�2xYw)zc
        Adding a filesystem file reader to a reactor will make sure it is
        polled.
        c���eZdZdZ�fd�Zy)�4StdioFilesTests.test_addReader.<locals>.DataProtocolrc�p��|xj|z
c_|jdk(r�j�yy)N�hello!)�data�stop)rr�reactors  �r�dataReceivedzAStdioFilesTests.test_addReader.<locals>.DataProtocol.dataReceived&s-����	�	�T�!�	��9�9�	�)��L�L�N�*rN)�__name__�
__module__�__qualname__rr�rs�r�DataProtocolr#s
����D�
#rr"r
rN�rb��stdin�stdoutr)�buildReactorrrr�writer�filenor�
runReactor�assertEqualr)rr"r�f�protocolrs     @r�test_addReaderzStdioFilesTests.test_addReaders����
�#�#�%��		#�8�		#��{�{�}��
�$��
�	��
�G�G�I��	��$��
�		%��#�~�H����h�h�j��~�~�,�,�.��	
�
�O�O�G�$�		%�	
������	�2�	�	��		%�		%�s�C�%AC$�C!�$C-c�f��|j��G�fd�dt�}|j�}t|d�5}|�}t	||j�|jj����|jjd�|jjd�|jj�|j��ddd�t|d�5}|j|j�d	�ddd�y#1swY�?xYw#1swYyxYw)
zc
        Adding a filesystem file writer to a reactor will make sure it is
        polled.
        c���eZdZ�fd�Zy)�:StdioFilesTests.test_addWriter.<locals>.DisconnectProtocolc�&���j�y)N)r)r�reasonrs  �r�connectionLostzIStdioFilesTests.test_addWriter.<locals>.DisconnectProtocol.connectionLostHs������rN)rrr r4r!s�r�DisconnectProtocolr1Gs���
rr5r
�r&r%r�hellos, worldNr#shello, world)
r'rrrrr)r�	transportr(�loseConnectionr*r+�read)rr5rr,r-rs     @r�test_addWriterzStdioFilesTests.test_addWriter@s���
�#�#�%��	��	��{�{�}��
�$��
�	%��*�+�H����x�x�z��n�n�+�+�-��	
�
���$�$�X�.����$�$�Z�0����-�-�/��O�O�G�$�	%� �$��
�	8�����Q�V�V�X��7�	8�	8�!	%�	%�� 	8�	8�s�BD�1!D'�D$�'D0c��|j�}|j�}t|d�j�t|d�5}t	t�|j
�|jj
�|��}|j|j|j��|jj�|j|j|j��ddd�y#1swYyxYw)zq
        Removing a filesystem file reader from a reactor will make sure it is
        no longer polled.
        r
r#r$N)
r'rrr
rrr)r�assertIn�_reader�
getReaders�stopReading�assertNotIn�rrrr,�stdios     r�test_removeReaderz!StdioFilesTests.test_removeReader`s���
�#�#�%���{�{�}���T�4���� �
�$��
�
	B����
��h�h�j��~�~�,�,�.��	�E�
�M�M�%�-�-��);�);�)=�>��M�M�%�%�'����U�]�]�G�,>�,>�,@�A�
	B�
	B�
	B�s
�B,C<�<Dc��|j�}t|j�d�x|_}t	�}t||j
�|jj
�|��}|jjd�|j|j|j��|jj�|j|j|j��y)zq
        Removing a filesystem file writer from a reactor will make sure it is
        no longer polled.
        r
r6r7N)r'rrr,rrr)rr8r(r=�_writer�
getWriters�stopWritingrA)rrr,r-rCs     r�test_removeWriterz!StdioFilesTests.test_removeWritervs���
�#�#�%���$�+�+�-��.�.�����:����Q�X�X�Z�t�~�~�/D�/D�/F�PW�
��	��� � ��*��
�
�e�m�m�W�%7�%7�%9�:�
�
�
�!�!�#��������(:�(:�(<�=rc���|j�}|j�}t|d�j�t|d�x|_}tt
�|j�|jj�|��}|j�}|j|j|�|j|j|j��y)zk
        Calling C{removeAll} on a reactor includes descriptors that are
        filesystem files.
        r
r#r$N)r'rrr
r,rrr)r�	removeAllr=r>rAr?)rrrr,rC�removeds      r�test_removeAllzStdioFilesTests.test_removeAll�s���
�#�#�%���{�{�}���T�4���� ��$��%�%������J��(�(�*��>�>�(�(�*��	
���#�#�%���
�
�e�m�m�W�-��������(:�(:�(<�=rc��|j�}|j�}t|d�j�t|d�5}t	t�|j
�|jj
�|��}|j|j|j��ddd�y#1swYyxYw)zW
        C{reactor.getReaders} includes descriptors that are filesystem files.
        r
r#r$N)r'rrr
rrr)rr=r>r?rBs     r�test_getReaderszStdioFilesTests.test_getReaders�s����#�#�%���{�{�}���T�4���� ��$��
�	?����
��h�h�j��~�~�,�,�.��	�E�
�M�M�%�-�-��);�);�)=�>�	?�	?�	?�s
�A(B8�8Cc��|j�}t|j�d�x|_}t	t�|j
�|jj
�|��}|j|j|j��|jj�|j|j|j��y)zW
        C{reactor.getWriters} includes descriptors that are filesystem files.
        r
r6N)
r'rrr,rrr)rrArFrG�startWritingr=)rrr,rCs    r�test_getWriterszStdioFilesTests.test_getWriters�s����#�#�%���$�+�+�-��.�.������J��8�8�:��.�.�'�'�)��	
��	
�������(:�(:�(<�=�
�
�
�"�"�$��
�
�e�m�m�W�%7�%7�%9�:rzoStandardIO does not accept stdout as an argument to Windows. Testing redirection to a file is therefore harder.N)rrr �__doc__rr.r;rDrIrMrOrRr�	isWindows�skip�rrrrsR���.�"3�H8�@B�,>�(>�2?�(;�(�x����
A�	
�rrN)rS�twisted.internet.protocolr�#twisted.internet.test.reactormixinsr�twisted.python.runtimerrT�twisted.internet.stdiorr�globals�update�makeTestCaseClassesrVrr�<module>r^sP���
/�>�+��x����1�~
�n�~
�B�	����4�4�6�7r

Zerion Mini Shell 1.0