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

�
�mYc@`s�dZddlmZmZmZddlZddlZddlZddlm	Z
mZde
fd��YZddd��YZd	�Zd
�Zejde�d��Zejd
��Zd�Zd�ZdS(s�
merged implementation of the cache provider

the name cache was not chosen to ensure pluggy automatically
ignores the external pytest-cache
i(tabsolute_importtdivisiontprint_functionN(tseptaltseptCachecB`s5eZd�Zd�Zd�Zd�Zd�ZRS(cC`s�||_|jjd�|_|jjjd�|_|jd�r�|jd�|jj�rq|jj	�n|jj
�ndS(Ns.cachetcachet
cacheclearsclearing cachedir(tconfigtrootdirtjoint	_cachedirttracetroottgettgetvaluetchecktremovetmkdir(tselfR((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyt__init__s	
cC`sFt|ks$tdk	r3t|kr3td��n|jjd|�S(s� return a directory path object with the given name.  If the
        directory does not yet exist, it will be created.  You can use it
        to manage files likes e. g. store/retrieve database
        dumps across test sessions.

        :param name: must be a string not containing a ``/`` separator.
             Make sure the name contains your plugin or application
             identifiers to prevent clashes with other cache users.
        s.name is not allowed to contain path separatorstdN(t_sept_altseptNonet
ValueErrorRt
ensure_dir(Rtname((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytmakedirs
$cC`s|jjd|jd��S(Ntvt/(RR
tsplit(Rtkey((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyt
_getvaluepath'scC`ss|j|�}|j�roy)|jd��}tj|�SWdQXWqotk
rk|jd|f�qoXn|S(s� return cached value for the given key.  If no value
        was yet cached or the value cannot be read, the specified
        default is returned.

        :param key: must be a ``/`` separated value. Usually the first
             name is the name of your plugin or your application.
        :param default: must be provided in case of a cache-miss or
             invalid cache values.

        trNscache-invalid at %s(R!RtopentjsontloadRR(RR tdefaulttpathtf((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyR*s
cC`s�|j|�}y|j�j�WnDtjjtjjfk
ri|jjdddd|f�dSXy|j	d�}Wn7tjj
k
r�|jjdddd|f�nAX|�8|jd||f�tj
||d	d
dt�WdQXdS(sP save value for the given key.

        :param key: must be a ``/`` separated value. Usually the first
             name is the name of your plugin or your application.
        :param value: must be of any combination of basic
               python types, including nested types
               like e. g. lists of dictionaries.
        tcodetI9tmessagescould not create cache path %sNtwscache could not write path %sscache-write %s: %rtindentit	sort_keys(R!tdirpathRtpyterrortEEXISTtEACCESRtwarnR#tENOTDIRRR$tdumptTrue(RR tvalueR'R(((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytset>s	(t__name__t
__module__RRR!RR9(((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyRs
	
			tLFPlugincB`sDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s< Plugin which implements the --lf (run last-failing) option c`s_�|_d}t�fd�|D��|_|jrR�jjdi�|_n	i|_dS(Ntlftfailedfirstc3`s|]}�j|�VqdS(N(R(t.0R (R(sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pys	<genexpr>_sscache/lastfailed(R=R>(RtanytactiveRRt
lastfailed(RRtactive_keys((RsF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyR\s		cC`sX|jrT|jsd}n1dt|j�|jjd�rBdndf}d|SdS(Nsrun all (no recorded failures)srerun last %d failures%sR>s firsttsrun-last-failure: %s(RARBtlenRR(Rtmode((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytpytest_report_headeres			"cC`sc|jr+d|jkr+t|j|j<n4|js_|jdkr_|jj|jd�q_ndS(Ntxfailtcall(tfailedtkeywordsR7RBtnodeidtwhentpopR(Rtreport((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytpytest_runtest_logreportos
	cC`sq|jdk}|r]|j|jkrm|jj|j�|jjd�|jD��qmnt|j|j<dS(Ntpassedtskippedcs`s|]}|jtfVqdS(N(RLR7(R?titem((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pys	<genexpr>|s(RQRR(toutcomeRLRBRNtupdatetresultR7(RRORQ((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytpytest_collectreportvs	cC`s�|jr�|jr�g}g}x=|D]5}|j|jkrM|j|�q%|j|�q%W|rn|rnq�|jjd�r�||(|jjd|�q�|||(ndS(NR=titems(RARBRLtappendRRthooktpytest_deselected(RtsessionRRXtpreviously_failedtpreviously_passedRS((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytpytest_collection_modifyitems�s

cC`s{|j}|jd�s't|d�r+dS|jjdd�dk	}|jrU|s^|jrw|jjd|j�ndS(Nt	cacheshowt
slaveinputscache/lastfailed(	RRthasattrRRRttestscollectedRBR9(RR\Rtprev_failed((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytpytest_sessionfinish�s	(	R:R;t__doc__RRGRPRWR_Re(((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyR<Zs			
			c	C`s�|jd�}|jdddddddd	�|jd
ddddddd
�|jddddddd�|jddddddd�dS(Ntgenerals--lfs
--last-failedtactiont
store_truetdestR=thelpsHrerun only the tests that failed at the last run (or all if none failed)s--ffs--failed-firstR>sxrun all tests but run the last failures first.  This may re-order tests and thus lead to repeated fixture setup/teardowns--cache-showR`s6show cache contents, don't perform collection or testss
--cache-clearRs/remove all cache contents at start of test run.(tgetgroupt	addoption(tparsertgroup((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytpytest_addoption�scC`s-|jjr)ddlm}||t�SdS(Ni(twrap_session(toptionR`t_pytest.mainRq(RRq((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytpytest_cmdline_main�sttryfirstcC`s,t|�|_|jjt|�d�dS(Ntlfplugin(RRt
pluginmanagertregisterR<(R((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pytpytest_configure�scC`s
|jjS(sg
    Return a cache object that can persist state between testing sessions.

    cache.get(key, default)
    cache.set(key, value)

    Keys must be a ``/`` separated value, where the first part is usually the
    name of your plugin or application to avoid clashes with other cache users.

    Values can be any object handled by the json stdlib module.
    (RR(trequest((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyR�s
cC`s6|jjr2tjj�j|jj�}d|SdS(Nscachedir: %s(RrtverboseR0R'tlocaltbestrelpathRR(Rtrelpath((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyRG�scC`s�ddlm}tjj�}|jdt|jj��|jjj�s_|jd�dSt	�}|jj}|j
d�}|jdd�x�|jd��D]�}|j
|�j|jd	�}|jj||�}	|	|kr�|jd
|�q�|jd|�tjj�}
||	d|
�x+|
j�j�D]}|jd
|�qBWq�W|j
d�}|j�r�|j�r�|jdd�x[|j
d�j�D]A}
|
j�r�|
j
|�}|jd||
j�f�q�q�WndS(Ni(tpprints
cachedir: scache is emptyRt-scache valuescS`s
|j�S(N(tisfile(tx((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyt<lambda>�RDRs/%s contains unreadable content, will be ignoreds%s contains:tstreams  Rscache directoriess%s is a file of length %d(RR0tiotTerminalWritertlinetstrRRRtobjectR
RtvisittreltotreplaceRtTextIORt
splitlinestisdirtlistdirR�tsize(RR\RttwtdummytbasedirtvdirtvalpathR tvalR�R�tddirtp((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyR`�s<
			((Rft
__future__RRRR0tpytestR$tos.pathRRRRR�RR<RpRtthookimplR7RytfixtureRRGR`(((sF/opt/alt/python27/lib/python2.7/site-packages/_pytest/cacheprovider.pyt<module>sLC