Your IP : 216.73.216.196


Current Path : /opt/alt/python27/lib/python2.7/site-packages/_pytest/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyo

�
�mYc@`s�dZddlmZmZmZddlZddlZddlZddlm	Z	ddl
mZddlZddl
Z
ddlmZejjZidd6dd	6d
d6Zd�Ze
jd
e�d��Zdd%d��YZdZe
jd��Ze
jd��Zdd&d��YZdd�Zdefd��YZ defd��YZ!dd'd��YZ"dd(d��YZ#d d)d!��YZ$d"d*d#��YZ%d$�Z&dS(+s.
per-test stdout/stderr capturing mechanism.

i(tabsolute_importtdivisiontprint_functionN(tUnsupportedOperation(t
TemporaryFile(t	CaptureIOtstdintstdoutitstderricC`s�|jd�}|jddddttd�r6dndd	d
ddddgd
d�|jdddddddd
d�dS(Ntgenerals	--capturetactiontstoretdefaulttduptfdtsystmetavartmethodtchoicestnothelps,per-test capturing method: one of fd|sys|no.s-ststore_consttconsttdesttcapturesshortcut for --capture=no.(tgetgroupt
_addoptionthasattrtos(tparsertgroup((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytpytest_addoptionsthookwrapperc
c`s�t�|j}|j}t|j�}|j|d�|j|j�d�}|j|�|j�dV}|j	�\}}	|j
dk	r�tj
j|�tjj|	�ndS(NtcapturemanagercS`s&dtjkr"ttjd_ndS(Ntlogging(RtmodulestFalsetraiseExceptions(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytsilence_logging_at_shutdown.s(t_readline_workaroundtknown_args_namespacet
pluginmanagertCaptureManagerRtregistertadd_cleanuptreset_capturingstinit_capturingstsuspendcapturetexcinfotNoneRRtwriteR(
tearly_configRtargstnsR)tcapmanR&toutcometoutterr((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytpytest_load_initial_conftests"s			

R*cB`seZd�Zd�Zd�Zd�Zd�Zed�Zd�Z	d�Z
ejde
�d	��Zejde
�d
��Zejde
�d��Zejde
�d��Zejd
e
�d��Zejd
e
�d��Zed�ZRS(cC`s
||_dS(N(t_method(tselfR((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyt__init__=scC`s�|dkr%tdtdtdt�S|dkrJtdtdtdt�S|dkrotdtdtdt�Std|��dS(	NRR8R9tCaptureRRtin_sunknown capturing method: %r(tMultiCapturetTruet	FDCapturet
SysCaptureR$t
ValueError(R<R((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyt_getcapture@scC`s&|j|j�|_|jj�dS(N(RER;t
_capturingtstart_capturing(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR.JscC`s<|jjdd�}|dk	r8|j�|j�ndS(NRF(t__dict__tpopR1tpop_outerr_to_origtstop_capturing(R<tcap((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR-Os
cC`s|jj�dS(N(RFtresume_capturing(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyt
resumecaptureUscC`sT|j�t|dd�}|dk	rPz|j�}Wd|jd|�X|SdS(NRFR?(tdeactivate_funcargstgetattrR1t
readouterrtsuspend_capturing(R<R?RLtouterr((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR/Xs
cC`s;|jjdd�}|dk	r7|j�||_ndS(Nt_capfuncarg(RHRIR1t_startRT(R<t
pyfuncitemt
capfuncarg((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytactivate_funcargsbs
cC`s2|jjdd�}|dk	r.|j�ndS(NRT(RHRIR1tclose(R<RW((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyROhsR cc`s�t|tj�r�|j�dV}|j�\}}|j�}|r`|jjd|f�n|r�|jjd|f�q�ndVdS(NsCaptured stdoutsCaptured stderr(t
isinstancetpytesttFileRNR/t
get_resulttsectionstappend(R<t	collectorR7R8R9trep((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytpytest_make_collect_reportms
cc`s#|j�dV|j|d�dS(Ntsetup(RNtsuspendcapture_item(R<titem((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytpytest_runtest_setup{s
cc`s0|j�|j|�dV|j|d�dS(Ntcall(RNRXRd(R<Re((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytpytest_runtest_call�s

cc`s#|j�dV|j|d�dS(Ntteardown(RNRd(R<Re((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytpytest_runtest_teardown�s
ttryfirstcC`s|j�dS(N(R-(R<R0((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytpytest_keyboard_interrupt�scC`s|j�dS(N(R-(R<R0((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytpytest_internalerror�scC`sB|jd|�\}}|j|d|�|j|d|�dS(NR?RR(R/tadd_report_section(R<RetwhenR?R8R9((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRd�s(t__name__t
__module__R=RER.R-RNR$R/RXROR[thookimplRARbRfRhRjRlRmRd(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR*<s		
			
		s,cannot use capsys and capfd at the same timecC`s>d|jkr!|jt��ntt|�|j_}|S(s�Enable capturing of writes to sys.stdout/sys.stderr and make
    captured output available via ``capsys.readouterr()`` method calls
    which return a ``(out, err)`` tuple.
    tcapfd(tfixturenamest
raiseerrorterror_capsysfderrortCaptureFixtureRCtnodeRT(trequesttc((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytcapsys�scC`s[d|jkr|jt�nttd�s>tjd�ntt|�|j	_
}|S(s�Enable capturing of writes to file descriptors 1 and 2 and make
    captured output available via ``capfd.readouterr()`` method calls
    which return a ``(out, err)`` tuple.
    R{R
scapfd funcarg needs os.dup(RtRuRvRRR[tskipRwRBRxRT(RyRz((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRs�sRwcB`s>eZd�Zd�Zd�Zd�Zejd��ZRS(cC`s||_||_dS(N(tcaptureclassRy(R<R}Ry((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR=�s	c	C`s8tdtdtdtd|j�|_|jj�dS(NR8R9R?R>(R@RAR$R}t_captureRG(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRU�scC`sA|jjdd�}|dk	r=|j�|_|j�ndS(NR~(RHRIR1RJt_outerrRK(R<RL((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRY�scC`s-y|jj�SWntk
r(|jSXdS(N(R~RQtAttributeErrorR(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRQ�s
cc`sO|jjjjd�}|j|jjddt�z	dVWd|j�XdS(NR!RgR?(RytconfigR)t	getpluginRdRxRARN(R<t
capmanager((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytdisabled�s
	(	RpRqR=RURYRQt
contextlibtcontextmanagerR�(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRw�s
				tUTF8cC`s�t|dd�}y|j�}Wn<tk
r`dt|dd�kr�t|d�r�|Sn>Xtj|�}d|kr�|d7}ntj||d�}t||p�|�S(sa return a open text file object that's a duplicate of f on the
        FD-level if possible.
    tencodingtbtmodetiN(	RPR1tfilenot	ExceptionRRR
tfdopentEncodedFile(tfR�tdefault_encodingR�Rtnewfd((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytsafe_text_dupfile�s
'
R�cB`s2eZdZd�Zd�Zd�Zd�ZRS(tstrictcC`s||_||_dS(N(tbufferR�(R<R�R�((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR=�s	cC`s;t|t�r'|j|jd�}n|jj|�dS(Ntreplace(RZtunicodetencodeR�R�R2(R<tobj((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR2�scC`s dj|�}|j|�dS(NR�(tjoinR2(R<tlinelisttdata((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyt
writelines�scC`sttj|d�|�S(NR�(RPtobjectt__getattribute__(R<tname((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyt__getattr__�s(RpRqterrorsR=R2R�R�(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��s
			R@cB`sdeZdZZZeeedd�Zd�Zd�Z	e
d�Zd�Zd�Z
d�ZRS(cC`sL|r|d�|_n|r0|d�|_n|rH|d�|_ndS(Niii(R?R8R9(R<R8R9R?R>((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR=scC`sO|jr|jj�n|jr2|jj�n|jrK|jj�ndS(N(R?tstartR8R9(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRG
s			cC`sN|j�\}}|r+|jj|�n|rD|jj|�n||fS(sA pop current snapshot out/err capture and flush to orig streams. (RQR8twriteorgR9(R<R8R9((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRJscC`s^|jr|jj�n|jr2|jj�n|rZ|jrZ|jj�t|_ndS(N(R8tsuspendR9R?RAt
_in_suspended(R<R?((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRRs		
cC`s[|jr|jj�n|jr2|jj�nt|d�rW|jj�|`ndS(NR�(R8tresumeR9RR?R�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRM$s		
cC`svt|d�rtd��nt|_|jr@|jj�n|jrY|jj�n|jrr|jj�ndS(s, stop capturing and reset capturing streams t_resetswas already stoppedN(RRDRAR�R8tdoneR9R?(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRK-s				cC`sF|jdk	r|jj�nd|jdk	r?|jj�ndfS(s< return snapshot unicode value of stdout/stderr capturings. R�N(R8R1tsnapR9(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRQ9s!N(RpRqR1R8R9R?RAR=RGRJR$RRRMRKRQ(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR@�s							t	NoCapturecB`s!eZd�ZZZZZRS(cG`sdS(N(R1(R4((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyt<lambda>?R�(RpRqR=R�R�R�R�(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR�>sRBcB`sYeZdZd	d�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�ZRS(
s5 Capture IO to/from a given os-level filedescriptor. cC`s�||_ytj|j�|_Wn)tk
rMd�|_d�|_n�X|dkr~ttjd�}t	|�|_
nd|dkr�t�}|�t
|dd�}WdQXn|tkr�t	||�|_
nt�|_
||_|j�|_dS(NcS`sdS(N(R1(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR�IR�cS`sdS(N(R1(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR�JR�itrR�swb+(ttargetfdRR
t
targetfd_savetOSErrorR�R�topentdevnullRCt
syscaptureR1RR�tpatchsysdictR�ttmpfileR�t
tmpfile_fd(R<R�R�R�((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR=Ds$	
		cC`sd|j|jfS(Ns<FDCapture %s oldfd=%s>(R�R�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyt__repr__\scC`saytj|j�Wn#ttfk
r9td��nXtj|j|j�|j	j
�dS(s6 Start capturing on targetfd using memorized tmpfile. s&saved filedescriptor not valid anymoreN(RtfstatR�R�R�RDtdup2R�R�R�R�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR�_scC`s�|j}|jd�|j�}|r�t|dd�}|rjt|t�rjtjj	||d�}n|j
d�|jd�|SdS(NiR�R�R�(R�tseektreadRPR1RZtbytestpytbuiltint_totextttruncate(R<R�trestenc((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR�hs	


cC`sP|jjd�}tj||j�tj|�|jj�|jj�dS(sa stop capturing, restore streams, return original capture file,
        seeked to position zero. R�N(	RHRIRR�R�RYR�R�R�(R<R�((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR�us


cC`s'|jj�tj|j|j�dS(N(R�R�RR�R�R�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR�~s
cC`s'|jj�tj|j|j�dS(N(R�R�RR�R�R�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��s
cC`s;tjj|�r$|jd�}ntj|j|�dS(s$ write to original file descriptor. tutf8N(R�R�t_istextR�RR2R�(R<R�((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��sN(RpRqt__doc__R1R=R�R�R�R�R�R�R�(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRBAs				
				RCcB`sJeZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cC`sbt|}tt|�|_||_|dkrU|dkrIt�}qUt�}n||_dS(NR(	R�RPRt_oldR�R1tDontReadFromInputRR�(R<RR�R�((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR=�s
	cC`stt|j|j�dS(N(tsetattrRR�R�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��scC`s3|j}|j�}|jd�|jd�|S(Ni(R�tgetvalueR�R�(R<R�R�((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��s
	

cC`s-tt|j|j�|`|jj�dS(N(R�RR�R�R�RY(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��scC`stt|j|j�dS(N(R�RR�R�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��scC`stt|j|j�dS(N(R�RR�R�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��scC`s!|jj|�|jj�dS(N(R�R2tflush(R<R�((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��sN(
RpRqR1R=R�R�R�R�R�R�(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRC�s					R�cB`sYeZdZdZd�ZeZeZeZd�Z	d�Z
d�Zed��Z
RS(sTemporary stub class.  Ideally when stdin is accessed, the
    capturing should be turned off, with possibly all data captured
    so far sent to the screen.  This should be configurable, though,
    because in automated test runs it is better to crash than
    hang indefinitely.
    cG`std��dS(Ns+reading from stdin while output is captured(tIOError(R<R4((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��scC`std��dS(Ns/redirected stdin is pseudofile, has no fileno()(R(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��scC`stS(N(R$(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pytisatty�scC`sdS(N((R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyRY�scC`s#tjdkr|Std��dS(Niis(redirected stdin has no attribute buffer(ii(Rtversion_infoR�(R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��sN(RpRqR�R1R�R�treadlinet	readlinest__iter__R�R�RYtpropertyR�(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR��s				cC`s>tjjd�sdSyddl}Wntk
r9nXdS(sF
    Ensure readline is imported so that it attaches to the correct stdio
    handles on Windows.

    Pdb uses readline support where available--when not running from the Python
    prompt, the readline module is not imported until running the pdb REPL.  If
    running pytest with the --pdb option this means the readline module is not
    imported until after I/O capture has been started.

    This is a problem for pyreadline, which is often used to implement readline
    support on Windows, as it does not attach to the correct handles for stdout
    and/or stdin if they have been redirected by the FDCapture mechanism.  This
    workaround ensures that readline is imported before I/O capture is setup so
    that it can attach to the actual stdin/out for the console.

    See https://github.com/pytest-dev/pytest/pull/1281
    twin32Ni(Rtplatformt
startswithR�tImportError(R�((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyR'�s
((((((('R�t
__future__RRRR�RRtioRttempfileRR�R[t_pytest.compatRR�ttextR�R�RRrRAR:R*RvtfixtureR{RsRwR�R�R�R@R�RBRCR�R'(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/capture.pyt<module>s4	a ?L&"