Your IP : 216.73.216.196


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__/config.cpython-37.pyc

B

C$�X!��@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
mZmZmZddlmZed�Zed�ZGdd�de�ZdEdd	�ZGd
d�d�ZGdd
�d
e�Zdd�Zdd�ZgZd��Zee�Z e �!d�dd�Z"dd�Z#dd�Z$dFdd�Z%Gdd�de�Z&dd�Z'Gd d!�d!�Z(Gd"d#�d#e�Z)Gd$d%�d%�Z*Gd&d'�d'�Z+Gd(d)�d)ej,�Z-Gd*d+�d+ej.�Z/d,d-�Z0Gd.d/�d/e1�Z2Gd0d1�d1�Z3e3�Z4d2Z5Gd3d4�d4e1�Z6e7fd5d6�Z8dGd7d8�Z9d9d:�Z:d;d<�Z;dHd=d>�Z<d?d@�Z=dAdB�Z>dCdD�Z?dS)Iz< command line options, ini-file and conftest.py processing. �N)�
PluginManager�HookimplMarker�HookspecMarker)�safe_str�pytestc@seZdZdd�Zdd�ZdS)�ConftestImportFailurecCst�|||�||_||_dS)N)�	Exception�__init__�path�excinfo)�selfr
r�r
�?/opt/alt/python37/lib/python3.7/site-packages/_pytest/config.pyr	szConftestImportFailure.__init__cCs4|j\}}}t�|�}t|�dd�|dd��S)N�
��)r�	traceback�	format_tb�repr�join)r�etypeZevalueZetb�	formattedr
r
r�__str__s
zConftestImportFailure.__str__N)�__name__�
__module__�__qualname__r	rr
r
r
rrsrc
Cs�y�yt||�}Wnltk
r|}zNtj�tj�}x&tj|j	�D]}|j
|��dd�q>W|j
d|jdd�dSd}~XYn&Xz|j
��|jj|d�S|��XWnDtk
r�}z&x |jD]}tj�d|f�q�WdSd}~XYnXdS)z� return exit code, after performing an in-process test run.

    :arg args: list of command line arguments.

    :arg plugins: list of plugin objects to be auto-registered during
                  initialization.
    T)ZredzERROR: could not load %s
�N)�configz
ERROR: %s
)�_prepareconfigr�py�io�TerminalWriter�sys�stderrr�format_exceptionr�line�rstripr
�
pluginmanagerZ
check_pending�hookZpytest_cmdline_main�_ensure_unconfigure�
UsageError�args�write)r+�pluginsr�e�twr%�msgr
r
r�main%s"
r1c@seZdZee�ZdS)�cmdlineN)rrr�staticmethodr1r
r
r
rr2Asr2c@seZdZdZdS)r*z$ error in pytest usage or invocationN)rrr�__doc__r
r
r
rr*Esr*cCs tj�|�rtd�||���|S)zs Argparse type validator for filename arguments.

    :path: path of filename
    :optname: name of the option
    z"{0} must be a filename, given: {1})�osr
�isdirr*�format)r
�optnamer
r
r�filename_argIsr9cCs tj�|�std�||���|S)ztArgparse type validator for directory arguments.

    :path: path of directory
    :optname: name of the option
    z#{0} must be a directory, given: {1})r5r
r6r*r7)r
r8r
r
r�
directory_argTsr:z�mark main terminal runner python fixtures debugging unittest capture skipping tmpdir monkeypatch recwarn pastebin helpconfig nose assertion junitxml resultlog doctest cacheprovider freeze_support setuponly setupplanZpytestercCstrt�t�t��dS)N)�_preinit�AssertionError�append�
get_configr
r
r
r�_preloadpluginsksr?cCs8trt�d�St�}t|�}xtD]}|�|�q"W|S)Nr)r;�pop�PytestPluginManager�Config�default_plugins�
import_plugin)r'r�specr
r
rr>os

r>cCst�jS)z�
    Obtain a new instance of the
    :py:class:`_pytest.config.PytestPluginManager`, with default plugins
    already loaded.

    This function can be used by integration with other tools, like hooking
    into pytest to run tests into an IDE.
    )r>r'r
r
r
r�get_plugin_managerys	rFcCs
d}|dkrtjdd�}nft|tjj�r6t|�g}nLt|ttf�s�t|t�s\t	d|f��t
j|tjdkd�}ddl
m}|j}t�}|j}yV|r�x0|D](}t|tjj�r�|�|�q�|�|�q�W|r�|�d|�|jj||d�Stk
�r|���YnXdS)	N�z!not a string or argument list: %r�win32)�posixr)�
deprecated�C1)r'r+)r"�argv�
isinstancerr
�local�str�tuple�list�
ValueError�shlex�split�platform�_pytestrJZ
MAIN_STR_ARGSr>r'�builtin�_basestring�consider_pluginarg�register�warnr(�pytest_cmdline_parse�
BaseExceptionr))r+r-�warningrJrr'�pluginr
r
rr�s4


