%PDF- %PDF-
Direktori : /usr/local/lib/python2.7/test/ |
Current File : //usr/local/lib/python2.7/test/test_file_eintr.pyo |
ó Nêáac @ s÷ d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l Z d d l Z d d l m Z e j e j d k d ƒ d e j f d „ ƒ Yƒ Z d e f d „ ƒ YZ d e f d „ ƒ YZ d „ Z e d k ró e ƒ n d S( iÿÿÿÿN( t run_unittest( t FileIOt posixs tests requires a posix system.t TestFileIOSignalInterruptc B s_ e Z d „ Z d „ Z d „ Z d d e d „ Z d „ Z d Z d „ Z d „ Z d „ Z RS( c C s d | _ d S( N( t Nonet _process( t self( ( s0 /usr/local/lib/python2.7/test/test_file_eintr.pyt setUp s c C sJ | j rF | j j ƒ d k rF y | j j ƒ WqF t k rB qF Xn d S( N( R t pollR t killt OSError( R ( ( s0 /usr/local/lib/python2.7/test/test_file_eintr.pyt tearDown s c C s d S( s Returns the infile = ... line of code for the reader process. subclasseses should override this to test different IO objects. s9 import _io ;infile = _io.FileIO(sys.stdin.fileno(), "rb")( ( R ( ( s0 /usr/local/lib/python2.7/test/test_file_eintr.pyt _generate_infile_setup_code' s t c C s¦ | j j ƒ d k rJ t j d ƒ y | j j ƒ WqJ t k rF qJ Xn | r| | j j ƒ \ } } | | 7} | | 7} n | j d | | j ƒ | j ƒ f ƒ d S( s; 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š™™™™™¹?s/ Error from IO process %s: STDOUT: %sSTDERR: %s N( R R R t timet sleept terminateR t communicatet failt decode( R t whyt stdoutt stderrR t stdout_endt stderr_end( ( s0 /usr/local/lib/python2.7/test/test_file_eintr.pyt fail_with_process_info/ s c C s¾ | j ƒ } t j t j d d d | d d | d d g d t j d t j d t j ƒ| _ | j j j t d ƒ ƒ } | d k r | j d d | ƒn | j j j | ƒ d } g } xz | s8t j | j j g d d d ƒ \ } } } | j j t j ƒ | d 7} | d k r¿ | j j ƒ | j d ƒ q¿ q¿ W| j j j ƒ } | d k rm| j d d | ƒn | j j d d ƒ \ } } | j j rº| j d | j j | | d t ƒn d S( sn Generic 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. s -us -cs\ import io, signal, sys ;signal.signal(signal.SIGINT, lambda s, f: sys.stderr.write("$\n")) ;s ;s"