Your IP : 216.73.216.213


Current Path : /opt/alt/python33/lib64/python3.3/test/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/test/__pycache__/test_file_eintr.cpython-33.pyc

�
��f[(c@s�ddlZddlZddlZddlZddlZddlmZddlZddlZddl	m
Z
ejejdkd�Gdd�dej
��ZGdd	�d	e�ZGd
d�de�Zdd
�Zedkr�e�ndS(iN(urun_unittest(uFileIOuposixutests requires a posix system.cBs�|EeZdZdd�Zdd�Zdd�Zddddd	�Zd
d�ZdZ	d
d�Z
dd�Zdd�ZdS(uTestFileIOSignalInterruptcCs
d|_dS(N(uNoneu_process(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyusetUpsuTestFileIOSignalInterrupt.setUpcCsK|jrG|jj�dkrGy|jj�WqGtk
rCYqGXndS(N(u_processupolluNoneukilluOSError(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyutearDowns

u"TestFileIOSignalInterrupt.tearDowncCsdS(u�Returns the infile = ... line of code for the reader process.

        subclasseses should override this to test different IO objects.
        u9import _io ;infile = _io.FileIO(sys.stdin.fileno(), "rb")((uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu_generate_infile_setup_code$su5TestFileIOSignalInterrupt._generate_infile_setup_codesc
Cs�|jj�dkrKtjd�y|jj�WqKtk
rGYqKXn|r}|jj�\}}||7}||7}n|jd||j	�|j	�f�dS(u;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.
        g�������?u/Error from IO process %s:
STDOUT:
%sSTDERR:
%s
N(
u_processupolluNoneutimeusleepu	terminateuOSErrorucommunicateufailudecode(uselfuwhyustdoutustderrucommunicateu
stdout_endu
stderr_end((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyufail_with_process_info,s



	u0TestFileIOSignalInterrupt.fail_with_process_infocCs�|j�}t|�dks*td��tjtjddd|dd|ddgd	tjd
tjdtj�|_|jj	j
td��}|dkr�|jd
d|�n|jjj
|�d}g}xz|sVtj|jj	gffd�\}}}|jjtj�|d7}|dkr�|jj�|jd�q�q�W|jj	j�}|dkr�|jdd|�n|jjdd�\}	}
|jjr�|jd|jj|	|
dd�ndS(unGeneric 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.
        iu#data_to_write must fit in pipe buf.u-uu-cuXimport signal, sys ;signal.signal(signal.SIGINT, lambda s, f: sys.stderr.write("$\n")) ;u ;u"sys.stderr.write("Worm Sign!\n") ;uinfile.close()ustdinustdoutustderrsWorm Sign!
uwhile awaiting a signig�������?ii�u,reader process failed to handle our signals.s$
uwhile awaiting signaluinputs
uexited rc=%ducommunicateNF(u_generate_infile_setup_codeulenuAssertionErroru
subprocessuPopenusysu
executableuPIPEu_processustderrureadufail_with_process_infoustdinuwriteuselectusend_signalusignaluSIGINTukillufailureadlineucommunicateu
returncodeuFalse(uselfu
data_to_writeuread_and_verify_codeuinfile_setup_codeu	worm_signusignals_senturlistu_usignal_lineustdoutustderr((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu
_test_readingGs>


	*



u'TestFileIOSignalInterrupt._test_readingu�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	Cs/|jddd|jjdddd��dS(	u1readline() must handle signals and not lose data.u
data_to_writes
hello, world!uread_and_verify_codeuread_method_nameureadlineuexpectedshello, world!
N(u
_test_readingu_READING_CODE_TEMPLATEuformat(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu
test_readline�s
	u'TestFileIOSignalInterrupt.test_readlinec
Cs5|jddd|jjdddddg��d	S(
u2readlines() must handle signals and not lose data.u
data_to_writeshello
world!uread_and_verify_codeuread_method_nameu	readlinesuexpectedshello
sworld!
N(u
_test_readingu_READING_CODE_TEMPLATEuformat(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyutest_readlines�s
	u(TestFileIOSignalInterrupt.test_readlinesc	CsZ|jddd|jjdddd��|jddd|jjdddd��d	S(
u0readall() must handle signals and not lose data.u
data_to_writeshello
world!uread_and_verify_codeuread_method_nameureadalluexpecteds
hello
world!
ureadN(u
_test_readingu_READING_CODE_TEMPLATEuformat(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyutest_readall�s	
	u&TestFileIOSignalInterrupt.test_readallNT(
u__name__u
__module__u__qualname__usetUputearDownu_generate_infile_setup_codeuTrueufail_with_process_infou
_test_readingu_READING_CODE_TEMPLATEu
test_readlineutest_readlinesutest_readall(u
__locals__((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyuTestFileIOSignalInterruptsIuTestFileIOSignalInterruptcBs,|EeZdZdd�Zdd�ZdS(uTestBufferedIOSignalInterruptcCsdS(u?Returns the infile = ... line of code to make a BufferedReader.ubinfile = open(sys.stdin.fileno(), "rb") ;import _io ;assert isinstance(infile, _io.BufferedReader)((uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu_generate_infile_setup_code�su9TestBufferedIOSignalInterrupt._generate_infile_setup_codec	Cs/|jddd|jjdddd��dS(	u<BufferedReader.read() must handle signals and not lose data.u
data_to_writeshello
world!uread_and_verify_codeuread_method_nameureaduexpecteds
hello
world!
N(u
_test_readingu_READING_CODE_TEMPLATEuformat(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyutest_readall�s
	u*TestBufferedIOSignalInterrupt.test_readallN(u__name__u
__module__u__qualname__u_generate_infile_setup_codeutest_readall(u
__locals__((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyuTestBufferedIOSignalInterrupt�suTestBufferedIOSignalInterruptcBsD|EeZdZdd�Zdd�Zdd�Zdd�Zd	S(
uTestTextIOSignalInterruptcCsdS(u>Returns the infile = ... line of code to make a TextIOWrapper.uoinfile = open(sys.stdin.fileno(), "rt", newline=None) ;import _io ;assert isinstance(infile, _io.TextIOWrapper)((uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu_generate_infile_setup_code�su5TestTextIOSignalInterrupt._generate_infile_setup_codec	Cs/|jddd|jjdddd��dS(	u1readline() must handle signals and not lose data.u
data_to_writes
hello, world!uread_and_verify_codeuread_method_nameureadlineuexpecteduhello, world!
N(u
_test_readingu_READING_CODE_TEMPLATEuformat(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu
test_readline�s
	u'TestTextIOSignalInterrupt.test_readlinec
Cs5|jddd|jjdddddg��d	S(
u2readlines() must handle signals and not lose data.u
data_to_writes
hello
world!uread_and_verify_codeuread_method_nameu	readlinesuexpecteduhello
uworld!
N(u
_test_readingu_READING_CODE_TEMPLATEuformat(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyutest_readlines�s
	u(TestTextIOSignalInterrupt.test_readlinesc	Cs/|jddd|jjdddd��dS(	u-read() must handle signals and not lose data.u
data_to_writeshello
world!uread_and_verify_codeuread_method_nameureaduexpectedu
hello
world!
N(u
_test_readingu_READING_CODE_TEMPLATEuformat(uself((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyutest_readall�s
	u&TestTextIOSignalInterrupt.test_readallN(u__name__u
__module__u__qualname__u_generate_infile_setup_codeu
test_readlineutest_readlinesutest_readall(u
__locals__((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyuTestTextIOSignalInterrupt�suTestTextIOSignalInterruptcCs*dd�t�j�D�}t|�dS(NcSs7g|]-}t|t�rt|tj�r|�qS((u
isinstanceutypeu
issubclassuunittestuTestCase(u.0utc((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu
<listcomp>�s	utest_main.<locals>.<listcomp>(uglobalsuvaluesurun_unittest(u
test_cases((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu	test_main�su	test_mainu__main__(uosuselectusignalu
subprocessusysutest.supporturun_unittestutimeuunittestu_iouFileIOu
skipUnlessunameuTestCaseuTestFileIOSignalInterruptuTestBufferedIOSignalInterruptuTestTextIOSignalInterruptu	test_mainu__name__(((u9/opt/alt/python33/lib64/python3.3/test/test_file_eintr.pyu<module>s%