rcs�eZdZdZ�fdd�Zdd�Z�fdd�Z�fdd	�Z�fd
d�Zd/�fd
d�	Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Z�ZS)0rAa(
    Overwrites :py:class:`pluggy.PluginManager` to add pytest-specific
    functionality:

    * loading plugins from the command line, ``PYTEST_PLUGIN`` env variable and
      ``pytest_plugins`` global variables found in plugins being loaded;
    * ``conftest.py`` loading during start-up;
    cs�tt|�jddd�t�|_i|_i|_d|_d|_t�|_	|�
tj�|�
|�tj�d�r�tj}t|dd�}ytjj||d�}Wntk
r�YnX|jj�|j�|��tj��|_dS)	Nr�pytest_)Z
implprefixFZPYTEST_DEBUG�encoding�utf8)ra) �superrAr	�set�_conftest_plugins�_path2confmods�_conftestpath2mod�_confcutdir�_noconftestZ_duplicatepaths�
add_hookspecsrV�hookspecrZr5�environ�getr"r#�getattrrr Zdupfiler�trace�rootZ	setwriterr,Zenable_tracing�	assertionZDummyRewriteHook�rewrite_hook)r�errra)�	__class__r
rr	�s&
zPytestPluginManager.__init__cCs2tdtj�t�d��ddd�}|�|�|�|�S)zi
        .. deprecated:: 2.8

        Use :py:meth:`pluggy.PluginManager.add_hookspecs` instead.
        ZI2rGNzHuse pluginmanager.add_hookspecs instead of deprecated addhooks() method.)�code�
fslocation�nodeid�message)�dictrV�_code�getfslinenor"�	_getframe�_warnrj)r�module_or_classr^r
r
r�addhooks�s
zPytestPluginManager.addhookscsl|�d�sdS|dks |�d�r$dSt||�}tt|��||�}|dk	rhxdD]}|�|t||��qNW|S)Nr`�pytest_pluginsZpytest_funcarg__)Ztryfirst�trylastZoptionalhookZhookwrapper)�
startswithrnrcrA�parse_hookimpl_opts�
setdefault�hasattr)rr_�name�method�opts)rtr
rr��s


z'PytestPluginManager.parse_hookimpl_optscsHtt|��||�}|dkrDt||�}|�d�rDt|d�t|d�d�}|S)Nr`�firstresult�historic)r�r�)rcrA�parse_hookspec_optsrnr�r�)rr~r�r�r�)rtr
rr��s


z'PytestPluginManager.parse_hookspec_optscsNtt|��||�d|jkrJtj�|j�}td|dd|j	d�}|�
|�dS)NZ
__multicall__�I1z.%r hook uses deprecated __multicall__ argument)rurvrwrx)rcrA�_verify_hook�argnamesrVrzr{�functionryr�r})rr(Z
hookmethodZfslinenor^)rtr
rr��s
z PytestPluginManager._verify_hookNcs2tt|��||�}|r.|jjjt||d�d�|S)N)r_�manager)�kwargs)rcrArZr(Zpytest_plugin_registered�
call_historicry)rr_r��ret)rtr
rrZ�s
zPytestPluginManager.registercCs
|�|�S)N)�
get_plugin)rr�r
r
r�	getpluginszPytestPluginManager.getplugincCst|�|��S)z<Return True if the plugin with the given name is registered.)�boolr�)rr�r
r
r�	haspluginszPytestPluginManager.hasplugincCs|�dd�|�dd�dS)N�markersz|tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible.zytrylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible.)�addinivalue_line)rrr
r
r�pytest_configuresz$PytestPluginManager.pytest_configurecCs0t|t�r|nd|ddd�}|jjj|d�dS)Nr�)rurxrvrw)r�)rMryr(�pytest_logwarningr�)rrxr�r
r
rr}szPytestPluginManager._warncCs�tj��}|jr |j|jdd�nd|_|j|_|j}d}xV|D]N}t	|�}|�
d�}|dkrh|d|�}|j|dd�}t|�r>|�|�d}q>W|s�|�|�dS)a} load initial conftest files given a preparsed "namespace".
            As conftest files may add their own command line options
            which have arguments ('--my-opt somepath') we might get some
            false positives.  All builtin and 3rd party plugins will have
            been loaded, however, so common options will not confuse our logic
            here.
        T)�absNFz::���rG)
rr
rN�
confcutdirrrhZ
noconftestri�file_or_dirrO�find�exists�_try_load_conftest)r�	namespace�current�	testpathsZfoundanchorr
�i�anchorr
r
r�_set_initial_conftestss 



z*PytestPluginManager._set_initial_conftestscCsD|�|�|jdd�r@x(|�d�D]}|jdd�r"|�|�q"WdS)NrG)�dirztest*)�_getconftestmodules�check�listdir)rr��xr
r
rr�9s

z&PytestPluginManager._try_load_conftestcCs�|jr
gSy
|j|Stk
r�|��r<|�|���}nPg}xJ|��D]>}|jrb|j�|�rbqJ|�	d�}|��rJ|�
|�}|�|�qJW||j|<|SXdS)Nzconftest.py)rirf�KeyError�isfiler��dirpath�partsrh�reltor�_importconftestr=)rr
Zclist�parent�conftestpath�modr
r
rr�As"



z'PytestPluginManager._getconftestmodulesc	CsN|�|�}x6t|�D]*}y|t||�fStk
r<wYqXqWt|��dS)N)r��reversedrn�AttributeErrorr�)rr�r
�modulesr�r
r
r�_rget_with_confmodYs
z&PytestPluginManager._rget_with_confmodcCs�y
|j|Stk
r�|��}|dkr4t|j�y|��}Wn"tk
rbt|t�	���YnX|j
�|�||j|<|��}||j
kr�xB|j
��D]4\}}|r�|�|�s�||kr�||ks�t�|�|�q�W|�d|�|�|�|SXdS)Nzloaded conftestmodule %r)rgr�Z	pypkgpath�_ensure_removed_sysmoduleZpurebasenameZpyimportrrr"�exc_infore�addr�rf�itemsr�r<r=ro�consider_conftest)rr��pkgpathr�r�r
Zmodsr
r
rr�bs*




z#PytestPluginManager._importconftestcCs6x0t||dd��D]\}}|dkr|�|�qWdS)NrGz-p)�ziprY)rr+�opt1�opt2r
r
r�consider_preparsesz%PytestPluginManager.consider_preparsecCsH|�d�r:|dd�}|�|�|�d�sD|�d|�n
|�|�dS)Nzno:�r`)r�Zset_blockedrD)r�argr�r
r
rrY�s


z&PytestPluginManager.consider_pluginargcCs|j||jd�r|�|�dS)N)r�)rZ�__file__�consider_module)rZconftestmoduler
r
rr��sz%PytestPluginManager.consider_conftestcCs|�tj�d��dS)NZPYTEST_PLUGINS)�_import_plugin_specsr5rlrm)rr
r
r�consider_env�sz PytestPluginManager.consider_envcCs|�t|dg��dS)Nr�)r�rn)rr�r
r
rr��sz#PytestPluginManager.consider_modulecCs$t|�}x|D]}|�|�qWdS)N)�_get_plugin_specs_as_listrD)rrEr-Zimport_specr
r
rr��s
z(PytestPluginManager._import_plugin_specsc
Cs>t|t�std|��|�|�dk	r(dS|tkr:d|}n|}|j�|�yt|�Wn�tk
r�}zLtd|t	|j
d�f�}x(dD] }t||�r�t||t
||��q�W|�Wdd}~XYnztk
�r}z:ddl}t|d�r�t||jj�s�|�d||jf�Wdd}~XYn"Xtj|}|�||�|�|�dS)Nz&module name as string required, got %rz_pytest.zError importing plugin "%s": %sr)r�r
�skipzskipped plugin %r: %s)rMrOr<r��builtin_pluginsrr�mark_rewrite�
__import__�ImportErrorrr+r��setattrrnrrr�r}r0r"r�rZr�)r�modnameZ
importspecr.�new_exc�attrrr�r
r
rrD�s.


&
z!PytestPluginManager.import_plugin)N)rrrr4r	rr�r�r�rZr�r�r�r}r�r�r�r�r�r�rYr�r�r�r�rD�
__classcell__r
r
)rtrrA�s.

		rAcCsJ|dk	rFt|t�r$|r |�d�ng}t|ttf�s>td|��t|�SgS)a
    Parses a list of "plugin specs" and returns a list of plugin names.

    Plugin specs can be given as a list of strings separated by "," or already as a list/tuple in
    which case it is returned as a list. Specs can also be `None` in which case an
    empty list is returned.
    N�,zbPlugin specs must be a ','-separated string or a list/tuple of strings for plugin names. Given: %r)rMrOrTrQrPr*)�specsr
r
rr��s
r�c@sneZdZdZddd�Zdd�Zddd	�Zd
d�Zddd
�Zdd�Z	ddd�Z
ddd�Zddd�Zddd�Z
dS)�Parserz� Parser for command line arguments and ini-file values.

    :ivar extra_info: dict of generic param -> value to display in case
        there's an error processing the command line arguments.
    NcCs6td|d�|_g|_||_||_i|_g|_i|_dS)Nzcustom options)�parser)�OptionGroup�
_anonymous�_groups�_processopt�_usage�_inidict�	_ininames�
extra_info)r�usage�
processoptr
r
rr	�szParser.__init__cCs|jr|jr|�|�dS)N)r��dest)r�optionr
r
r�
processoption�szParser.processoptionrcCsjx|jD]}|j|kr|SqWt|||d�}d}x"t|j�D]\}}|j|kr<Pq<W|j�|d|�|S)a� get (or create) a named option Group.

        :name: name of the option group.
        :description: long description for --help output.
        :after: name of other group, used for ordering --help output.

        The returned group object has an ``addoption`` method with the same
        signature as :py:func:`parser.addoption
        <_pytest.config.Parser.addoption>` but will be shown in the
        respective group in the output of ``pytest. --help``.
        )r�rrG)r�r�r��	enumerate�insert)rr��description�after�groupr��grpr
r
r�getgroup�s

zParser.getgroupcOs|jj||�dS)a register a command line option.

        :opts: option names, can be short or long options.
        :attrs: same attributes which the ``add_option()`` function of the
           `argparse library
           <http://docs.python.org/2/library/argparse.html>`_
           accepts.

        After command line parsing options are available on the pytest config
        object via ``config.option.NAME`` where ``NAME`` is usually set
        by passing a ``dest`` attribute, for example
        ``addoption("--long", dest="NAME", ...)``.
        N)r��	addoption)rr��attrsr
r
rr��szParser.addoptioncCs:ddlm}|��|_||j�|jjdd�|D�|d�S)Nr)�try_argcompletecSsg|]}t|��qSr
)rO)�.0r�r
r
r�
<listcomp>sz Parser.parse.<locals>.<listcomp>)r�)�_pytest._argcompleter��
_getparser�	optparser�
parse_args)rr+r�r�r
r
r�parses

zParser.parsec
Cs�ddlm}t||j�}|j|jg}xT|D]L}|jr,|jp@|j}|�	|�}x*|jD] }|�
�}|��}	|j||	�qTWq,W||jt
dd�_|S)Nr)�filescompleter�*)�nargs)r�r��MyOptionParserr�r�r��optionsr�r��add_argument_group�namesr��add_argument�FILE_OR_DIRZ	completer)
rr�r��groupsr��descZarggroupr��n�ar
r
rr�s

zParser._getparsercCs<|j||d�}x"|j��D]\}}t|||�qWt|t�S)N)r�)r��__dict__r�r�rnr)rr+r�r�Zparsedoptionr��valuer
r
r�parse_setoption!szParser.parse_setoptioncCs|j||d�dS)zZparses and returns a namespace object with known arguments at this
        point.
        )r�r)�parse_known_and_unknown_args)rr+r�r
r
r�parse_known_args'szParser.parse_known_argscCs$|��}dd�|D�}|j||d�S)zparses and returns a namespace object with known arguments, and
        the remaining arguments unknown at this point.
        cSsg|]}t|��qSr
)rO)r�r�r
r
rr�2sz7Parser.parse_known_and_unknown_args.<locals>.<listcomp>)r�)r�r	)rr+r�r�r
r
rr-sz#Parser.parse_known_and_unknown_argscCs,|dkst�|||f|j|<|j�|�dS)a� register an ini-file option.

        :name: name of the ini-variable
        :type: type of the variable, can be ``pathlist``, ``args``, ``linelist``
               or ``bool``.
        :default: default value if no ini-file option exists but is queried.

        The value of ini-variables can be retrieved via a call to
        :py:func:`config.getini(name) <_pytest.config.Config.getini>`.
        )N�pathlistr+�linelistr�N)r<r�r�r=)rr��help�type�defaultr
r
r�addini5sz
Parser.addini)NN)rN)N)N)N)N)NN)rrrr4r	r�r�r�r�r�rr	rrr
r
r
rr��s
	




r�c@s eZdZdZdd�Zdd�ZdS)�
ArgumentErrorz_
    Raised if an Argument instance is created with invalid or
    inconsistent arguments.
    cCs||_t|�|_dS)N)r0rO�	option_id)rr0r�r
r
rr	KszArgumentError.__init__cCs |jrd|j|jfS|jSdS)Nz
option %s: %s)rr0)rr
r
rrOszArgumentError.__str__N)rrrr4r	rr
r
r
rrEsrc@sFeZdZdZeeeed�Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
S)�Argumentz�class that mimics the necessary behaviour of optparse.Option

    its currently a least effort implementation
    and ignoring choices and integer prefixes
    https://docs.python.org/3/library/optparse.html#optparse-standard-option-types
    )�int�string�float�complexcOsz||_g|_g|_|�d�|_d|�d�p,dkr@tjdtdd�y|d}Wntk
r`Yn~Xt	|t
jj�r�|d	kr�tjd
||ftdd�t
|dd�|d<n&tjd
||ftdd�tj||d<|d|_
n||_
y|d|_Wntk
�rYnX|�|�|j�sv|j�r<|jddd��dd�|_n:y|jddd�|_Wn tk
�rttd|��YnXdS)z3store parms in private vars for use in add_argumentr�z%defaultrrzHpytest now uses argparse. "%default" should be changed to "%(default)s" r�)�
stacklevelr
�choicez|type argument to addoption() is a string %r. For parsearg this is optional and when supplied should be a type. (options: %s)�choicesrz^type argument to addoption() is a string %r. For parsearg this should be a type. (options: %s)rrN�-�_rGzneed a long or short option)�_attrs�_short_opts�
_long_optsrmr��warningsr[�DeprecationWarningr�rMrrWrXr
r�_typ_mapr�_set_opt_strings�replace�
IndexErrorr)rr�r��typr
r
rr	dsT
zArgument.__init__cCs|j|jS)N)rr)rr
r
rr��szArgument.namesc	Cs�d��}|jr|�|j�x6|D].}yt||�|j|<Wq tk
rLYq Xq W|j�d�r~|jd}|�dd�}||jd<|jS)Nzdefault dest helprz%defaultz%(default)s)rTr�r=rnrr�rmr#)rr�r�rr
r
rr��s



zArgument.attrscCs�x�|D]�}t|�dkr&td||��qt|�dkrf|ddkrJ|ddksXtd||��|j�|�q|dd�dkr�|ddks�td||��|j�|�qWd	S)
z]directly from optparse

        might not be necessary as this is passed to argparse later onrz>invalid option string %r: must be at least two characters longrrrGzMinvalid short option string %r: must be of the form -x, (x any non-dash char)z--zGinvalid long option string %r: must start with --, followed by non-dashN)�lenrrr=r)rr��optr
r
rr"�s$
zArgument._set_opt_stringscCs�g}|jr|dt|j�g7}|jr8|dt|j�g7}|dt|j�g7}t|d�rj|dt|j�g7}t|d�r�|dt|j�g7}d�d	�|��S)
Nz
_short_opts: z_long_opts: zdest: r
ztype: rz	default: z
Argument({0})z, )	rrrr�r�r
rr7r)rr+r
r
r�__repr__�s

zArgument.__repr__N)rrrr4rrOrrr!r	r�r�r"r(r
r
r
rrVs:rc@s0eZdZddd�Zdd�Zdd�Zd
d
d�ZdS)r�rNcCs||_||_g|_||_dS)N)r�r�r�r�)rr�r�r�r
r
rr	�szOptionGroup.__init__cOsFt|��dd�|jD��}|r*td|��t||�}|j|dd�dS)aE add an option to this group.

        if a shortened version of a long option is specified it will
        be suppressed in the help. addoption('--twowords', '--two-words')
        results in help showing '--two-words' only, but --twowords gets
        accepted **and** the automatic destination is in args.twowords
        css |]}|��D]
}|VqqdS)N)r�)r�r'r�r
r
r�	<genexpr>�sz(OptionGroup.addoption.<locals>.<genexpr>zoption names %s already addedF)�
shortupperN)rd�intersectionr�rRr�_addoption_instance)r�optnamesr�Zconflictr�r
r
rr��s
zOptionGroup.addoptioncOst||�}|j|dd�dS)NT)r*)rr,)rr-r�r�r
r
r�
_addoption�s
zOptionGroup._addoptionFcCsV|s4x.|jD]$}|ddkr|d��rtd��qW|jrF|j�|�|j�|�dS)NrrrGzlowercase shortoptions reserved)r�islowerrRr�r�r�r=)rr�r*r'r
r
rr,�szOptionGroup._addoption_instance)rN)F)rrrr	r�r.r,r
r
r
rr��s
r�c@s eZdZddd�Zddd�ZdS)r�NcCs.|si}||_tjj||jdtd�||_dS)NF)r�Zadd_helpZformatter_class)�_parser�argparse�ArgumentParserr	r��DropShorterLongHelpFormatterr�)rr�r�r
r
rr	�s
zMyOptionParser.__init__cCs�|�||�\}}|r�xj|D]b}|r|ddkrdd�|�g}x,t|j���D]\}}|�d||f�qNW|�d�|��qWt|t��	|�|S)z'allow splitting of positional argumentsrrzunrecognized arguments: %s� z  %s: %sr)
r	r�sortedr�r�r=�errorrnr�extend)rr+r�rLr��lines�k�vr
r
rr�s
zMyOptionParser.parse_args)N)NN)rrrr	r�r
r
r
rr��s

r�c@seZdZdZdd�ZdS)r3a�shorten help for long options that differ only in extra hyphens

    - collapse **long** options that are the same except for extra hyphens
    - special action attribute map_long_option allows surpressing additional
      long options
    - shortcut if there are only two options and one of them is a short one
    - cache result on action object as this is called at least 2 times
    cCs�tj�||�}|r"|ddkr"|St|dd�}|r6|S|�d�}t|�dkrvt|d�dkslt|d�dkrv||_|Sg}t|di�}|dkr�i}i}x�|D]�}t|�dks�|ddkr�q�|�d	�s�td
||��|dd�}	|	��d|kr�|	�	dd�}
|
|k�st||
�t|	�kr�|	||
<q�Wxh|D]`}t|�dk�sJ|ddk�rT|�
|�|dd�|�|�	dd��k�r*|�
|�	ddd���q*Wd�|�|_|jS)
Nrr�_formatted_action_invocationz, rrGZmap_long_optionr4z--z)long optional argument without "--": [%s]r�=)
r1�
HelpFormatter�_format_action_invocationrnrTr&r;r�rr#r=rmr)r�actionZorgstr�resr�Zreturn_listZ
option_mapZ
short_longr�ZxxoptionZ	shortenedr
r
rr>sD
,





 z6DropShorterLongHelpFormatter._format_action_invocationN)rrrr4r>r
r
r
rr3sr3cCs&ytj|=Wntk
r YnXdS)N)r"r�r�)r�r
r
rr�Gsr�c@s*eZdZdZd
dd�Zdd�Zdd�Zd	S)�
CmdOptionsz% holds cmdline options as attributes.r
cCs|j�|�dS)N)r�update)r�valuesr
r
rr	OszCmdOptions.__init__cCsd|jfS)Nz<CmdOptions %r>)r)rr
r
rr(QszCmdOptions.__repr__cCs
t|j�S)N)rAr)rr
r
r�copySszCmdOptions.copyN)r
)rrrr4r	r(rDr
r
r
rrAMs
rAc@seZdZdd�ZdS)�NotsetcCsdS)Nz<NOTSET>r
)rr
r
rr(WszNotset.__repr__N)rrrr(r
r
r
rrEVsrEr�c@seZdZdZdd�Zdd�Zdd�Zdd	�Zd:dd�Zd
d�Z	dd�Z
d;dd�Zdd�Ze
dd��Zdd�Zedd�dd��Zdd�Zdd �Zd!d"�Zd<d#d$�Zd%d&�Zd=d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zed3fd4d5�Zd>d6d7�Zd?d8d9�Z d
S)@rBzB access to configuration values, pluginmanager and plugin hooks.  cCs�t�|_t}td||f|jd�|_||_|jjj�	d�|_|jj
|_
i|_d|_i|_
g|_|jj|_|j�|d�d|_dd�}|j
j�|i�|j
jjt|jd	�d
�dS)Nz#%%(prog)s [options] [%s] [%s] [...])r�r�rr
ZpytestconfigFcSsddl}t||�dS)Nr)r�setns)�dicrr
r
r�do_setnswsz!Config.__init__.<locals>.do_setns)r�)r�)rAr�rr�r�r0r'rorprmr(�	_inicache�
_override_ini�	_opt2dest�_cleanupr}rZ�_configuredZpytest_namespacer�Zpytest_addoptionry)rr'Z_arHr
r
rr	bs$


zConfig.__init__cCs|j�|�dS)zz Add a function to be called when the config object gets out of
        use (usually coninciding with pytest_unconfigure).N)rLr=)r�funcr
r
r�add_cleanup~szConfig.add_cleanupcCs*|jr
t�d|_|jjjt|d�d�dS)NT)r)r�)rMr<r(r�r�ry)rr
r
r�
_do_configure�s
zConfig._do_configurecCsD|jr$d|_|jj|d�g|jj_x|jr>|j��}|�q&WdS)NF)r)rMr(Zpytest_unconfigurer�Z
_call_historyrLr@)rZfinr
r
rr)�s

zConfig._ensure_unconfigureNcCs |jjjt|||dd�d�dS)z+ generate a warning for this test session. N)rurxrvrw)r�)r(r�r�ry)rrurxrvr
r
rr[�s
zConfig.warncCs|j�d�jS)NZterminalreporter)r'r�Z_tw)rr
r
r�get_terminal_writer�szConfig.get_terminal_writercCs|�|�|S)N)r�)rr'r+r
r
rr\�s
zConfig.pytest_cmdline_parsecCs~|r|jrd}nd}|jdt|dd�|d�}|jj||d�}tj�|�szx0t|��	d�D]}t
j�d	|�t
j�
�qXWdS)
N�longZnativeT�
showlocalsF)ZfuncargsrS�style)�excreprrrzINTERNALERROR> %s
)Z	fulltraceZgetreprrnr(Zpytest_internalerrorrrW�anyrOrTr"r#r,�flush)rrr�rTrUr@r%r
r
r�notify_exception�s

zConfig.notify_exceptioncCs(|j|jkr$|j�|�}|j�|�}|S)N)�invocation_dir�rootdirrZbestrelpath)rrw�fullpathr
r
r�cwd_relative_nodeid�szConfig.cwd_relative_nodeidcCsDt�}|jj�|�|j|dd�x|jjD]}|j�|�q,W|S)z' constructor useable for subprocesses. F)�addopts)r>r�rrBr�r-r'rY)�cls�option_dictr+rr�r
r
r�fromdictargs�szConfig.fromdictargscCsVx |j|jD]}|j|j|<qWt|d�rR|jrRt|j|j�sRt|j|j|j�dS)Nr)rrr�rKr�r�r�r)rr'r�r
r
rr��s
zConfig._processoptT)r�cCs|j�|j�dS)N)r'r��known_args_namespace)r�early_configr
r
r�pytest_load_initial_conftests�sz$Config.pytest_load_initial_conftestscCs�|jj||j��d�\}}t|j|j||jd�}|\|_|_	|_
|j|jjd<|j	|jjd<tj
��|_|j�ddd�|j�dd	�|jp�d
|_dS)N)r�)�warnfuncrZ�inifiler]zextra command line optionsr+�
minversionz!minimally required pytest versionr
)r0rr�rD�determine_setupZinifilenamer�r[rZre�inicfgr�rr
rNrYrZoverride_inirJ)rr+�ns�unknown_args�rr
r
r�_initini�szConfig._initinicCs|j�|�\}}|j}|dk�rytj�|�}Wntk
rHd}Yn�Xddl}||j_	x�|�
d�D]�}x�dD]�}	x�|j�|	�D]z}
|
�
d�d}tj|ko�|�d�}|�tj�d	ko�|�d
�}
|r�tj�|�\}}|�|�q�|
r�tj�|�}|�|�q�WqpWqfW|�|�dS)z�Install the PEP 302 import hook if using assertion re-writing.

        Needs to parse the --assert=<mode> option from the commandline
        and find all the installed plugins to mark them for re-writing
        by the importhook.
        Zrewrite�plainrN�pytest11)ZRECORDzSOURCES.txtr�z.pyrGz__init__.py)r0rZ
assertmoderVrqZinstall_importhook�SystemError�
pkg_resourcesr'rr�iter_entry_points�dist�
_get_metadatarTr5�sep�endswith�countr
�splitextr��dirname�_warn_about_missing_assertion)rr+�entrypoint_namerirj�moder(rpZ
entrypoint�metadata�entry�fnZis_simple_module�
is_package�module_name�ext�package_namer
r
r�_consider_importhook�s,


zConfig._consider_importhookcCsHyds
t�Wntk
r Yn$X|dkr8tj�d�ntj�d�dS)NFrmz[WARNING: ASSERTIONS ARE NOT EXECUTED and FAILING TESTS WILL PASS.  Are you using python -O?z�WARNING: assertions not in test modules or plugins will be ignored because assert statements are not executed by the underlying Python interpreter (are you using python -O?)
)r<r"r#r,)rr{r
r
rry�sz$Config._warn_about_missing_assertioncCs0|�|�|rDt�tj�dd��||dd�<|�d�||dd�<|��d}|�||�|j	�
|�|j	�|�|j	��|j
j||j��d�|_}|jj}|jjdkr�|jr�tj�|j�j}||j_y|jj|||j
d�WnFtk
�r*t��d}|j�s|j�r$|�d|j�n�YnXdS)	NZPYTEST_ADDOPTSrr]rn)r�)rbr+r�rGz&could not load initial conftests (%s)
) rlrSrTr5rlrm�getini�
_checkversionr�r'r�Zload_setuptools_entrypointsr�r0r	r�rDrar�rerr
rNrxr(rcrr"r�r�versionr})rr+r]rzrir�r.r
r
r�	_preparses.
 
zConfig._preparsecCsbddl}|j�dd�}|r^|�d�}|j�d�}||kr^|�d|jjj|j�d�||jf��dS)Nrrf�.z,%s:%d: requires pytest-%s, actual pytest-%s')	rrhrmrT�__version__r*rr
Zlineof)rrZminver�verZmyverr
r
rr�'s
zConfig._checkversioncCs�t|d�rtd��||_|jjjt|jd�d�|j||d�|jj	||d�|j
j||j|jd�}|s�t
��}||jkr�|�d�}|s�|g}||_dS)	Nr+z:can only parse cmdline args at most once per Config object)r')r�)r])rr+)r�r�)r�r<Z	_origargsr(Zpytest_addhooksr�ryr'r�Zpytest_cmdline_preparser0rr�r5�getcwdrZr�r+)rr+r]�cwdr
r
rr�3s

zConfig.parsecCs&|�|�}t|t�st�|�|�dS)z� add a line to an ini-file option. The option must have been
        declared but might not yet be set in which case the line becomes the
        the first line in its value. N)r�rMrQr<r=)rr�r%r�r
r
rr�Fs
zConfig.addinivalue_linecCs8y
|j|Stk
r2|�|�|j|<}|SXdS)a return configuration value from an :ref:`ini file <inifiles>`. If the
        specified name hasn't been registered through a prior
        :py:func:`parser.addini <pytest.config.Parser.addini>`
        call (usually from a plugin), a ValueError is raised. N)rIr��_getini)rr��valr
r
rr�Ns

z
Config.getinic	Cs@y|jj|\}}}Wn"tk
r8td|f��YnX|�|�}|dkr�y|j|}Wn,tk
r�|dk	rv|S|dkr�dSgSX|dkr�tj�|jj	j��
�}g}x&t�|�D]}|�
|j|dd��q�W|S|dkr�t�|�S|dk�rdd	�td
d�|�d��D�S|d
k�r*tt|����S|dk�s8t�|SdS)Nzunknown configuration value: %rrr
T)r�r+rcSsg|]}|r|�qSr
r
)r��tr
r
rr�qsz"Config._getini.<locals>.<listcomp>cSs|��S)N)�strip)r�r
r
r�<lambda>q�z Config._getini.<locals>.<lambda>rr�)r0r�r�rR�_get_override_ini_valuerhrr
rNrr�rSrTr=r�mapr��
_strtoboolr�r<)	rr�r�r
rrZdp�l�relpathr
r
rr�Ys8



zConfig._getinicCs�y|j�||�\}}Wntk
r*dSXtj�|j���}g}xD|D]<}t|tjj�sz|�	dtjjj
�}|j|dd�}|�|�qHW|S)N�/T)r�)
r'r�r�rr
rNr�r�rMr#rtrr=)rr�r
r�ZrelrootsZmodpathr�Zrelrootr
r
r�_getconftest_pathlistxs
zConfig._getconftest_pathlistc
Csdd}xZ|jD]P}xJ|D]B}y|�dd�\}}Wntk
rJtd��YnX||kr|}qWqW|S)Nr<rGz--o/--override-ini expects option=value style.)rJrTrRr*)rr�rZini_config_listZ
ini_config�keyZuser_ini_valuer
r
rr��s
zConfig._get_override_ini_valueFcCs�|j�||�}y$t|j|�}|dkr0|r0t|��|Stk
r||tk	rN|S|rjddl}|�d|f�td|f��YnXdS)ac return command line option value.

        :arg name: name of the option.  You may also specify
            the literal ``--OPT`` option instead of the "dest" option name.
        :arg default: default value if no option of that name exists.
        :arg skip: if True raise pytest.skip if option does not exists
            or has a None value.
        Nrzno %r option foundzno option named %r)	rKrmrnr�r��notsetrr�rR)rr�rr�r�rr
r
r�	getoption�s	zConfig.getoptioncCs
|�|�S)z (deprecated, use getoption()) )r�)rr�r
r
r
r�getvalue�szConfig.getvaluecCs|j|dd�S)z( (deprecated, use getoption(skip=True)) T)r�)r�)rr�r
r
r
r�getvalueorskip�szConfig.getvalueorskip)N)N)T)T)N)N)!rrrr4r	rOrPr)r[rQr\rXr\�classmethodr`r��hookimplrcrlr�ryr�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rrB_s6	


#


rBcCs"y|��S|k
rdSXdS)NF)r�)r
�ignorer
r
rr��sr�c	Cs�ddlm}dddg}dd�|D�}|s4tj��g}x�|D]�}tj�|�}x�|jdd	�D]�}x�|D]�}|�|�}t|�rbtj�	|�}d
|j
kr�|dkr�|r�|d|�|||d
fS|dkr�d|j
kr�|||dfS|dkrb||ifSqbWqXWq:Wd
S)aY
    Search the list of arguments for a valid ini-file for pytest,
    and return a tuple of (rootdir, inifile, cfg-dict).

    note: warnfunc is an optional function used to warn
        about ini-files that use deprecated features.
        This parameter should be removed when pytest
        adopts standard deprecation warnings (#1804).
    r)�SETUP_CFG_PYTESTz
pytest.iniztox.iniz	setup.cfgcSsg|]}t|��d�s|�qS)r)rOr�)r�r�r
r
rr��szgetcfg.<locals>.<listcomp>T)�reverserrKztool:pytest)NNN)Z_pytest.deprecatedr�rr
rNr�rr��	iniconfig�	IniConfig�sections)	r+rdr�Zinibasenamesr��baseZinibasename�pr�r
r
r�getcfg�s*






r�cCs�d}x`|D]X}|��sq
|dkr&|}q
|�|�s
||kr<q
q
|�|�rL|}q
|�|�}|dk	r
|}q
W|dkrztj��}n|��r�|��}|S)N)r�r��commonrr
rNr�r�)�pathsZcommon_ancestorr
�sharedr
r
r�get_common_ancestor�s$


r�cs>dd��dd��dd����fdd�|D�}�fd	d
�|D�S)NcSst|��d�S)Nr)rOr�)r�r
r
r�	is_option�sz%get_dirs_from_args.<locals>.is_optioncSst|��d�dS)Nz::r)rOrT)r�r
r
r�get_file_part_from_node_id�sz6get_dirs_from_args.<locals>.get_file_part_from_node_idcSs|��r|Stj�|j�S)N)r6rr
rNrx)r
r
r
r�get_dir_from_path�sz-get_dirs_from_args.<locals>.get_dir_from_pathc3s&|]}�|�stj��|��VqdS)N)rr
rN)r�r�)r�r�r
rr)sz%get_dirs_from_args.<locals>.<genexpr>csg|]}|��r�|��qSr
)r�)r�r
)r�r
rr�sz&get_dirs_from_args.<locals>.<listcomp>r
)r+Zpossible_pathsr
)r�r�r�r�get_dirs_from_args�s
r�c	Cs�t|�}|rHtj�|�}y|d}Wntk
r<d}YnXt|�}n�t|�}t|g|d�\}}}|dkr�xr|jdd�D]}|�d��	�rzPqzWt||d�\}}}|dkr�ttj
��|g�}tj
�
t|��dtjk}|r�|}|||p�ifS)Nr)rdT)r�zsetup.pyrG)r�rr�r�r�r�r�r�rr�r
rNr5�
splitdriverOrt)	rer+rd�dirsr�rhrZZancestorZ
is_fs_rootr
r
rrgs*

rgcCs�ddl}x�|��D]�\}}t|t�r~t||d�}|dkrfd|}t�|�}|tj|<g|_	t
|||�|j	�|�t||�qt
|||�|j	�|�t
|||�qWdS)Nrz	pytest.%s)
rr�rMryrn�types�
ModuleTyper"r��__all__r�r=rF)�objrGrr�rr�r�r
r
rrF(s


rFcOs6tjj||�}|jjdkr d|_|jjdkr2d|_|S)z�Create a TerminalWriter instance configured according to the options
    in the config object. Every code which requires a TerminalWriter object
    and has access to a config object should use this function.
    �yesT�noF)rr r!r�ZcolorZ	hasmarkup)rr+r�r/r
r
r�create_terminal_writer=sr�cCs2|��}|dkrdS|dkr dStd|f��dS)aConvert a string representation of truth to true (1) or false (0).

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.

    .. note:: copied from distutils.util
    )�yr�r��true�on�1rG)rr��f�false�off�0rzinvalid truth value %rN)�lowerrR)r�r
r
rr�Js	r�)NN)NN)N)N)@r4r1rSrr�rrr"r5Z
_pytest._coderVZ_pytest.hookspecZ_pytest.assertionZ_pytest._pluggyrrrZ_pytest.compatrr�rkrrr1r2r*r9r:r;rTrCrdr�r�r?r>rFrrAr�r�rrr�r2r�r=r3r��objectrArEr�rrB�EnvironmentErrorr�r�r�r�rgrFr�r�r
r
r
r�<module>sn



v$2	X
"