Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_file_eintr.cpython-312.pyc

�

'Μg�*��P�ddlZddlZddlZddlZddlZddlZddlZddlmZejsejd��ddlZddlZejejdk(d�Gd�d��ZGd�d	eej �ZGd
�deej �ZGd�d
e�ZGd�deej �ZGd�deej �ZGd�de�ZGd�deej �ZGd�deej �Zedk(rej4�yy)�N)�supportztest module requires subprocess�posixztests requires a posix system.c�F�eZdZd�Zd�Zd�Z		dd�Zd�ZdZd�Z	d�Z
d	�Zy
)�TestFileIOSignalInterruptc��d|_y�N)�_process��selfs �1/usr/local/lib/python3.12/test/test_file_eintr.py�setUpzTestFileIOSignalInterrupt.setUps	����
�c��|jr7|jj��	|jj�yyy#t$rYywxYwr)r	�poll�kill�OSErrorr
s r�tearDownz"TestFileIOSignalInterrupt.tearDown sK���=�=�T�]�]�/�/�1�9�
��
�
�"�"�$�:�=���
��
�s�A�	A�Ac� �d|jzS)z�Returns the infile = ... line of code for the reader process.

        subclasseses should override this to test different IO objects.
        z=import %s as io ;infile = io.FileIO(sys.stdin.fileno(), "rb")��modnamer
s r�_generate_infile_setup_codez5TestFileIOSignalInterrupt._generate_infile_setup_code's��
?�����	rc	�v�|jj��0tjd�	|jj	�|r'|jj
�\}}||z
}||z
}|jd|�d|j��d|j��d��y#t
$rY�lwxYw)a;A common way to cleanup and fail with useful debug output.

        Kills the process if it is still running, collects remaining output
        and fails the test with an error message including the output.

        Args:
            why: Text to go after "Error from IO process" in the message.
            stdout, stderr: standard output and error from the process so
                far to include in the error message.
            communicate: bool, when True we call communicate() on the process
                after killing it to gather additional output.
        Ng�������?zError from IO process z
:
STDOUT:
zSTDERR:
�
)	r	r�time�sleep�	terminater�communicate�fail�decode)r�why�stdout�stderrr�
stdout_end�
stderr_ends       r�fail_with_process_infoz0TestFileIOSignalInterrupt.fail_with_process_info0s����=�=����'��J�J�s�O�
��
�
�'�'�)��%)�]�]�%>�%>�%@�"�J�
��j� �F��j� �F��	�	���
�
������:�	;��
�
��
�s�B,�,	B8�7B8c�h�|j�}t|�dksJd��tjtj
ddd|zdzdz|zdzdzgtjtjtj�	�|_|jjjtd
��}|d
k7r|jd|��|jjj|�d
}g}|s�tj|jjgddd�\}}}|jjtj �|dz
}|dkDr+|jj#�|j%d�|s��|jjj'�}|dk7r|jd|��|jj)d��\}	}
|jj*r-|jd|jj*z|	|
d��yy)anGeneric buffered read method test harness to validate EINTR behavior.

        Also validates that Python signal handlers are run during the read.

        Args:
            data_to_write: String to write to the child process for reading
                before sending it a signal, confirming the signal was handled,
                writing a final newline and closing the infile pipe.
            read_and_verify_code: Single "line" of code to read from a file
                object named 'infile' and validate the result.  This will be
                executed as part of a python subprocess fed data_to_write.
        iz#data_to_write must fit in pipe buf.z-uz-czXimport signal, sys ;signal.signal(signal.SIGINT, lambda s, f: sys.stderr.write("$\n")) ;z ;z"sys.stderr.write("Worm Sign!\n") ;zinfile.close())�stdinr!r"sWorm Sign!
