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/doctest.pyc

�
�mYc@`s|dZddlmZmZmZddlZddlZddlmZm	Z	m
Z
ddlmZdZ
dZdZd	Zd
Ze
eeeefZd�Zd�Zd
�Zde
fd��YZdejfd��YZd�Zd�Zdejfd��YZd�Zdejfd��YZd�Zd�Z d�Z!d�Z"d�Z#ej$dd�d ��Z%dS(!s5 discover and run doctests in modules and test files.i(tabsolute_importtdivisiontprint_functionN(t
ExceptionInfotReprFileLocationtTerminalRepr(tFixtureRequesttnonetcdifftndifftudifftonly_first_failurecC`s�|jddddddg�|jdddd	�|jd
�}|jddd
dtdddd�|jddtjdddddtdd�|jddddgdddddd�|jddd
dtdddd�dS( Ntdoctest_optionflagssoption flags for docteststtypetargstdefaulttELLIPSIStdoctest_encodingsencoding used for doctest filessutf-8tcollects--doctest-modulestactiont
store_truethelpsrun doctests in all .py modulestdesttdoctestmoduless--doctest-reportR
s9choose another output format for diffs on doctest failuretchoicest
doctestreports--doctest-globtappendtmetavartpats2doctests file matching pattern, default: test*.txttdoctestglobs--doctest-ignore-import-errorssignore doctest ImportErrorstdoctest_ignore_import_errors(taddinitgetgroupt	addoptiontFalsetstrtlowertDOCTEST_REPORT_CHOICES(tparsertgroup((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pytpytest_addoptions*cC`sW|j}|jdkr4|jjrSt||�Snt|||�rSt||�SdS(Ns.py(tconfigtexttoptionRt
DoctestModulet_is_doctesttDoctestTextfile(tpathtparentR)((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pytpytest_collect_file1s	cC`sh|jdkr%|jj|�r%tS|jd�p:dg}x$|D]}|jd|�rDtSqDWtS(Ns.txts.rstRs	test*.txttfnmatch(s.txts.rst(R*tsessiont
isinitpathtTruet	getoptiontcheckR"(R)R/R0tglobstglob((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR-:s!
tReprFailDoctestcB`seZd�Zd�ZRS(cC`s||_||_dS(N(treprlocationtlines(tselfR;R<((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyt__init__Fs	cC`s5x|jD]}|j|�q
W|jj|�dS(N(R<tlineR;t
toterminal(R=ttwR?((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR@Js(t__name__t
__module__R>R@(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR:Ds	tDoctestItemcB`s;eZddd�Zd�Zd�Zd�Zd�ZRS(cC`sAtt|�j||�||_||_d|_d|_dS(N(tsuperRDR>trunnertdtesttNonetobjtfixture_request(R=tnameR0RFRG((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR>Qs
			cC`s�|jdk	r|t|�|_td|jj�}x0|jjd�j�D]\}}|||<qLW|jjj|�ndS(Nt
getfixturetdoctest_namespace(	RGRHt_setup_fixturesRJtdicttgetfixturevaluetitemsR8tupdate(R=R8RKtvalue((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pytsetupXs%cC`s$t|j�|jj|j�dS(N(t_check_all_skippedRGRFtrun(R=((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pytruntest`s
cC`sddl}|j|j|jf�r|j}|j}|j}|j}|jdkrcd}n|j|jd}|j
j}t|||�}	t
�}
t|jjd��}|dk	r/|jjjt�}gt|�D]'\}
}d|
|jd|f^q�}||jd|jd!}nFdg}d}x4|jj�D]#}|jd||f�d	}qNW|j|j�r�||
j||j|�jd
�7}nEt|jj�}|dt|j�g7}|tj|jj�7}t|	|�St t!|�j"|�SdS(NiiRs%03d %si	s?EXAMPLE LOCATION UNKNOWN, not showing all tests of that examples>>>s	??? %s %ss...s
sUNEXPECTED EXCEPTION: %s(#tdoctestt
errisinstancetDocTestFailuretUnexpectedExceptionRStexamplettesttfilenametlinenoRHR
RBRt_get_checkert_get_report_choiceR)R6t	docstringt
splitlinesR"t	enumeratetsourceRtoutput_differencetgottsplitRtexc_infotreprt	tracebacktformat_exceptionR:RERDtrepr_failure(R=texcinfoRXtdoctestfailureR\R]R^R_tmessageR;tcheckert
report_choiceR<titxtindentR?t
inner_excinfo((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyRmdsB						7	

cC`s|jdd|jfS(Ns[doctest] %s(tfspathRHRK(R=((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyt
reportinfo�sN(RBRCRHR>RTRWRmRx(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyRDPs
			)cC`s[ddl}td|jd|jd|jd|jd|jd|jdt�d	t	��S(
NitDONT_ACCEPT_TRUE_FOR_1tDONT_ACCEPT_BLANKLINEtNORMALIZE_WHITESPACERtIGNORE_EXCEPTION_DETAILtCOMPARISON_FLAGSt
ALLOW_UNICODEtALLOW_BYTES(
RXRORyRzR{RR|R}t_get_allow_unicode_flagt_get_allow_bytes_flag(RX((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyt_get_flag_lookup�s						cC`sD|jjd�}t�}d}x|D]}|||O}q(W|S(NRi(R)tgetiniR�(R0toptionflags_strtflag_lookup_tabletflag_acctflag((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pytget_optionflags�s	
R.cB`seZdZd�ZRS(cc`s�ddl}|jjd�}|jj|�}t|j�}|jj}idd6}t|�}|jddd|dt	��}|j
�}	|	j||||d�}
|
jr�t
|
j|||
�VndS(NiRt__main__RBtverbosetoptionflagsRq(RXR)R�Rwt	read_textR#tbasenameR�tDebugRunnerR`t
DocTestParsertget_doctesttexamplesRDRK(R=RXtencodingttextR^RKR8R�RFR&R]((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR�s
	N(RBRCRHRIR(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR.�sc`sEddl�t�fd�|jD��}|rAtjd�ndS(s\raises pytest.skip() if all examples in the given DocTest have the SKIP
    option set.
    iNc3`s'|]}|jj�jt�VqdS(N(toptionstgettSKIPR"(t.0Rt(RX(s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pys	<genexpr>�ss!all tests skipped by +SKIP option(RXtallR�tpytesttskip(R]tall_skipped((RXs@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyRU�sR,cB`seZd�ZRS(cc`sddl}|jjdkr9|jjj|j�}nSy|jj�}Wn=tk
r�|jjd�r�t	j
d|j�q��nX|j�}t|�}|j
ddd|dt��}x@|j||j�D])}|jr�t|j|||�Vq�q�WdS(Nisconftest.pyRsunable to import module %rR�R�Rq(RXRwR�R)t
pluginmanagert_importconftesttpyimporttImportErrortgetvalueR�R�t
DocTestFinderR�R�R`tfindRBR�RDRK(R=RXtmoduletfinderR�RFR]((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR�s 
	(RBRCR(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR,�sc	C`s_d�}i|_|jj}|jd|d|dddt�|_t|�}|j�|S(sO
    Used by DoctestTextfile and DoctestItem to setup fixture information.
    cS`sdS(N((((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pytfunc�stnodeR�tclstfuncargsN(	R�R3t_fixturemanagertgetfixtureinfoRHR"t_fixtureinfoRt
_fillfixtures(tdoctest_itemR�tfmRJ((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyRN�s		
c`sfttd�rtj�Sddl�ddl�d�jf��fd��Y}|t_tj�S(sJ
    Returns a doctest.OutputChecker subclass that takes in account the
    ALLOW_UNICODE option to ignore u'' prefixes in strings and ALLOW_BYTES
    to strip b'' prefixes.
    Useful when the same doctest should run in Python 2 and Python 3.

    An inner class is used to avoid importing "doctest" at the module
    level.
    tLiteralsOutputCheckeriNc`sJeZdZ�jd�j�Z�jd�j�Z��fd�ZRS(s�
        Copied from doctest_nose_plugin.py from the nltk project:
            https://github.com/nltk/nltk

        Further extended to also support byte literals.
        s(\W|^)[uU]([rR]?[\'\"])s(\W|^)[bB]([rR]?[\'\"])c`s��jj||||�}|r%tS|t�@}|t�@}|rQ|rQtS�fd�}|r�||j|�}||j|�}n|r�||j|�}||j|�}n�jj||||�}|SdS(Nc`s�j|d|�S(Ns\1\2(tsub(tregexttxt(tre(s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pytremove_prefixess(t
OutputCheckertcheck_outputR5R�R�R"t_unicode_literal_ret_bytes_literal_re(R=twantRgR�trest
allow_unicodetallow_bytesR�(RXR�(s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR�s$	

	(RBRCt__doc__tcompiletUNICODER�R�R�((RXR�(s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR�s(thasattrR`R�RXR�R�(R�((RXR�s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR`�s

"$	cC`sddl}|jd�S(s7
    Registers and returns the ALLOW_UNICODE flag.
    iNR~(RXtregister_optionflag(RX((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR�(scC`sddl}|jd�S(s5
    Registers and returns the ALLOW_BYTES flag.
    iNR(RXR�(RX((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyR�0scC`sCddl}i|jt6|jt6|jt6|jt6dt	6|S(s�
    This function returns the actual `doctest` module flag value, we want to do it as late as possible to avoid
    importing `doctest` and all its dependencies when parsing options, as it adds overhead and breaks tests.
    iN(
RXtREPORT_UDIFFtDOCTEST_REPORT_CHOICE_UDIFFtREPORT_CDIFFtDOCTEST_REPORT_CHOICE_CDIFFtREPORT_NDIFFtDOCTEST_REPORT_CHOICE_NDIFFtREPORT_ONLY_FIRST_FAILUREt(DOCTEST_REPORT_CHOICE_ONLY_FIRST_FAILUREtDOCTEST_REPORT_CHOICE_NONE(tkeyRX((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyRa8s



tscopeR3cC`st�S(s2
    Inject names into the doctest namespace.
    (RO(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyRMGs(&R�t
__future__RRRRkR�t_pytest._code.codeRRRt_pytest.fixturesRR�R�R�R�R�R%R(R1R-R:tItemRDR�R�tModuleR.RUR,RNR`R�R�RatfixtureRM(((s@/opt/alt/python27/lib/python2.7/site-packages/_pytest/doctest.pyt<module>s>					
A	
		
		8