Your IP : 216.73.216.74


Current Path : /opt/alt/python37/lib/python3.7/site-packages/_pytest/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/_pytest/__pycache__/cacheprovider.cpython-37.pyc

B

C$�X�"�@s�dZddlZddlZddlZddlmZmZGdd�de	�Z
Gdd�d�Zdd	�Zd
d�Z
ejdd
�dd��Zejdd��Zdd�Zdd�ZdS)z�
merged implementation of the cache provider

the name cache was not chosen to ensure pluggy automatically
ignores the external pytest-cache
�N)�sep�altsepc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�CachecCsZ||_|j�d�|_|jj�d�|_|�d�rV|�d�|j��rL|j�	�|j�
�dS)Nz.cache�cache�
cacheclearzclearing cachedir)�configZrootdir�join�	_cachedir�trace�root�get�getvalue�check�remove�mkdir)�selfr�r�F/opt/alt/python37/lib/python3.7/site-packages/_pytest/cacheprovider.py�__init__s



zCache.__init__cCs.t|kstdk	r t|kr td��|j�d|�S)a� 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.
        Nz.name is not allowed to contain path separators�d)�_sep�_altsep�
ValueErrorr	�
ensure_dir)r�namerrr�makedirs
z
Cache.makedircCs|jjd|�d���S)N�v�/)r)r	r�split)r�keyrrr�
_getvaluepath'szCache._getvaluepathc	Cs\|�|�}|��rXy |�d��}t�|�SQRXWn$tk
rV|�d|f�YnX|S)a� 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.

        �rNzcache-invalid at %s)r r�open�json�loadrr
)rr�default�path�frrrr*s
z	Cache.getc	Cs�|�|�}y|����Wn6tjjtjjfk
rP|jjdd|fd�dSXy|�	d�}Wn.tjj
k
r�|jjdd|fd�Yn6X|�*|�d||f�tj
||dd	d
�WdQRXdS)aP 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.
        ZI9zcould not create cache path %s)�code�messageN�wzcache could not write path %szcache-write %s: %r�T)�indent�	sort_keys)r �dirpathr�py�error�EEXIST�EACCESr�warnr"�ENOTDIRr
r#�dump)rr�valuer&r'rrr�set>s	
z	Cache.setN)�__name__�
__module__�__qualname__rrr rr7rrrrrs

rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�LFPluginz< Plugin which implements the --lf (run last-failing) option csD�|_d}t�fdd�|D��|_|jr:�j�di�|_ni|_dS)N)�lf�failedfirstc3s|]}��|�VqdS)N)r
)�.0r)rrr�	<genexpr>_sz$LFPlugin.__init__.<locals>.<genexpr>zcache/lastfailed)r�any�activerr�
lastfailed)rrZactive_keysr)rrr\szLFPlugin.__init__cCs@|jr<|jsd}n"dt|j�|j�d�r,dndf}d|SdS)Nzrun all (no recorded failures)zrerun last %d failures%sr=z first�zrun-last-failure: %s)rArB�lenrr
)r�moderrr�pytest_report_headereszLFPlugin.pytest_report_headercCsB|jrd|jkrd|j|j<n |js>|jdkr>|j�|jd�dS)NZxfailT�call)�failed�keywordsrB�nodeidZwhen�pop)r�reportrrr�pytest_runtest_logreportos

z!LFPlugin.pytest_runtest_logreportcCsR|jdk}|rB|j|jkrN|j�|j�|j�dd�|jD��nd|j|j<dS)N)�passedZskippedcss|]}|jdfVqdS)TN)rJ)r>�itemrrrr?|sz0LFPlugin.pytest_collectreport.<locals>.<genexpr>T)ZoutcomerJrBrK�update�result)rrLrNrrr�pytest_collectreportvs
zLFPlugin.pytest_collectreportcCs�|jr�|jr�g}g}x.|D]&}|j|jkr6|�|�q|�|�qW|sN|rNn8|j�d�rl|||dd�<n||dd�<|jj|d�dS)Nr=)�items)rArBrJ�appendrr
�hookZpytest_deselected)r�sessionrrSZpreviously_failedZpreviously_passedrOrrr�pytest_collection_modifyitems�s
z&LFPlugin.pytest_collection_modifyitemscCsT|j}|�d�st|d�rdS|j�dd�dk	}|jr:|s@|jrP|j�d|j�dS)N�	cacheshowZ
slaveinputzcache/lastfailed)rr
�hasattrrrZtestscollectedrBr7)rrVrZprev_failedrrr�pytest_sessionfinish�szLFPlugin.pytest_sessionfinishN)
r8r9r:�__doc__rrFrMrRrWrZrrrrr;Zs	
r;cCsZ|�d�}|jdddddd�|jdd	dd
dd�|jddd
dd�|jddddd�dS)NZgeneralz--lfz
--last-failed�
store_truer<zHrerun only the tests that failed at the last run (or all if none failed))�action�dest�helpz--ffz--failed-firstr=zxrun all tests but run the last failures first.  This may re-order tests and thus lead to repeated fixture setup/teardownz--cache-showrXz6show cache contents, don't perform collection or testsz
--cache-clearrz/remove all cache contents at start of test run.)ZgetgroupZ	addoption)�parser�grouprrr�pytest_addoption�s
rbcCs"|jjrddlm}||t�SdS)Nr)�wrap_session)�optionrXZ_pytest.mainrc)rrcrrr�pytest_cmdline_main�sreT)ZtryfirstcCs t|�|_|j�t|�d�dS)NZlfplugin)rrZ
pluginmanager�registerr;)rrrr�pytest_configure�s
rgcCs|jjS)ag
    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)�requestrrrr�s
rcCs(|jjr$tj���|jj�}d|SdS)Nzcachedir: %s)rd�verboser/r&�localZbestrelpathrr	)r�relpathrrrrF�srFcCsvddlm}tj��}|�dt|jj��|jj��sF|�d�dSt	�}|jj}|�
d�}|�dd�x�|�dd	��D]�}|�
|��|jd
�}|j�||�}	|	|kr�|�d|�qz|�d|�tj��}
||	|
d
�x"|
����D]}|�d|�q�WqzW|�
d�}|���rr|���rr|�dd�xB|�
d���D]0}
|
���r>|
�
|�}|�d||
��f��q>WdS)Nr)�pprintz
cachedir: zcache is emptyr�-zcache valuescSs|��S)N)�isfile)�xrrr�<lambda>��zcacheshow.<locals>.<lambda>rz/%s contains unreadable content, will be ignoredz%s contains:)�streamz  rzcache directoriesz%s is a file of length %d)rlr/�ioZTerminalWriter�line�strrr	r�objectrr�visitZrelto�replacerZTextIOr
�
splitlines�isdir�listdirrn�size)rrVrlZtw�dummyZbasedirZvdirZvalpathr�valrrrtZddir�prrrrX�s<







rX)r[r/�pytestr#�os.pathrrrrrvrr;rbreZhookimplrgZfixturerrFrXrrrr�<module>sLC