ó
…¾^Yc           @` sÝ   d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l m Z d d l	 Z	 d d l
 Z
 d d l m Z d e f d „  ƒ  YZ d „  Z e j d	 e ƒ d
 „  ƒ Z d „  Z d „  Z d g Z d „  Z d „  Z d S(   s6    version info, help messages, tracing configuration.  i    (   t   absolute_importt   divisiont   print_functionN(   t	   PrintHelp(   t   Actiont
   HelpActionc           B` s,   e  Z d  Z d e d d „ Z d d „ Z RS(   s„  This is an argparse Action that will raise an exception in
    order to skip the rest of the argument parsing when --help is passed.
    This prevents argparse from quitting due to missing required arguments
    when any are defined, for example by ``pytest_addoption``.
    This is similar to the way that the builtin argparse --help option is
    implemented by raising SystemExit.
    c         C` s;   t  t |  ƒ j d | d | d t d | d d d | ƒ d  S(   Nt   option_stringst   destt   constt   defaultt   nargsi    t   help(   t   superR   t   __init__t   True(   t   selfR   R   R	   R   (    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyR      s    c         C` s8   t  | |  j |  j ƒ t | j d t ƒ r4 t ‚ n  d  S(   Nt   after_preparse(   t   setattrR   R   t   getattrt   _parsert   FalseR   (   R   t   parsert	   namespacet   valuest   option_string(    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyt   __call__!   s    N(   t   __name__t
   __module__t   __doc__t   NoneR   R   R   (    (    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyR      s
   	c         C` së   |  j  d ƒ } | j d d d d d ƒ| j d d d t d	 d d d
 ƒ| j d d d d	 d d g  d d d d ƒ| j d d d d d t d d ƒf | j d d d d	 d d t d d ƒ| j d d d d d	 d d d d d ƒd  S(   Nt   debugconfigs	   --versiont   actiont
   store_trueR   s2   display pytest lib version and import information.s   -hs   --helpR   s(   show help message and configuration infos   -pt   appendt   pluginsR	   t   metavart   namesn   early-load given plugin (multi-allowed). To avoid loading of plugins, use the `no:` prefix, e.g. `no:doctest`.s   --traceconfigs   --trace-configs*   trace considerations of conftest.py files.s   --debugt   debugs>   store internal tracing debug information in 'pytestdebug.log'.s   -os   --override-iniR
   t   *t   override_inisL   override config option with option=value style, e.g. `-o xfail_strict=True`.(   t   getgroupt	   addoptiont
   _addoptionR   R   (   R   t   group(    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyt   pytest_addoption)   s$    
t   hookwrapperc          #` sæ   d  V}  |  j  ƒ  ‰  ˆ  j j râ t j j d ƒ } t | d ƒ ‰ ˆ j d t j	 t
 j	 d j t t t j ƒ ƒ t j ƒ  ˆ  j f ƒ ˆ  j j j ˆ j ƒ ˆ  j j ƒ  ‰ t j j d | ƒ ‡  ‡ ‡ f d †  } ˆ  j | ƒ n  d  S(   Ns   pytestdebug.logt   ws5   versions pytest-%s, py-%s, python-%s
cwd=%s
args=%s

t   .s&   writing pytestdebug information to %s
c           ` s?   ˆ j  ƒ  t j j d ˆ j ƒ ˆ  j j j d  ƒ ˆ ƒ  d  S(   Ns$   wrote pytestdebug information to %s
(	   t   closet   syst   stderrt   writeR$   t   tracet   roott	   setwriterR   (    (   t   configt	   debugfilet   undo_tracing(    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyt   unset_tracingP   s
    
(   t
   get_resultt   optionR%   t   ost   patht   abspatht   openR3   t   pytestt   __version__t   pyt   joint   mapt   strR1   t   version_infot   getcwdt	   _origargsR4   R5   R6   t   pluginmanagert   enable_tracingR2   t   add_cleanup(   t   outcomeR>   R:   (    (   R7   R8   R9   s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyt   pytest_cmdline_parse@   s    	c         C` s®   |  j  j r| t j j t j ƒ } t j j	 d t j
 | f ƒ t |  ƒ } | rx x% | D] } t j j	 | d ƒ qW Wn  d S|  j  j rª |  j ƒ  t |  ƒ |  j ƒ  d Sd  S(   Ns,   This is pytest version %s, imported from %s
s   
i    (   R<   t   versionRC   R>   t   localRA   t   __file__R1   R2   R3   RB   t   getpluginversioninfoR   t   _do_configuret   showhelpt   _ensure_unconfigure(   R7   t   pt
   plugininfot   line(    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyt   pytest_cmdline_mainY   s    


c         C` s¥  |  j  j d ƒ } | j } | j |  j j j ƒ  ƒ | j ƒ  | j ƒ  | j d ƒ | j ƒ  xv |  j j D]h } |  j j	 | \ } } } | d  k r  d } n  d | | f } d | | f } | j | | j  ƒ ql W| j ƒ  | j d ƒ d d d g }	 x+ |	 D]# \ } } | j d | | f ƒ qW| j ƒ  | j ƒ  | j d ƒ | j d ƒ | j d ƒ x7 | j j d g  ƒ D]  }
 | j d |
 j d t ƒq}Wd  S(   Nt   terminalreportersJ   [pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:t   strings   %s (%s)s
     %-24s %ss   environment variables:t   PYTEST_ADDOPTSs   extra command line optionst   PYTEST_PLUGINSs.   comma-separated plugins to load during startupt   PYTEST_DEBUGs1   set to enable debug tracing of pytest's internalss/   to see available markers type: pytest --markerss1   to see available fixtures type: pytest --fixturessJ   (shown according to specified file_or_dir or current dir if not specified)t   warningss
   warning : t   red(   R\   s   extra command line options(   R]   s.   comma-separated plugins to load during startup(   R^   s1   set to enable debug tracing of pytest's internals(   RJ   t
   get_plugint   _twR3   R   t	   optparsert   format_helpRX   t	   _ininamest   _inidictR   t	   fullwidtht   statst   gett   messageR   (   R7   t   reportert   twR$   R   t   typeR	   t   specRX   t   varst   warningreport(    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyRT   i   s:    	


	
	

t   pytest_pluginss   list of plugin names to loadc         C` sˆ   g  } |  j  j ƒ  } | r„ | j d ƒ xY | D]N \ } } t | d t | ƒ ƒ } d | j | j | f } | j d | ƒ q/ Wn  | S(   Ns   setuptools registered plugins:RQ   s   %s-%s at %ss     (   RJ   t   list_plugin_distinfoR!   R   t   reprt   project_nameRO   (   R7   t   linesRW   t   plugint   distt   loct   content(    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyRR   •   s    c         C` sä   g  } |  j  j s |  j  j r` | j d t j t j f ƒ t |  ƒ } | r` | j | ƒ q` n  |  j  j rà | j d ƒ |  j	 j
 ƒ  } xU | D]J \ } } t | d ƒ r¶ | j } n t | ƒ } | j d | | f ƒ q Wn  | S(   Ns   using: pytest-%s pylib-%ss   active plugins:RQ   s       %-20s: %s(   R<   R%   t   traceconfigR!   RA   RB   RC   RR   t   extendRJ   t   list_name_plugint   hasattrRQ   Rs   (   R7   Ru   t   verinfot   itemsR$   Rv   t   r(    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyt   pytest_report_header    s     	(   Rq   s   list of plugin names to load(   R   t
   __future__R    R   R   RC   RA   t   _pytest.configR   R=   R1   t   argparseR   R   R,   t   hookimplR   RN   RY   RT   t   conftest_optionsRR   R   (    (    (    s2   /tmp/pip-build-hU8Cw8/pytest/_pytest/helpconfig.pyt   <module>   s   			)		