
^Yc           @` s  d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z d d l m Z e d  Z e d  Z d e f d     YZ e e d	  Z d
 f  d     YZ d e f d     YZ d e f d     YZ d   Z  d   Z! g  Z" d j#   Z$ e% e$  Z& e& j' d  d   Z( d   Z) d   Z* e e d  Z+ d e f d     YZ, d   Z- d f  d     YZ. d e f d     YZ/ d f  d      YZ0 d! f  d"     YZ1 d# e j2 f d$     YZ3 d% e j4 f d&     YZ5 d'   Z6 d( e7 f d)     YZ8 d* f  d+     YZ9 e9   Z: d, Z; d- e7 f d.     YZ< e= d/  Z> e d0  Z? d1   Z@ d2   ZA e d3  ZB d4   ZC d5   ZD d6   ZE d S(7   s<    command line options, ini-file and conftest.py processing. i    (   t   absolute_importt   divisiont   print_functionN(   t   PluginManagert   HookimplMarkert   HookspecMarker(   t   safe_strt   pytestt   ConftestImportFailurec           B` s   e  Z d    Z d   Z RS(   c         C` s)   t  j |  | |  | |  _ | |  _ d  S(   N(   t	   Exceptiont   __init__t   patht   excinfo(   t   selfR   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
      s    	c         C` s@   |  j  \ } } } t j |  } t |  d d j | d  S(   Ns   
t    i   (   R   t	   tracebackt	   format_tbt   reprt   join(   R   t   etypet   evaluet   etbt	   formatted(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   __str__    s    (   t   __name__t
   __module__R
   R   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR      s   	c         C` s   y y t  |  |  } Wny t k
 r } t j j t j  } x3 t j | j	   D] } | j
 | j   d t qP W| j
 d | j d t d SXz | j j d |  SWd | j   XWn? t k
 r } x( | j D] } t j j d | f  q Wd SXd S(   s    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   reds   ERROR: could not load %s
i   t   configNs
   ERROR: %s
(   t   _prepareconfigR   t   pyt   iot   TerminalWritert   syst   stderrR   t   format_exceptionR   t   linet   rstript   TrueR   t   hookt   pytest_cmdline_maint   _ensure_unconfiguret
   UsageErrort   argst   write(   R*   t   pluginsR   t   et   twR#   t   msg(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   main'   s     t   cmdlinec           B` s   e  Z e e  Z RS(    (   R   R   t   staticmethodR0   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR1   B   s   R)   c           B` s   e  Z d  Z RS(   s$    error in pytest usage or invocation(   R   R   t   __doc__(    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR)   F   s   t	   PrintHelpc           B` s   e  Z d  Z RS(   sf   Raised when pytest should print it's help to skip the rest of the
    argument parsing and validation.(   R   R   R3   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR4   J   s   c         C` s1   t  j j |   r- t d j | |     n  |  S(   ss    Argparse type validator for filename arguments.

    :path: path of filename
    :optname: name of the option
    s"   {0} must be a filename, given: {1}(   t   osR   t   isdirR)   t   format(   R   t   optname(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   filename_argP   s    c         C` s1   t  j j |   s- t d j | |     n  |  S(   st   Argparse type validator for directory arguments.

    :path: path of directory
    :optname: name of the option
    s#   {0} must be a directory, given: {1}(   R5   R   R6   R)   R7   (   R   R8   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   directory_arg[   s    s   mark main terminal runner python fixtures debugging unittest capture skipping tmpdir monkeypatch recwarn pastebin helpconfig nose assertion junitxml resultlog doctest cacheprovider freeze_support setuponly setupplan warningst   pytesterc           C` s!   t  s t  t  j t    d  S(   N(   t   _preinitt   AssertionErrort   appendt
   get_config(    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   _preloadpluginss   s    c          C` sJ   t  r t  j d  St   }  t |   } x t D] } |  j |  q/ W| S(   Ni    (   R<   t   popt   PytestPluginManagert   Configt   default_pluginst   import_plugin(   t   pluginmanagerR   t   spec(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR?   w   s    	c           C` s
   t    j S(   s   
    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?   RF   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   get_plugin_manager   s    	c         C` sv  d  } |  d  k r" t j d }  n t |  t j j  rI t |   g }  nt t |  t t	 f  s t |  t  s t
 d |  f   n  t j |  d t j d k }  d d l m } | j } n  t   } | j } y | rxC | D]8 } t | t j j  r
| j |  q | j |  q Wn  | r7| j d |  n  | j j d | d	 |   SWn t k
 rq| j     n Xd  S(
   Ni   s!   not a string or argument list: %rt   posixt   win32i    (   t
   deprecatedt   C1RF   R*   (   t   NoneR    t   argvt
   isinstanceR   R   t   localt   strt   tuplet   listt
   ValueErrort   shlext   splitt   platformt   _pytestRK   t   MAIN_STR_ARGSR?   RF   t   builtint   _basestringt   consider_pluginargt   registert   warnR&   t   pytest_cmdline_parset   BaseExceptionR(   (   R*   R,   t   warningRK   R   RF   t   plugin(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR      s4    		
RB   c           B` s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d d  Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   sY  
    Overwrites :py:class:`pluggy.PluginManager <_pytest.vendored_packages.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;
    c         C` s  t  t |   j d d d t   |  _ i  |  _ i  |  _ d  |  _ t	 |  _
 t   |  _ |  j t j  |  j |   t j j d  r t j } t | d d  } y t j j | d | } Wn t k
 r n X|  j j j | j  |  j   n  t j j    |  _! d  S(   NR   t
   implprefixt   pytest_t   PYTEST_DEBUGt   encodingt   utf8("   t   superRB   R
   t   sett   _conftest_pluginst   _path2confmodst   _conftestpath2modRM   t   _confcutdirt   Falset   _noconftestt   _duplicatepathst   add_hookspecsRX   t   hookspecR]   R5   t   environt   getR    R!   t   getattrR   R   t   dupfileR	   t   tracet   roott	   setwriterR+   t   enable_tracingt	   assertiont   DummyRewriteHookt   rewrite_hook(   R   t   errRf   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
      s&    					c      	   C` sP   t  d d d t j j t j d   d d d d  } |  j |  |  j |  S(	   s   
        .. deprecated:: 2.8

        Use :py:meth:`pluggy.PluginManager.add_hookspecs <_pytest.vendored_packages.pluggy.PluginManager.add_hookspecs>` instead.
        t   codet   I2t
   fslocationi   t   nodeidt   messagesH   use pluginmanager.add_hookspecs instead of deprecated addhooks() method.N(	   t   dictRX   t   _codet   getfslinenoR    t	   _getframeRM   t   _warnRq   (   R   t   module_or_classRa   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   addhooks   s    	c         C` s   | j  d  s d  S| d k s. | j  d  r2 d  St | |  } t t |   j | |  } | d  k	 r x* d D] } | j | t | |   qo Wn  | S(	   NRd   t   pytest_pluginst   pytest_funcarg__t   tryfirstt   trylastt   optionalhookt   hookwrapper(   R   s   trylastR   R   (   t
   startswithRu   Rh   RB   t   parse_hookimpl_optsRM   t
   setdefaultt   hasattr(   R   Rb   t   namet   methodt   opts(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR      s     c         C` su   t  t |   j | |  } | d  k rq t | |  } | j d  rq i t | d  d 6t | d  d 6} qq n  | S(   NRd   t   firstresultt   historic(   Rh   RB   t   parse_hookspec_optsRM   Ru   R   R   (   R   R   R   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR      s    c      
   C` sy   t  t |   j | |  d | j k ru t j j | j  } t d d d | d d  d d | j
  } |  j |  n  d  S(   Nt   __multicall__R   t   I1R   R   R   s.   %r hook uses deprecated __multicall__ argument(   Rh   RB   t   _verify_hookt   argnamesRX   R   R   t   functionR   RM   R   R   (   R   R&   t
   hookmethodt   fslinenoRa   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR      s    c         C` so   t  t |   j | |  } | rk |  j j j d t d | d |    t | t j	  rk |  j
 |  qk n  | S(   Nt   kwargsRb   t   manager(   Rh   RB   R]   R&   t   pytest_plugin_registeredt   call_historicR   RO   t   typest
   ModuleTypet   consider_module(   R   Rb   R   t   ret(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR]     s    c         C` s   |  j  |  S(   N(   t
   get_plugin(   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt	   getplugin  s    c         C` s   t  |  j |   S(   s<   Return True if the plugin with the given name is registered.(   t   boolR   (   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt	   hasplugin  s    c         C` s$   | j  d d  | j  d d  d  S(   Nt   markerss|   tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible.sy   trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible.(   t   addinivalue_line(   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   pytest_configure  s    		c         C` sQ   t  | t  r | n i d d 6| d 6d  d 6d  d 6} |  j j j d |  d  S(   NR   R   R   R   R   R   (   RO   R   RM   R&   t   pytest_logwarningR   (   R   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s    
c         C` s   t  j j   } | j r0 | j | j d t n d |  _ | j |  _	 | j
 } t } xy | D]q } t |  } | j d  } | d k r | |  } n  | j | d d } t |  r[ |  j |  t } q[ q[ W| s |  j |  n  d S(   s}   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   abss   ::ii   N(   R   R   RP   t
   confcutdirR   R%   RM   Rm   t
   noconftestRo   t   file_or_dirRn   RQ   t   findt   existst   _try_load_conftest(   R   t	   namespacet   currentt	   testpathst   foundanchorR   t   it   anchor(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   _set_initial_conftests)  s     *	c         C` sb   |  j  |  | j d d  r^ x< | j d  D]( } | j d d  r/ |  j  |  q/ q/ Wn  d  S(   Nt   diri   s   test*(   t   _getconftestmodulest   checkt   listdir(   R   R   t   x(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR   D  s
    c         C` s   |  j  r g  Sy |  j | SWn t k
 r | j   rP |  j | j    } nx g  } xo | j   D]a } |  j r |  j j |  r qc n  | j	 d  } | j   rc |  j
 |  } | j |  qc qc W| |  j | <| SXd  S(   Ns   conftest.py(   Ro   Rk   t   KeyErrort   isfileR   t   dirpatht   partsRm   t   reltoR   t   _importconftestR>   (   R   R   t   clistt   parentt   conftestpatht   mod(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR   L  s"    	c         C` sd   |  j  |  } xB t |  D]4 } y | t | |  f SWq t k
 rO q q Xq Wt |   d  S(   N(   R   t   reversedRu   t   AttributeErrorR   (   R   R   R   t   modulesR   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   _rget_with_confmodd  s    c         C` sE  y |  j  | SWn/t k
 r@| j   } | d  k rG t | j  n  y | j   } Wn& t k
 r t | t	 j
     n X|  j j |  | |  j  | <| j   } | |  j k rxc |  j j   D]O \ } } | r | j |  s | | k r | | k st  | j |  q q Wn  |  j d |  |  j |  | SXd  S(   Ns   loaded conftestmodule %r(   Rl   R   t	   pypkgpathRM   t   _ensure_removed_sysmodulet   purebasenamet   pyimportR	   R   R    t   exc_infoRj   t   addR   Rk   t   itemsR   R=   R>   Rw   t   consider_conftest(   R   R   t   pkgpathR   R   R   t   mods(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR   m  s*    !c         C` sD   x= t  | | d  D]( \ } } | d k r |  j |  q q Wd  S(   Ni   s   -p(   t   zipR\   (   R   R*   t   opt1t   opt2(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   consider_preparse  s     c         C` s]   | j  d  rL | d } |  j |  | j  d  sY |  j d |  qY n |  j |  d  S(   Ns   no:i   Rd   (   R   t   set_blockedRE   (   R   t   argR   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR\     s    
c         C` s   |  j  | d | j d  S(   NR   (   R]   t   __file__(   R   t   conftestmodule(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s    c         C` s   |  j  t j j d   d  S(   Nt   PYTEST_PLUGINS(   t   _import_plugin_specsR5   Rs   Rt   (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   consider_env  s    c         C` s   |  j  t | d g    d  S(   NR   (   R   Ru   (   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s    c         C` s.   t  |  } x | D] } |  j |  q Wd  S(   N(   t   _get_plugin_specs_as_listRE   (   R   RG   R,   t   import_spec(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s    c         C` s  t  | t j j t f  s+ t d |   t |  } |  j |  d  k	 rP d  S| t k ri d | } n | } |  j	 j
 |  y t |  Wn t k
 r} t d | t | j d  f  } x9 d	 D]1 } t | |  r t | | t | |   q q W|  n t k
 rk} d d  l } t | d  sHt  | | j j  rN  n  |  j d | | j f  n Xt j | } |  j | |  d  S(
   Ns$   module name as text required, got %rs   _pytest.s   Error importing plugin "%s": %si    R   R   t   skips   skipped plugin %r: %s(   s   names   path(   RO   R   RZ   t   textRQ   R=   R   RM   t   builtin_pluginsR}   t   mark_rewritet
   __import__t   ImportErrorR   R*   R   t   setattrRu   R	   R   R   R   R/   R    R   R]   (   R   t   modnamet
   importspecR-   t   new_exct   attrR   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRE     s.    +# 	&N(   R   R   R3   R
   R   R   R   R   RM   R]   R   R   R   R   R   R   R   R   R   R   R\   R   R   R   R   RE   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRB      s.   				
	
			
														c         C` so   |  d k	 rk t |  t  r9 |  r0 |  j d  n g  }  n  t |  t t f  sa t d |    n  t |   Sg  S(   s  
    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.
    t   ,sb   Plugin specs must be a ','-separated string or a list/tuple of strings for plugin names. Given: %rN(   RM   RO   RQ   RV   RS   RR   R)   (   t   specs(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s    
t   Parserc           B` s   e  Z d  Z d d d  Z d   Z d d d  Z d   Z d d  Z d   Z	 d d  Z
 d d	  Z d d
  Z d d d  Z RS(   s    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.
    c         C` sO   t  d d |  |  _ g  |  _ | |  _ | |  _ i  |  _ g  |  _ i  |  _ d  S(   Ns   custom optionst   parser(   t   OptionGroupt
   _anonymoust   _groupst   _processoptt   _usaget   _inidictt	   _ininamest
   extra_info(   R   t   usaget
   processopt(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
     s    					c         C` s)   |  j  r% | j r% |  j  |  q% n  d  S(   N(   R   t   dest(   R   t   option(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   processoption  s    		R   c         C` s   x$ |  j  D] } | j | k r
 | Sq
 Wt | | d |  } d } x0 t |  j   D] \ } } | j | k rR PqR qR W|  j  j | d |  | S(   s   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   i    i   (   R   R   R   t	   enumeratet   insert(   R   R   t   descriptiont   aftert   groupR   t   grp(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   getgroup  s    c         O` s   |  j  j | |   d S(   s   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   t	   addoption(   R   R   t   attrs(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    c         C` s[   d d l  m } |  j   |  _ | |  j  |  j j g  | D] } t |  ^ q< d | S(   Ni    (   t   try_argcompleteR   (   t   _pytest._argcompleteR  t
   _getparsert	   optparsert
   parse_argsRQ   (   R   R*   R   R  R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   parse  s    c   
      C` s   d d l  m } t |  |  j  } |  j |  j g } xw | D]o } | j r< | j pZ | j } | j	 |  } x< | j D]. } | j
   } | j   }	 | j | |	   qv Wq< q< W| | j t d d _ | S(   Ni    (   t   filescompletert   nargst   *(   R  R  t   MyOptionParserR   R   R   t   optionsR  R   t   add_argument_groupt   namesR  t   add_argumentt   FILE_OR_DIRt	   completer(
   R   R  R  t   groupsR
  t   desct   arggroupR  t   nt   a(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    	c         C` sR   |  j  | d | } x- | j j   D] \ } } t | | |  q% Wt | t  S(   NR   (   R  t   __dict__R   R   Ru   R  (   R   R*   R  R   t   parsedoptionR   t   value(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   parse_setoption+  s    c         C` s   |  j  | d | d S(   sZ   parses and returns a namespace object with known arguments at this
        point.
        R   i    (   t   parse_known_and_unknown_args(   R   R*   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   parse_known_args1  s    c         C` s>   |  j    } g  | D] } t |  ^ q } | j | d | S(   s   parses and returns a namespace object with known arguments, and
        the remaining arguments unknown at this point.
        R   (   R  RQ   R)  (   R   R*   R   R  R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR(  7  s    c         C` s<   | d k s t  | | | f |  j | <|  j j |  d S(   s   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>`.
        t   pathlistR*   t   linelistR   N(   Ns   pathlists   argsR+  s   bool(   RM   R=   R   R   R>   (   R   R   t   helpt   typet   default(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   addini?  s    N(   R   R   R3   RM   R
   R  R  R  R  R  R'  R)  R(  R/  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s   				t   ArgumentErrorc           B` s    e  Z d  Z d   Z d   Z RS(   s_   
    Raised if an Argument instance is created with invalid or
    inconsistent arguments.
    c         C` s   | |  _  t |  |  _ d  S(   N(   R/   RQ   t	   option_id(   R   R/   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
   U  s    	c         C` s(   |  j  r d |  j  |  j f S|  j Sd  S(   Ns   option %s: %s(   R1  R/   (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR   Y  s    	(   R   R   R3   R
   R   (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR0  O  s   	t   Argumentc           B` s]   e  Z d  Z i e d 6e d 6e d 6e d 6Z d   Z d   Z	 d   Z
 d   Z d	   Z RS(
   s   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
    t   intt   stringt   floatt   complexc         O` s  | |  _  g  |  _ g  |  _ | j d  |  _ d | j d  pB d k ra t j d t d d n  y | d } Wn t k
 r n Xt	 | t
 j j  r | d	 k r t j d
 | | f t d d t | d d  | d <n1 t j d | | f t d d t j | | d <| d |  _ n	 | |  _ y | d |  _ Wn t k
 rMn X|  j |  |  j s|  j r|  j d d j d d  |  _ qy |  j d d |  _ Wqt k
 rt d |    qXn  d S(   s3   store parms in private vars for use in add_argumentR  s   %defaultR,  R   sH   pytest now uses argparse. "%default" should be changed to "%(default)s" t
   stackleveli   R-  t   choices|   type argument to addoption() is a string %r. For parsearg this is optional and when supplied should be a type. (options: %s)t   choicesi    s^   type argument to addoption() is a string %r. For parsearg this should be a type. (options: %s)R.  i   t   -t   _i   s   need a long or short optionN(   t   _attrst   _short_optst
   _long_optsRt   R  t   warningsR^   t   DeprecationWarningR   RO   R   RZ   R[   R-  R2  t   _typ_mapR.  t   _set_opt_stringst   replacet
   IndexErrorR0  (   R   R  R  t   typ(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
   n  sT    			


			#c         C` s   |  j  |  j S(   N(   R=  R>  (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    c         C` s   d j    } |  j r( | j |  j  n  x< | D]4 } y t |  |  |  j | <Wq/ t k
 rb q/ Xq/ W|  j j d  r |  j d } | j d d  } | |  j d <n  |  j S(   Ns   default dest helpR,  s   %defaults   %(default)s(   RV   R  R>   Ru   R<  R   Rt   RC  (   R   R  R   R#  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    	c         C` s   x | D] } t  |  d k  r5 t d | |    q t  |  d k r | d d k od | d d k s} t d | |    n  |  j j |  q | d d !d k o | d d k s t d | |    n  |  j j |  q Wd	 S(
   s]   directly from optparse

        might not be necessary as this is passed to argparse later oni   s>   invalid option string %r: must be at least two characters longi    R:  i   sM   invalid short option string %r: must be of the form -x, (x any non-dash char)s   --sG   invalid long option string %r: must start with --, followed by non-dashN(   t   lenR0  R=  R>   R>  (   R   R   t   opt(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRB    s$     #c         C` s   g  } |  j  r, | d t |  j   g 7} n  |  j rR | d t |  j  g 7} n  | d t |  j  g 7} t |  d  r | d t |  j  g 7} n  t |  d  r | d t |  j  g 7} n  d j d	 j |   S(
   Ns   _short_opts: s   _long_opts: s   dest: R-  s   type: R.  s	   default: s   Argument({0})s   , (	   R=  R   R>  R  R   R-  R.  R7   R   (   R   R*   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   __repr__  s    		(   R   R   R3   R3  RQ   R5  R6  RA  R
   R  R  RB  RH  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR2  `  s   
	:			R   c           B` s5   e  Z d  d d  Z d   Z d   Z e d  Z RS(   R   c         C` s(   | |  _  | |  _ g  |  _ | |  _ d  S(   N(   R   R  R  R   (   R   R   R  R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
     s    			c         O` sa   t  |  j d   |  j D  } | r; t d |   n  t | |   } |  j | d t d S(   sE   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
        c         s` s(   |  ] } | j    D] } | Vq q d  S(   N(   R  (   t   .0RG  R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pys	   <genexpr>  s    s   option names %s already addedt
   shortupperN(   Ri   t   intersectionR  RT   R2  t   _addoption_instanceRn   (   R   t   optnamesR  t   conflictR  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    c         O` s&   t  | |   } |  j | d t d  S(   NRJ  (   R2  RL  R%   (   R   RM  R  R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt
   _addoption  s    c         C` s|   | sL xC | j  D]5 } | d d k r | d j   r t d   q q Wn  |  j rh |  j j |  n  |  j j |  d  S(   Ni    R:  i   s   lowercase shortoptions reserved(   R=  t   islowerRT   R   R  R  R>   (   R   R  RJ  RG  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRL    s     	N(   R   R   RM   R
   R  RO  Rn   RL  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s   		R  c           B` s#   e  Z d d   Z d d d  Z RS(   c         C` sJ   | s i  } n  | |  _  t j j |  d | j d t d t | |  _ d  S(   NR  t   add_helpt   formatter_class(   t   _parsert   argparset   ArgumentParserR
   R   Rn   t   DropShorterLongHelpFormatterR   (   R   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
     s    		c         C` s   |  j  | |  \ } } | r x | D] } | r% | d d k r% d d j |  g } x: t |  j j    D]# \ } } | j d | | f  qm W|  j d j |   q% q% Wt | t  j	 |  n  | S(   s'   allow splitting of positional argumentsi    R:  s   unrecognized arguments: %st    s     %s: %ss   
(
   R)  R   t   sortedR   R   R>   t   errorRu   R  t   extend(   R   R*   R   RN   R   t   linest   kt   v(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    "N(   R   R   RM   R
   R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s   
RV  c           B` s   e  Z d  Z d   Z RS(   s  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
    c         C` s@  t  j j |  |  } | r/ | d d k r/ | St | d d   } | rK | S| j d  } t |  d k r t | d  d k s t | d  d k r | | _ | Sg  } t | d i   } | d  k r i  } n  i  } x | D] } t |  d k s | d d k rq n  | j d	  s2t	 d
 | |    n  | d }	 |	 j   d | k r |	 j
 d d  }
 |
 | k st | |
  t |	  k  r|	 | |
 <qq q Wx | D]| } t |  d k s| d d k r| j |  n  | d | j | j
 d d   k r| j | j
 d d d   qqWd j |  | _ | j S(   Ni    R:  t   _formatted_action_invocations   , i   i   t   map_long_optionRW  s   --s)   long optional argument without "--": [%s]R   t   =(   RT  t   HelpFormattert   _format_action_invocationRu   RM   RV   RF  R^  R   R0  RC  R>   Rt   R   (   R   t   actiont   orgstrt   resR  t   return_listt
   option_mapt
   short_longR  t   xxoptiont	   shortened(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRb  (  sD    >		"
"%#(   R   R   R3   Rb  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRV    s   c         C` s&   y t  j |  =Wn t k
 r! n Xd  S(   N(   R    R   R   (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR   Q  s    t
   CmdOptionsc           B` s,   e  Z d  Z d d  Z d   Z d   Z RS(   s%    holds cmdline options as attributes.c         C` s   |  j  j |  d  S(   N(   R$  t   update(   R   t   values(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
   Y  s    c         C` s   d |  j  f S(   Ns   <CmdOptions %r>(   R$  (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRH  [  s    c         C` s   t  |  j  S(   N(   Rk  R$  (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   copy]  s    (    (   R   R   R3   R
   RH  Rn  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRk  W  s   	t   Notsetc           B` s   e  Z d    Z RS(   c         C` s   d S(   Ns   <NOTSET>(    (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRH  a  s    (   R   R   RH  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRo  `  s   R   RC   c           B` s1  e  Z d  Z d   Z d   Z d   Z d   Z d d d  Z d   Z	 d   Z
 d d  Z d	   Z e d
    Z d   Z e d e  d    Z d   Z d   Z d   Z d   Z e d  Z d   Z e d  Z d   Z d   Z d   Z d   Z d   Z e e  d  Z! d d  Z" d d  Z# RS(   sB    access to configuration values, pluginmanager and plugin hooks.  c         C` s   t    |  _ t } t d d | | f d |  j  |  _ | |  _ |  j j j j	 d  |  _ |  j j
 |  _
 i  |  _ d	 |  _ i  |  _ g  |  _ |  j j |  _ |  j j |  d  t |  _ d   } |  j
 j j | i   |  j
 j j d t d |  j   d  S(
   NR  s#   %%(prog)s [options] [%s] [%s] [...]R  R   t   pytestconfigc         S` s   d d  l  } t | |   d  S(   Ni    (   R   t   setns(   t   dicR   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   do_setns  s    R   R   (    (   Rk  R  R  R   R   RS  RF   Rw   Rx   Rt   R&   t	   _inicachet   _override_init	   _opt2destt   _cleanupR   R]   Rn   t   _configuredt   pytest_namespaceR   t   pytest_addoptionR   (   R   RF   t   _aRs  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR
   l  s$    							c         C` s   |  j  j |  d S(   sz    Add a function to be called when the config object gets out of
        use (usually coninciding with pytest_unconfigure).N(   Rw  R>   (   R   t   func(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   add_cleanup  s    c         C` s<   |  j  s t  t |  _  |  j j j d t d |    d  S(   NR   R   (   Rx  R=   R%   R&   R   R   R   (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   _do_configure  s    	c         C` sa   |  j  r7 t |  _  |  j j d |   g  |  j j _ n  x# |  j r\ |  j j   } |   q: Wd  S(   NR   (   Rx  Rn   R&   t   pytest_unconfigureR   t   _call_historyRw  RA   (   R   t   fin(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR(     s    		c         C` s5   |  j  j j d t d | d | d | d |   d S(   s+    generate a warning for this test session. R   R   R   R   R   N(   R&   R   R   R   (   R   R   R   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR^     s    c         C` s   |  j  j d  j S(   Nt   terminalreporter(   RF   R   t   _tw(   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   get_terminal_writer  s    c         C` s   |  j  |  |  S(   N(   R  (   R   RF   R*   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR_     s    c         C` s   | r | j  r d } n d } | j d t d t | d t  d |  } |  j j d | d |  } t j j	 |  s xA t
 |  j d  D]' } t j j d	 |  t j j   q Wn  d  S(
   Nt   longt   nativet   funcargst
   showlocalst   stylet   excreprR   s   
s   INTERNALERROR> %s
(   t	   fulltracet   getreprR%   Ru   Rn   R&   t   pytest_internalerrorR   RZ   t   anyRQ   RV   R    R!   R+   t   flush(   R   R   R  R  R  Re  R#   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   notify_exception  s    			c         C` s=   |  j  |  j k r9 |  j j |  } |  j  j |  } n  | S(   N(   t   invocation_dirt   rootdirR   t   bestrelpath(   R   R   t   fullpath(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   cwd_relative_nodeid  s    c         C` sZ   t    } | j j j |  | j | d t x$ | j j D] } | j j |  q< W| S(   s'    constructor useable for subprocesses. t   addopts(	   R?   R  R$  Rl  R  Rn   R,   RF   R\   (   t   clst   option_dictR*   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   fromdictargs  s    	c         C` s{   x( | j  | j D] } | j |  j | <q Wt | d  rw | j rw t |  j | j  sw t |  j | j | j  qw n  d  S(   NR.  (   R=  R>  R  Rv  R   R  R   R.  (   R   RG  R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s
    R   c         C` s   |  j  j | j  d  S(   N(   RF   R   t   known_args_namespace(   R   t   early_config(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   pytest_load_initial_conftests  s    c         C` s   |  j  j | d |  j j   \ } } t | j | j | d |  j } | \ |  _ |  _	 |  _
 |  j |  j  j d <|  j	 |  j  j d <t j j   |  _ |  j  j d d d  |  j  j d d	  | j p d
 |  _ d  S(   NR   t   warnfuncR  t   inifileR  s   extra command line optionsR*   t
   minversions!   minimally required pytest version(    (   RS  R(  R  Rn  t   determine_setupt   inifilenameR   R^   R  R  t   inicfgR   R   R   RP   R  R/  t   override_iniRu  (   R   R*   t   nst   unknown_argst   r(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   _initini  s    '"c         C` s~   |  j  j |  \ } } | j } | d k rm y t j j |   } Wn t k
 r\ d } qm X|  j |  n  |  j |  d S(   s   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.
        t   rewritet   plainN(	   RS  R(  t
   assertmodeRX   R{   t   install_importhookt   SystemErrort   _mark_plugins_for_rewritet   _warn_about_missing_assertion(   R   R*   R  R  t   modeR&   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   _consider_importhook  s    	
c   
      ` s   d d l  } | |  j _ d
     f d   | j d  D } x | D] } t j | k oe | j d  } | j t j  d k o | j d	  } | r t j j	 |  \ } } | j
 |  qD | rD t j j |  }	 | j
 |	  qD qD Wd S(   s   
        Given an importhook, mark for rewrite any top-level
        modules or packages in the distribution package for
        all pytest plugins.
        i    Nt   RECORDs   SOURCES.txtc         3` sH   |  ]> }   D]1 } | j  j |  D] } | j d   d Vq# q q d S(   R   i    N(   t   distt   _get_metadataRV   (   RI  t
   entrypointt   metadatat   entry(   t   metadata_files(    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pys	   <genexpr>  s   
t   pytest11s   .pyi   s   __init__.py(   s   RECORDs   SOURCES.txt(   t   pkg_resourcesRF   R}   t   iter_entry_pointsR5   t   sept   endswitht   countR   t   splitextR   t   dirname(
   R   R&   R  t   package_filest   fnt   is_simple_modulet
   is_packaget   module_namet   extt   package_name(    (   R  s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    'c         C` sW   y t  s t  Wn t k
 r# n0 X| d k rC t j j d  n t j j d  d  S(   NR  s[   WARNING: ASSERTIONS ARE NOT EXECUTED and FAILING TESTS WILL PASS.  Are you using python -O?s   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?)
(   Rn   R=   R    R!   R+   (   R   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    c         C` s  |  j  |  | rM t j t j j d d   | | (|  j d  | | (n  |  j   |  j |  |  j	 j
 |  |  j	 j d  |  j	 j   |  j j | d |  j j   |  _ } |  j j } |  j j d  k r|  j rt j j |  j  j } | |  j _ n  y& |  j j d |  d | d |  j  WnM t k
 r|t j   d	 } | j s_| j rv|  j  d
 | j  q}  n Xd  S(   Nt   PYTEST_ADDOPTSR   R  R  R   R  R*   R   i   s&   could not load initial conftests (%s)
(!   R  RU   RV   R5   Rs   Rt   t   getinit   _checkversionR  RF   R   t   load_setuptools_entrypointsR   RS  R)  R  Rn  R  R   RM   R  R   R   RP   R  R&   R  R   R    R   R,  t   versionR   (   R   R*   R  R  R   R-   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt	   _preparse$  s,    #
(c         C` s   d d  l  } |  j j d d   } | r | j d  } | j j d  } | | k  r | j d |  j j j |  j j	 d  | | j f   q n  d  S(   Ni    R  t   .s,   %s:%d: requires pytest-%s, actual pytest-%s'(
   R   R  Rt   RM   RV   t   __version__R)   R   R   t   lineof(   R   R   t   minvert   vert   myver(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR  ?  s    c         C` s  t  |  d  s t d   | |  _ |  j j j d t d |  j   |  j | d | |  j j	 d |  d |  t
 |  j _ yv |  j j | |  j d |  j } | s t j   } | |  j k r |  j d  } n  | s | g } q n  | |  _ Wn t k
 rn Xd  S(	   NR*   s:   can only parse cmdline args at most once per Config objectR   RF   R  R   R   R   (   R   R=   t	   _origargsR&   t   pytest_addhooksR   R   RF   R  t   pytest_cmdline_preparseR%   RS  t   after_preparseR'  R  R5   t   getcwdR  R  R*   R4   (   R   R*   R  t   cwd(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR  K  s&    		!c         C` s5   |  j  |  } t | t  s$ t  | j |  d S(   s    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  RO   RS   R=   R>   (   R   R   R#   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR   b  s    c         C` sB   y |  j  | SWn, t k
 r= |  j |  |  j  | <} | SXd S(   s   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(   Rt  R   t   _getini(   R   R   t   val(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR  j  s
    c   
      C` s  y |  j  j | \ } } } Wn$ t k
 rC t d | f   n X|  j |  } | d  k r y |  j | } Wq t k
 r | d  k	 r | S| d  k r d Sg  SXn  | d k rt j j	 |  j j
 j  j   } g  } x3 t j |  D]" } | j | j | d t  q W| S| d k r.t j |  S| d k rlg  t d   | j d   D] }	 |	 rV|	 ^ qVS| d	 k rt t | j     S| d  k st  | Sd  S(
   Ns   unknown configuration value: %rR   R*  R   R*   R+  c         S` s
   |  j    S(   N(   t   strip(   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   <lambda>  s    s   
R   (   RS  R   R   RT   t   _get_override_ini_valueRM   R  R   R   RP   R   R   RU   RV   R>   R   R%   t   mapR   t
   _strtoboolR  R=   (
   R   R   R  R-  R.  R&  t   dpt   lt   relpatht   t(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR  u  s8    ! 2c         C` s   y |  j  j | |  \ } } Wn t k
 r3 d  SXt j j | j  j   } g  } xc | D][ } t	 | t j j  s | j
 d t j j j  } | j | d t } n  | j |  q\ W| S(   Nt   /R   (   RF   R   R   RM   R   R   RP   R   R   RO   RC  R  R   R%   R>   (   R   R   R   R   t   relrootst   modpathR  t   relroot(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   _getconftest_pathlist  s    c         C` s   d  } xs |  j D]h } x_ | D]W } y | j d d  \ } } Wn t k
 r^ t d   n X| | k r | } q q Wq W| S(   NR`  i   s-   -o/--override-ini expects option=value style.(   RM   Ru  RV   RT   R)   (   R   R   R&  t   ini_config_listt
   ini_configt   keyt   user_ini_value(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR    s    c         C` s   |  j  j | |  } y; t |  j |  } | d k rK | rK t |   n  | SWn] t k
 r | t k	 rp | S| r d d l } | j d | f  n  t	 d | f   n Xd S(   sc   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.
        i    Ns   no %r option founds   no option named %r(
   Rv  Rt   Ru   R  RM   R   t   notsetR   R   RT   (   R   R   R.  R   R  R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt	   getoption  s    	c         C` s   |  j  |  S(   s    (deprecated, use getoption()) (   R  (   R   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   getvalue  s    c         C` s   |  j  | d t S(   s(    (deprecated, use getoption(skip=True)) R   (   R  R%   (   R   R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   getvalueorskip  s    N($   R   R   R3   R
   R}  R~  R(   RM   R^   R  R_   R  R  t   classmethodR  R   t   hookimplR%   R  R  R  R  R  R  R  R  R   R  R  R  R  R  Rn   R  R  R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRC   i  s8   								
				 							c         C` s'   y |  j    SWn | k
 r" t SXd  S(   N(   R   Rn   (   R   t   ignore(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR     s    c   
      C` st  d d l  m } d d d g } g  |  D]! } t |  j d  s& | ^ q& }  |  sh t j j   g }  n  x|  D] } t j j |  } x | j d t  D] } x | D] } | j	 |  } t
 |  r t j j |  }	 d |	 j k r| d k r| r| d	 |  n  | | |	 d f S| d k rHd
 |	 j k rH| | |	 d
 f S| d k rd| | i  f Sq q Wq Wqo Wd S(   sY  
    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).
    i    (   t   SETUP_CFG_PYTESTs
   pytest.inis   tox.inis	   setup.cfgR:  t   reverseR   RL   s   tool:pytestN(   NNN(   t   _pytest.deprecatedR  RQ   R   R   R   RP   R   R%   R   R   t	   iniconfigt	   IniConfigt   sectionsRM   (
   R*   R  R  t   inibasenamesR   R   t   baset   inibasenamet   pR  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   getcfg  s*    
.c         C` s   d  } x |  D] } | j   s% q n  | d  k r: | } q | j |  s | | k r[ q q | j |  rs | } q | j |  } | d  k	 r | } q q W| d  k r t j j   } n | j   r | j   } n  | S(   N(	   RM   R   R   t   commonR   R   RP   R   R   (   t   pathst   common_ancestorR   t   shared(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   get_common_ancestor  s$    		c         ` s]   d    d     d   }    f d   |  D } g  | D] } | j    r; | |  ^ q; S(   Nc         S` s   t  |   j d  S(   NR:  (   RQ   R   (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt	   is_option  s    c         S` s   t  |   j d  d S(   Ns   ::i    (   RQ   RV   (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   get_file_part_from_node_id  s    c         S` s#   |  j    r |  St j j |  j  S(   N(   R6   R   R   RP   R  (   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   get_dir_from_path  s    c         3` s3   |  ]) }  |  s t  j j   |   Vq d  S(   N(   R   R   RP   (   RI  R   (   R  R  (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pys	   <genexpr>  s   (   R   (   R*   R  t   possible_pathsR   (    (   R  R  s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   get_dirs_from_args  s    			

c   	      C` sV  t  |  } |  r[ t j j |   } y | d } Wn t k
 rK d  } n Xt |  } n t |  } t | g d | \ } }  } | d  k rCx | j d t	  D] } | j
 d  j   r Pq q Wt | d | \ } }  } | d  k rCt t j j   | g  } t j j t |   d t j k } | r@| } q@qCn  | |  | pRi  f S(   NR   R  R  s   setup.pyi   (   R  R   R  R  R   RM   R  R  R   R%   R   R   R   RP   R5   t
   splitdriveRQ   R  (	   R  R*   R  t   dirsR  R  R  t   ancestort
   is_fs_root(    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR  *  s*    
%c         C` s   d d  l  } x | j   D] \ } } t | t  r t |  | d   } | d  k r d | } t j |  } | t j	 | <g  | _
 t |  | |  n  |  j
 j |  t | |  q t |  | |  |  j
 j |  t | | |  q Wd  S(   Ni    s	   pytest.%s(   R   R   RO   R   Ru   RM   R   R   R    R   t   __all__R   R>   Rq  (   t   objRr  R   R   R&  R   R   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyRq  D  s    
	c         O` sU   t  j j | |   } |  j j d k r3 t | _ n  |  j j d k rQ t | _ n  | S(   s   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.
    t   yest   no(   R   R   R   R  t   colorR%   t	   hasmarkupRn   (   R   R*   R   R.   (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   create_terminal_writerY  s    c         C` sC   |  j    }  |  d k r d S|  d k r, d St d |  f   d S(   s  Convert 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
    t   yR  R  t   truet   ont   1i   R"  R  t   ft   falset   offt   0i    s   invalid truth value %rN(   R  s   yesR  s   trues   onR  (   R"  s   noR  s   falses   offR  (   t   lowerRT   (   R  (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyR  f  s    	(F   R3   t
   __future__R    R   R   RT  RU   R   R   R?  R   R    R5   t   _pytest._codeRX   t   _pytest.hookspect   _pytest.assertiont   _pytest._pluggyR   R   R   t   _pytest.compatR   R  Rr   R	   R   RM   R0   R1   R)   R4   R9   R:   R<   RV   RD   Ri   R   R   R@   R?   RH   R   RB   R   R   R0  R2  R   RU  R  Ra  RV  R   t   objectRk  Ro  R  R  RC   t   EnvironmentErrorR   R  R  R  R  Rq  R  R  (    (    (    s.   /tmp/pip-build-hU8Cw8/pytest/_pytest/config.pyt   <module>   sn   				
	 	v$2			 i"				