zwhile awaiting a sign)r"r�g�������?���z,reader process failed to handle our signals.s$
zwhile awaiting signal�
)�inputzexited rc=%dF)rN)r�len�
subprocess�Popen�sys�
executable�PIPEr	r"�readr%r'�write�select�send_signal�signal�SIGINTrr�readliner�
returncode)r�
data_to_write�read_and_verify_code�infile_setup_code�	worm_sign�signals_sent�rlist�_�signal_liner!r"s           r�
_test_readingz'TestFileIOSignalInterrupt._test_readingKs��!�<�<�>���=�!�C�'�N�)N�N�'�#�(�(�����t�J�%�%�(,�,�7�	7�
(�(�
+/�/�"�
"��!�o�o�j�o�o�!���(��
��M�M�(�(�-�-�c�/�.B�C�	���'��'�'�(?�/8�
(�
:��
�
���!�!�-�0������ �-�-����)=�)=�(>��B��M�K�E�1�a��M�M�%�%�f�m�m�4��A��L��c�!��
�
�"�"�$��	�	�H�I�
��m�m�*�*�3�3�5���&� ��'�'�(?�/:�
(�
<����2�2��2�?�����=�=�#�#��'�'�"�T�]�]�%=�%=�=��F��
(�
7�$rz�got = infile.{read_method_name}() ;expected = {expected!r} ;assert got == expected, ("{read_method_name} returned wrong data.\n""got data %r\nexpected %r" % (got, expected))c�`�|jd|jjdd����y)�1readline() must handle signals and not lose data.�
hello, world!r9shello, world!
��read_method_name�expected�r;r<N�rC�_READING_CODE_TEMPLATE�formatr
s r�
test_readlinez'TestFileIOSignalInterrupt.test_readline�s8�����.�%)�%@�%@�%G�%G�)3�!3�&H�&5�	�	6rc�d�|jd|jjdddg����y)�2readlines() must handle signals and not lose data.�hello
world!�	readlinesshello
sworld!
rGrJNrKr
s r�test_readlinesz(TestFileIOSignalInterrupt.test_readlines�s=�����.�%)�%@�%@�%G�%G�)4�",�k�!:�&H�&<�	�	=rc��|jd|jjdd����|jd|jjdd����y)z0readall() must handle signals and not lose data.rQ�readall�
hello
world!
rGrJr3NrKr
s r�test_readallz&TestFileIOSignalInterrupt.test_readall�sp�����.�%)�%@�%@�%G�%G�)2�!3�&H�&5�	�	6�	
���.�%)�%@�%@�%G�%G�)/�!3�&H�&5�	�	6rN)rrT)�__name__�
__module__�__qualname__r
rrr%rCrLrNrSrWr(rrrrs@�����>A�+/�;�6D7�R
E��6�=�6rrc��eZdZdZy)�CTestFileIOSignalInterrupt�_ioN�rXrYrZrr(rrr\r\�����Grr\c��eZdZdZy)�PyTestFileIOSignalInterrupt�_pyioNr^r(rrrara�����Grrac��eZdZd�Zd�Zy)�TestBufferedIOSignalInterruptc� �d|jzS)z?Returns the infile = ... line of code to make a BufferedReader.ziimport %s as io ;infile = io.open(sys.stdin.fileno(), "rb") ;assert isinstance(infile, io.BufferedReader)rr
s rrz9TestBufferedIOSignalInterrupt._generate_infile_setup_code�s��?�����	rc�`�|jd|jjdd����y)z<BufferedReader.read() must handle signals and not lose data.rQr3rVrGrJNrKr
s rrWz*TestBufferedIOSignalInterrupt.test_readall�s8�����.�%)�%@�%@�%G�%G�)/�!3�&H�&5�	�	6rN)rXrYrZrrWr(rrrere�s���6rrec��eZdZdZy)�CTestBufferedIOSignalInterruptr]Nr^r(rrriri�r_rric��eZdZdZy)�PyTestBufferedIOSignalInterruptrbNr^r(rrrkrk�rcrrkc�$�eZdZd�Zd�Zd�Zd�Zy)�TestTextIOSignalInterruptc� �d|jzS)z>Returns the infile = ... line of code to make a TextIOWrapper.z�import %s as io ;infile = io.open(sys.stdin.fileno(), encoding="utf-8", newline=None) ;assert isinstance(infile, io.TextIOWrapper)rr
s rrz5TestTextIOSignalInterrupt._generate_infile_setup_code�s��>�����	rc�`�|jd|jjdd����y)rErFr9zhello, world!
rGrJNrKr
s rrNz'TestTextIOSignalInterrupt.test_readline�s8�����.�%)�%@�%@�%G�%G�)3�!2�&H�&4�	�	5rc�d�|jd|jjdddg����y)rPs
hello
world!rRzhello
zworld!
rGrJNrKr
s rrSz(TestTextIOSignalInterrupt.test_readlines�s=�����0�%)�%@�%@�%G�%G�)4�"+�Z�!8�&H�&:�	�	;rc�`�|jd|jjdd����y)z-read() must handle signals and not lose data.rQr3z
hello
world!
rGrJNrKr
s rrWz&TestTextIOSignalInterrupt.test_readall�s8�����.�%)�%@�%@�%G�%G�)/�!2�&H�&4�	�	5rN)rXrYrZrrNrSrWr(rrrmrm�s���5�;�5rrmc��eZdZdZy)�CTestTextIOSignalInterruptr]Nr^r(rrrsrs�r_rrsc��eZdZdZy)�PyTestTextIOSignalInterruptrbNr^r(rrruru�rcrru�__main__)�osr5r7r.r0r�unittest�testr�has_subprocess_support�SkipTestr]rb�
skipUnless�namer�TestCaser\rarerirkrmrsrurX�mainr(rr�<module>r�s,��
�
�
��
�����%�%�
�(�
�
�=�
>�>�������R�W�W��'�)I�J�[6�[6�K�[6�|�!:�H�<M�<M���";�X�=N�=N��
6�$=�
6��%B�H�DU�DU���&C�X�EV�EV��5� 9�5�@�!:�H�<M�<M���";�X�=N�=N���z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists