
i\c           @` s{  d  Z  d d l m Z d d l m Z d d l 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 d d l m Z d d l m Z d d	 l m Z d d l Z d d l Z d d l Z d
 d l m Z d
 d l m Z d
 d l m Z d
 d l m Z d d l m  Z  d d l m! Z! d d l m" Z" d d l# m$ Z$ d d l# m% Z% d d l& m' Z' d d l& m( Z( d d l) m* Z* e d  Z+ e d  Z, d e- f d     YZ. e/ e/ d  Z0 d e1 f d     YZ2 d   Z3 d   Z4 d d  d! d" d# f Z5 e5 d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: f Z6 e7 e6  Z8 e8 j9 d;  e/ d<  Z: d=   Z; e/ e/ d>  Z< d? e f d@     YZ= dA   Z> dB   Z? dC e1 f dD     YZ@ e@   ZA dE   ZB dF e1 f dG     YZC dH   ZD dI   ZE dJ   ZF dK   ZG dL   ZH d S(M   s<    command line options, ini-file and conftest.py processing. i    (   t   absolute_import(   t   division(   t   print_functionN(   t   Version(   t   HookimplMarker(   t   HookspecMarker(   t   PluginManageri   (   t	   PrintHelp(   t
   UsageError(   t   determine_setup(   t   exists(   t
   deprecated(   t   ExceptionInfo(   t   filter_traceback(   t	   lru_cache(   t   safe_str(   t   fail(   t   Skipped(   t   PytestConfigWarningt   pytestt   ConftestImportFailurec           B` s   e  Z d    Z RS(   c         C` s)   t  j |  | |  | |  _ | |  _ d  S(   N(   t	   Exceptiont   __init__t   patht   excinfo(   t   selfR   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR   -   s    	(   t   __name__t
   __module__R   (    (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR   ,   s   c         C` s  d d l  m } yy t |  |  } Wn t k
 r } t | j  } t j j t	 j
  } | j d j d |  d t | j j t  | _ | j r | j d d d t  n	 | j   } t |  } x- | j   D] }	 | j |	 j   d t q Wd	 SXz | j j d
 |  SWd | j   XWnY t k
 r} t j j t	 j
  } x- | j D]" }
 | j d j |
  d t qUW| 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.
    i    (   t   EXIT_USAGEERRORs.   ImportError while loading conftest '{e.path}'.t   et   redt   stylet   shortt   chaini   t   configNs
   ERROR: {}
(   t   _pytest.mainR   t   _prepareconfigR   R   R   t   pyt   iot   TerminalWritert   syst   stderrt   linet   formatt   Truet	   tracebackt   filterR   t   getreprt   Falset   exconlyR   t
   splitlinest   rstript   hookt   pytest_cmdline_maint   _ensure_unconfigureR   t   args(   R7   t   pluginsR   R"   R   t   exc_infot   twt   exc_reprt   formatted_tbR*   t   msg(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   main3   s0    ! t   cmdlinec           B` s   e  Z e e  Z RS(    (   R   R   t   staticmethodR>   (    (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR?   \   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    {} must be a filename, given: {}(   t   osR   t   isdirR   R+   (   R   t   optname(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   filename_arg`   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!   {} must be a directory, given: {}(   RA   R   RB   R   R+   (   R   RC   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   directory_argk   s    t   markR>   t   runnert   fixturest
   helpconfigt   pythont   terminalt	   debuggingt   unittestt   capturet   skippingt   tmpdirt   monkeypatcht   recwarnt   pastebint   noset	   assertiont   junitxmlt	   resultlogt   doctestt   cacheprovidert   freeze_supportt	   setuponlyt	   setupplant   stepwiset   warningst   loggingt   reportst   pytesterc         C` sS   t    } t |  } |  d  k	 r1 | j |   n  x t D] } | j |  q8 W| S(   N(   t   PytestPluginManagert   Configt   Nonet   consider_preparset   default_pluginst   import_plugin(   R7   t   pluginmanagerR"   t   spec(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt
   get_config   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.
    (   Rj   Rh   (    (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   get_plugin_manager   s    	c         C` sW  d  } |  d  k r" t j d }  nc t |  t j j  rI t |   g }  n< t |  t t	 f  s d } t
 | j |  t |      n  t |   } | j } y | r x@ | D]5 } t | t j  r | j |  q | j |  q Wn  | rd d l m } | | d | j d d n  | j j d | d	 |   SWn t k
 rR| j     n Xd  S(
   Ni   sP   `args` parameter expected to be a list or tuple of strings, got: {!r} (type: {})i    (   t   _issue_warning_capturedR4   t
   stackleveli   Rh   R7   (   Rd   R(   t   argvt
   isinstanceR%   R   t   localt   strt   tuplet   listt	   TypeErrorR+   t   typeRj   Rh   t   sixt   string_typest   consider_pluginargt   registert   _pytest.warningsRl   R4   t   pytest_cmdline_parset   BaseExceptionR6   (   R7   R8   t   warningR=   R"   Rh   t   pluginRl   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR$      s0    !	
Rb   c           B` s   e  Z d  Z d   Z d   Z d   Z d   Z d d  Z d   Z	 d   Z
 d   Z d	   Z d
   Z e d d  d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e d  Z RS(   s@  
    Overwrites :py:class:`pluggy.PluginManager <pluggy.PluginManager>` to add pytest-specific
    functionality:

    * loading plugins from the command line, ``PYTEST_PLUGINS`` 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  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    |  _! t	 |  _" d  S(   NR   t   PYTEST_DEBUGt   encodingt   utf8(#   t   superRb   R   t   sett   _conftest_pluginst   _dirpath2confmodst   _conftestpath2modRd   t   _confcutdirR0   t   _noconftestt   _duplicatepathst   add_hookspecst   _pytestt   hookspecRy   RA   t   environt   getR(   R)   t   getattrR%   R&   t   dupfileR   t   tracet   roott	   setwritert   writet   enable_tracingRU   t   DummyRewriteHookt   rewrite_hookt   _configured(   R   t   errR   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR      s(    					c         C` s#   t  j t j d d |  j |  S(   s   
        .. deprecated:: 2.8

        Use :py:meth:`pluggy.PluginManager.add_hookspecs <PluginManager.add_hookspecs>`
        instead.
        Rm   i   (   R^   t   warnR   t   PLUGIN_MANAGER_ADDHOOKSR   (   R   t   module_or_class(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   addhooks   s    c         C` s   | j  d  s d  S| d k r# d  St | |  } t t |   j | |  } t j |  s` d  S| d  k r | j  d  r i  } n  | d  k	 r d   t | d g   D } x6 d	 D]+ } | j | t	 | |  p | | k  q Wn  | S(
   Nt   pytest_t   pytest_pluginsc         S` s   h  |  ] } | j   q S(    (   t   name(   t   .0t   m(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pys	   <setcomp>  s   	 t
   pytestmarkt   tryfirstt   trylastt   optionalhookt   hookwrapper(   R   R   R   R   (
   t
   startswithR   R   Rb   t   parse_hookimpl_optst   inspectt	   isroutineRd   t
   setdefaultt   hasattr(   R   R~   R   t   methodt   optst   known_marks(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR     s    	,c         C` s   t  t |   j | |  } | d  k r t | |  } | j d  r d   t | d g   D } i t | d  p| d | k d 6t | d  p d | k d 6} q n  | S(   NR   c         S` s   h  |  ] } | j   q S(    (   R   (   R   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pys	   <setcomp>-  s   	 R   t   firstresultt   historic(   R   Rb   t   parse_hookspec_optsRd   R   R   R   (   R   R   R   R   R   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR   #  s    c         C` s   | d	 k r8 t  j t d j | j d d     d  St t |   j | |  } | r |  j j	 j
 d t d | d |    t | t j  r |  j |  q n  | S(
   Nt   pytest_catchlogt   pytest_capturelogsQ   {} plugin has been merged into the core, please remove it from your requirements.t   _t   -t   kwargsR~   t   manager(   R   R   (   R^   R   R   R+   t   replaceR   Rb   Ry   R4   t   pytest_plugin_registeredt   call_historict   dictRo   t   typest
   ModuleTypet   consider_module(   R   R~   R   t   ret(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyRy   6  s    c         C` s   |  j  |  S(   N(   t
   get_plugin(   R   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt	   getpluginK  s    c         C` s   t  |  j |   S(   s<   Return True if the plugin with the given name is registered.(   t   boolR   (   R   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt	   haspluginO  s    c         C` s-   | j  d d  | j  d d  t |  _ 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_lineR,   R   (   R   R"   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   pytest_configureS  s    c         C` s   t  j j   } | j r0 | j | j d t n d |  _ | j |  _	 | j
 |  _ | j } t } xy | D]q } t |  } | j d  } | d k r | |  } n  | j | d d } t |  rg |  j |  t } qg qg 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
   confcutdirt   joinR,   Rd   R   t
   noconftestR   t   pyargst   _using_pyargst   file_or_dirR0   Rq   t   findR
   t   _try_load_conftest(   R   t	   namespacet   currentt	   testpathst   foundanchorR   t   it   anchor(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   _set_initial_conftestse  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(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR     s
    t   maxsizei   c         C` s   |  j  r g  S| j   r( | j   } n | } t j r] y |  j | SWq] t k
 rY q] Xn  g  } x{ | j   j   D]g } |  j	 r |  j	 j
 |  r qv n  | j d  } | j   rv |  j | j    } | j |  qv qv W| |  j | <| S(   Ns   conftest.py(   R   t   isfilet   dirpathRv   t   PY2R   t   KeyErrort   realpatht   partsR   t   reltoR   t   _importconftestt   append(   R   R   t	   directoryt   clistt   parentt   conftestpatht   mod(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR     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   reversedR   t   AttributeErrorR   (   R   R   R   t   modulesR   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   _rget_with_confmod  s    c         C` s  y |  j  | SWnt k
 r| j   } | d  k rG t | j  n  yd | j   } t | d  r |  j r |  j	 r d d l
 m } t | j | |  j  d t n  Wn& t k
 r t | t j     n X|  j j |  | |  j  | <| j   } | |  j k rrxc |  j j   D]O \ } } | r=| j |  sI| | k r| | k s[t  | j |  qqWn  |  j d |  |  j |  | SXd  S(   NR   i    (   t*   PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTESTt   pytraces   loaded conftestmodule %r(   R   R   t	   pypkgpathRd   t   _ensure_removed_sysmodulet   purebasenamet   pyimportR   R   R   t   _pytest.deprecatedR   R   R+   R   R0   R   R   R(   R9   R   t   addR   R   t   itemsR   t   AssertionErrorR   R   t   consider_conftest(   R   R   t   pkgpathR   R   R   R   t   mods(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR     s:    	
!c         C` s   d } t  |  } x | | k  r | | } | d 7} t | t j  r | d k r y | | } Wn t k
 ru d  SX| d 7} n | j d  r | d } n q |  j |  q q Wd  S(   Ni    i   s   -pi   (   t   lenRo   Rv   Rw   t
   IndexErrorR   Rx   (   R   R7   R   t   nt   optt   parg(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyRe     s     

c         C` s  | j  d  r | d } | t k r8 t d |   n  | d k ra |  j d  |  j d  n  |  j |  | j  d  s|  j d |  qn | } |  j j | d  d  k r |  j | =n  | j  d  s|  j j d | d  d  k r|  j d | =qn  |  j | d	 t d  S(
   Ns   no:i   s   plugin %s cannot be disabledRY   R]   t   pytest_stepwiseR   it   consider_entry_points(	   R   t   essential_pluginsR   t   set_blockedt   _name2pluginR   Rd   Rg   R,   (   R   t   argR   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyRx     s"    
c         C` s   |  j  | d | j d  S(   NR   (   Ry   t   __file__(   R   t   conftestmodule(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR     s    c         C` s   |  j  t j j d   d  S(   Nt   PYTEST_PLUGINS(   t   _import_plugin_specsRA   R   R   (   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   consider_env  s    c         C` s   |  j  t | d g    d  S(   NR   (   R  R   (   R   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR     s    c         C` s.   t  |  } x | D] } |  j |  q Wd  S(   N(   t   _get_plugin_specs_as_listRg   (   R   Ri   R8   t   import_spec(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR    s    c         C` s  t  | t j  s" t d |   t |  } |  j |  sR |  j |  d k	 rV d S| t k rl d | n | } |  j	 j
 |  | r |  j d d | } | r d Sn  y t |  Wn t k
 r} d | t | j d  f } t |  } t j   d } t j t | |  ni t k
 rd} d d	 l m }	 |	 t d
 | | j f  |  j d d n Xt j | }
 |  j |
 |  d S(   s   
        Imports a plugin with ``modname``. If ``consider_entry_points`` is True, entry point
        names are also considered to find a plugin.
        s$   module name as text required, got %rNs   _pytest.t   pytest11R   s   Error importing plugin "%s": %si    i   (   Rl   s   skipped plugin %r: %sRm   i   (   Ro   Rv   Rw   R   Rq   t
   is_blockedR   Rd   t   builtin_pluginsR   t   mark_rewritet   load_setuptools_entrypointst
   __import__t   ImportErrorR   R7   R(   R9   t   reraiseR   Rz   Rl   R   R=   R4   R   Ry   (   R   t   modnameR  t
   importspect   loadedR   t   new_exc_messaget   new_exct   tbRl   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyRg     s8    	$	N(   R   R   t   __doc__R   R   R   R   Rd   Ry   R   R   R   R   R   R   R   R   R   Re   Rx   R   R  R   R  R0   Rg   (    (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyRb      s*   		
							!			,						c         C` s   |  d k	 r t |  t j  r t |  t j  rO |  rF |  j d  n g  }  n  t |  t t f  sw 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(
   Rd   Ro   R   R   Rv   Rw   t   splitRs   Rr   R   (   t   specs(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR  M  s    
c         C` s&   y t  j |  =Wn t k
 r! n Xd  S(   N(   R(   R   R   (   R  (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR   a  s    t   Notsetc           B` s   e  Z d    Z RS(   c         C` s   d S(   Ns   <NOTSET>(    (   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   __repr__i  s    (   R   R   R#  (    (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR"  h  s   c         c` s   x |  D] } d | k o% | j  d  } | j d  d k oI | j  d  } | rr t j j |  \ } } | Vq | r t j j |  } | Vq q Wd  S(   Nt   /s   .pyi   s   __init__.py(   t   endswitht   countRA   R   t   splitextt   dirname(   t   package_filest   fnt   is_simple_modulet
   is_packaget   module_nameR   t   package_name(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   _iter_rewritable_modulesp  s    $Rc   c           B` s"  e  Z d  Z d   Z d   Z d   Z 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  j   |  _ d d l m } m } | } | d d | | f d |  j  |  _ | |  _ |  j j	 j
 j d  |  _	 |  j j |  _ i  |  _ d
 |  _ i  |  _ g  |  _ |  j j |  d  t |  _ t j j   |  _ |  j j j d t d	 |  j   d  S(   Ni   (   t   Parsert   FILE_OR_DIRt   usages#   %%(prog)s [options] [%s] [%s] [...]t
   processoptR"   t   pytestconfigR   t   parser(    (   t   argparset	   Namespacet   optiont
   argparsingR0  R1  t   _processoptt   _parserRh   R   R   R   R4   t	   _inicachet   _override_init	   _opt2destt   _cleanupRy   R0   R   R%   R   Rp   t   invocation_dirt   pytest_addoptionR   R   (   R   Rh   R0  R1  t   _a(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR     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(   R?  R   (   R   t   func(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   add_cleanup  s    c         C` s<   |  j  s t  t |  _  |  j j j d t d |    d  S(   NR   R"   (   R   R   R,   R4   R   R   R   (   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.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"   (   R   R0   R4   t   pytest_unconfigureR   t   _call_historyR?  t   pop(   R   t   fin(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR6     s    		c         C` s   |  j  j d  j S(   Nt   terminalreporter(   Rh   R   t   _tw(   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   get_terminal_writer  s    c         C` s   y |  j  |  Wn t k
 r t |  j d t  sB d | k r_ d d l m } | |   nS t |  j d t  s d | k s d | k r |  j j   j	   t
 j j d  n    n X|  S(	   Nt   versions	   --versioni    (   t   showversiont   helps   --helps   -hs8   
NOTE: displaying only minimal help due to UsageError.

(   t   parseR   R   R8  R0   t   _pytest.helpconfigRN  R;  t
   _getparsert
   print_helpR(   t   stdoutR   (   R   Rh   R7   RN  (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR{     s    !-	
c         C` s   | r! t  | d t  r! d } n d } | j d t d t  | d t  d |  } |  j j d | d |  } t |  s xA t |  j d	  D]' } t	 j
 j d
 |  t	 j
 j   q Wn  d  S(   Nt	   fulltracet   longt   nativet   funcargst
   showlocalsR   t   excreprR   s   
s   INTERNALERROR> %s
(   R   R0   R/   R,   R4   t   pytest_internalerrort   anyRq   R   R(   R)   R   t   flush(   R   R   R8  R   RZ  t   resR*   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   notify_exception  s    		!c         C` s=   |  j  |  j k r9 |  j j |  } |  j  j |  } n  | S(   N(   R@  t   rootdirR   t   bestrelpath(   R   t   nodeidt   fullpath(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   cwd_relative_nodeid  s    c         C` s]   t  |  } | j j j |  | j | d t x$ | j j D] } | j j |  q? W| S(   s'    constructor useable for subprocesses. t   addopts(	   Rj   R8  t   __dict__t   updateRP  R0   R8   Rh   Rx   (   t   clst   option_dictR7   R"   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.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(   Nt   default(   t   _short_optst
   _long_optst   destR>  R   R8  t   setattrRk  (   R   R  R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR:    s
    R   c         C` s   |  j  j | j  d  S(   N(   Rh   R   t   known_args_namespace(   R   t   early_config(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   pytest_load_initial_conftests  s    c         C` s   |  j  j | d t j |  j  \ } } t | j | j | d | j pL d  d |  } | \ |  _ |  _	 |  _
 |  j |  j  j d <|  j	 |  j  j d <|  j  j d d d  |  j  j d	 d
  | j p d |  _ d  S(   NR   t   rootdir_cmd_argR"   R`  t   inifileRe  s   extra command line optionsR7   t
   minversions!   minimally required pytest version(    (   R;  t   parse_known_and_unknown_argst   copyR8  R	   t   inifilenameR   R`  Rd   Rt  t   inicfgt
   extra_infot   addinit   override_iniR=  (   R   R7   t   nst   unknown_argst   r(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   _initini  s    	!	c         C` s   |  j  j |  \ } } t | d d  } | d k rv y t j j |   } Wn t k
 re d } qv X|  j |  n  t |  d S(   s   Install the PEP 302 import hook if using assertion rewriting.

        Needs to parse the --assert=<mode> option from the commandline
        and find all the installed plugins to mark them for rewriting
        by the importhook.
        t
   assertmodet   plaint   rewriteN(	   R;  Rv  R   R   RU   t   install_importhookt   SystemErrort   _mark_plugins_for_rewritet   _warn_about_missing_assertion(   R   R7   R}  R~  t   modeR4   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   _consider_importhook  s    
c         C` s`   | |  j  _ t j j d  r" d Sd   t j   D } x! t |  D] } | j |  qE Wd S(   s   
        Given an importhook, mark for rewrite any top-level
        modules or packages in the distribution package for
        all pytest plugins.
        t   PYTEST_DISABLE_PLUGIN_AUTOLOADNc         s` sD   |  ]: } t  d    | j D  r | j D] } t |  Vq) q d S(   c         s` s   |  ] } | j  d  k Vq d S(   R  N(   t   group(   R   t   ep(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pys	   <genexpr>"  s    N(   R\  t   entry_pointst   filesRq   (   R   t   distt   file(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pys	   <genexpr>   s   (	   Rh   R   RA   R   R   t   importlib_metadatat   distributionsR/  R  (   R   R4   R)  R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR    s    c         C` sC   | |  j  _ z& |  j  j | d t j |  j  Wd |  j  ` X| S(   s   Validate known args.R   N(   R;  t   _config_source_hintRv  Rw  R8  (   R   R7   t   via(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   _validate_args)  s    	
c         C` s  | rM t  j j d d  } t |  rM |  j t j |  d  | | (qM n  |  j |  | r |  j |  j d  d  | | (n  |  j	   |  j
 |  |  j j |  t  j j d  s |  j j d  n  |  j j   |  j j | d t j |  j  |  _ } |  j j d  k rI|  j rIt j j |  j  j } | |  j _ n  y& |  j j d	 |  d
 | d |  j  Wnq t k
 rt j   d } | j  s| j! rd d l" m# } | t$ d j% | j   |  j d d q  n Xd  S(   Nt   PYTEST_ADDOPTSt    s   via PYTEST_ADDOPTSRe  s   via addopts configR  R  R   Rq  R7   R5  i   i    (   Rl   s$   could not load initial conftests: {}Rm   i   (&   RA   R   R   R   R  t   shlexR   R  t   getinit   _checkversionR  Rh   Re   R  R  R;  t   parse_known_argsRw  R8  Rp  R   Rd   Rt  R%   R   Rp   R(  R4   Rr  R   R(   R9   RO  RM  Rz   Rl   R   R+   (   R   R7   Re  t   env_addoptsR}  R   R   Rl   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt	   _preparse5  s@    #
	"	
c         C` s   d d  l  } |  j j d d   } | r t |  t | j  k r | j d |  j j j |  j j	 d  | | j f   q n  d  S(   Ni    Ru  s,   %s:%d: requires pytest-%s, actual pytest-%s'(
   R   Ry  R   Rd   R   t   __version__R   R"   R   t   lineof(   R   R   t   minver(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR  f  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 |  j |  j k r |  j d  } n  | s t |  j  g } q n  | |  _ Wn t k
 rn Xd  S(	   NR7   s:   can only parse cmdline args at most once per Config objectR   Rh   Re  R"   R   R   (   R   R   t	   _origargsR4   t   pytest_addhooksR   R   Rh   R  t   pytest_cmdline_preparseR,   R;  t   after_preparset   parse_setoptionR8  R@  R`  R  Rq   R7   R   (   R   R7   Re  (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyRP  v  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   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR     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(   R<  R   t   _getini(   R   R   t   val(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR    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  t   pathlistR   R7   t   linelistc         S` s
   |  j    S(   N(   t   strip(   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   <lambda>  R  s   
R   (   R;  t   _inidictR   t
   ValueErrort   _get_override_ini_valueRd   Ry  R%   R   Rp   R"   R   R  R   R   R   R,   t   mapR   t
   _strtoboolR  R   (
   R   R   t   descriptionRu   Rk  t   valuet   dpt   valuest   relpatht   t(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR    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(   NR$  R   (   Rh   R   R   Rd   R%   R   Rp   R	  R   Ro   R   t   sepR   R,   R   (   R   R   R   R   t   relrootst   modpathR  t   relroot(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   _getconftest_pathlist  s    c         C` so   d  } xb |  j D]W } y | j d d  \ } } Wn t k
 rQ t d   q X| | k r | } q q W| S(   Nt   =i   s-   -o/--override-ini expects option=value style.(   Rd   R=  R   R  R   (   R   R   R  t
   ini_configt   keyt   user_ini_value(    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.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(
   R>  R   R   R8  Rd   R   t   notsetR   t   skipR  (   R   R   Rk  R  R  R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt	   getoption  s    	c         C` s   |  j  |  S(   s    (deprecated, use getoption()) (   R  (   R   R   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   getvalue  s    c         C` s   |  j  | d t S(   s(    (deprecated, use getoption(skip=True)) R  (   R  R,   (   R   R   R   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   getvalueorskip  s    N(#   R   R   R  R   RD  RE  R6   RL  R{   Rd   R_  Rd  t   classmethodRj  R:  t   hookimplR,   Rr  R  R  R  R  R  R  RP  R   R  R  R  R  R  R0   R  R  R  (    (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyRc   |  s6   								
					1						c           C` s-   y t  s t  Wn t k
 r$ t SXt  Sd  S(   N(   R0   R   R,   (    (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   _assertion_supported   s
    c         C` s?   t    s; |  d k r( t j j d  q; t j j d  n  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?)
(   R  R(   R)   R   (   R  (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.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   R   Rd   R   R   R(   R   t   __all__Ro  R   t   setns(   t   objt   dicR   R   R  R   R  (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR    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'   R8  t   colorR,   t	   hasmarkupR0   (   R"   R7   R   R:   (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   create_terminal_writer1  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  R  R  R  R  R  (   R   R  R  R  R  R  (   t   lowerR  (   R  (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyR  >  s    	(I   R  t
   __future__R    R   R   R6  Rw  R   RA   R  R(   R   R^   R  R%   Rv   t   packaging.versionR   t   pluggyR   R   R   t   _pytest._codeR   t   _pytest.assertiont   _pytest.hookspect
   exceptionsR   R   t	   findpathsR	   R
   R   R   R   t   _pytest.compatR   R   t   _pytest.outcomesR   R   t   _pytest.warning_typesR   R  R   R   R   Rd   R>   t   objectR?   RD   RE   R  Rf   R   R  R   Rj   Rk   R$   Rb   R  R   R"  R  R/  Rc   R  R  R  R  R  (    (    (    s6   lib/python2.7/site-packages/_pytest/config/__init__.pyt   <module>   s   )			
	 x				 					