
i\c           @` sV  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 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' d g Z( d   Z) d   Z* d   Z+ d e, f d     YZ- e j. d    Z/ d e, f d     YZ0 d   Z1 d e, f d     YZ2 d  e, f d!     YZ3 e j. d"    Z4 e j. d# d$  d%    Z5 e j. d&    Z6 e j. d'    Z7 e j. d(    Z8 e	 j9 d)  Z: d* e, f d+     YZ; d, e, f d-     YZ< d. e, f d/     YZ= d0 e, f d1     YZ> d2 e, f d3     YZ? d4   Z@ d5 e, f d6     YZA d$ e, f d7     YZB d S(8   sD   (disabled by default) support for testing pytest and pytest plugins.i    (   t   absolute_import(   t   division(   t   print_functionN(   t   fnmatch(   t   WeakKeyDictionary(   t   Source(   t   saferepr(   t   AssertionRewritingHook(   t   MultiCapture(   t
   SysCapture(   t   safe_str(   t   Sequence(   t   EXIT_INTERRUPTED(   t   EXIT_OK(   t   Session(   t   MonkeyPatch(   t   Pathu   /var/lib/sss/mc/passwdc      
   C` sa   |  j  d d d d d d t d d |  j  d	 d d
 d d d d d d |  j d d d d  S(   Ns   --lsoft   actiont
   store_truet   destt   lsoft   defaultt   helps"   run FD checks if lsof is availables   --runpytestt	   inprocesst	   runpytestt   choicest
   subprocesssY   run pytest sub runs in tests using an 'inprocess' or 'subprocess' (python -m main) methodt   pytester_example_dirs1   directory to take the pytester example files from(   R   R   (   t	   addoptiont   Falset   addini(   t   parser(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   pytest_addoption)   s    c         C` sN   |  j  d  r: t   } | j   r: |  j j |  q: n  |  j d d  d  S(   NR   t   markerssl   pytester_example_path(*path_segments): join the given path segments to `pytester_example_dir` for this test.(   t   getvaluet   LsofFdLeakCheckert   matching_platformt   pluginmanagert   registert   addinivalue_line(   t   configt   checker(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   pytest_configureB   s    	c         C` s7   t  } |  r3 t d j d j t |       n  d  S(   Ns    Unexpected keyword arguments: {}s   , (   t   Truet	   TypeErrort   formatt   joint   sorted(   t   kwargst   __tracebackhide__(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   raise_on_kwargsO   s    R#   c           B` sM   e  Z d    Z d   Z d   Z d   Z e j d e d e  d    Z	 RS(   c         C` s   |  j    } |  j |  } | S(   N(   t
   _exec_lsoft   _parse_lsof_output(   t   selft   outt
   open_files(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   get_open_filesX   s    c      
   C` sV   t  j   } t t  j d  2 } t j d d d t |  f d | j   SWd  QXd  S(   Nt   wbR   s   -Ffn0s   -pt   stderr(   t   ost   getpidt   opent   devnullR   t   check_outputt   strt   decode(   R5   t   pidR>   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR3   ]   s    c         C` s   d   } g  } x | j  d  D]w } | |  r | j  d  } | d d } | d d } | t k rn q n  | j d  r | j | | f  q q q W| S(   Nc         S` s=   |  j  d  o< d |  k o< d |  k o< d |  k o< d |  k S(   Nt   ft   deletedt   memt   txtt   cwd(   t
   startswith(   t   line(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   isopenf   s
    s   
s    i    i   t   /(   t   splitt
   IGNORE_PAMRH   t   append(   R5   R6   RJ   R7   RI   t   fieldst   fdt   filename(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR4   e   s    	c         C` s7   y t  j d  Wn t t  j f k
 r. t SXt Sd  S(   NR   s   -v(   R   s   -v(   R   R?   t   OSErrort   CalledProcessErrorR   R+   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR$   |   s
    t   hookwrappert   tryfirstc   	      c` s  |  j    } d  Vt t d  r- t j   n  |  j    } d   | D d   | D } g  | D] } | d | k r^ | ^ q^ } | rg  } | j d t |   | j g  | D] } t |  ^ q  | j d  | j g  | D] } t |  ^ q  | j d  | j g  | D] } t |  ^ q | j | d  | j d | j	  | j d  | j
 t j d	 j |    n  d  S(
   Nt   pypy_version_infoc         S` s   h  |  ] } | d   q S(   i    (    (   t   .0t   t(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pys	   <setcomp>   s   	 i    s   ***** %s FD leakage detecteds   *** Before:s
   *** After:s   *** function %s:%s: %s s   See issue #2366s   
(   R8   t   hasattrt   syst   gct   collectRN   t   lent   extendR@   t   locationt   warnt   pytestt   PytestWarningR.   (	   R5   t   itemt   lines1t   lines2t   new_fdsRX   t   leaked_filest   errorRC   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   pytest_runtest_protocol   s&    )&&&(
   t   __name__t
   __module__R8   R3   R4   R$   Ra   t   hookimplR+   Ri   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR#   W   s
   				c         C` s
   t  |   S(   s   Return a helper which offers a gethookrecorder(hook) method which
    returns a HookRecorder instance which helps to make assertions about called
    hooks.

    (   t	   PytestArg(   t   request(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   _pytest   s    Rm   c           B` s   e  Z d    Z d   Z RS(   c         C` s   | |  _  d  S(   N(   Rn   (   R5   Rn   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   __init__   s    c         C` s&   t  | j  } |  j j | j  | S(   N(   t   HookRecordert   _pmRn   t   addfinalizert   finish_recording(   R5   t   hookt   hookrecorder(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   gethookrecorder   s    (   Rj   Rk   Rp   Rw   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRm      s   	c         C` s'   g  |  D] } | d d k r | ^ q S(   sD   Only return names from iterator values without a leading underscore.i    t   _(    (   t   valuest   x(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   get_public_names   s    t
   ParsedCallc           B` s   e  Z d    Z d   Z RS(   c         C` s   |  j  j |  | |  _ d  S(   N(   t   __dict__t   updatet   _name(   R5   t   nameR0   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRp      s    c         C` s'   |  j  j   } | d =d |  j | f S(   NR   s   <ParsedCall %r(**%r)>(   R}   t   copyR   (   R5   t   d(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   __repr__   s    (   Rj   Rk   Rp   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR|      s   	Rq   c           B` s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z	 d	 d d d
  Z d d  Z d   Z d   Z d   Z d d d d  Z d   Z RS(   s   Record all hooks called in a plugin manager.

    This wraps all the hook calls in the plugin manager, recording each call
    before propagating the normal calls.

    c         ` sC   |   _  g    _   f d   } d   } | j | |    _ d  S(   Nc         ` s     j  j t |  |   d  S(   N(   t   callsRN   R|   (   t	   hook_namet
   hook_implsR0   (   R5   (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   before   s    c         S` s   d  S(   N(    (   t   outcomeR   R   R0   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   after   s    (   t   _pluginmanagerR   t   add_hookcall_monitoringt   _undo_wrapping(   R5   R%   R   R   (    (   R5   s/   lib/python2.7/site-packages/_pytest/pytester.pyRp      s
    			c         C` s   |  j    d  S(   N(   R   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRt      s    c         C` sG   t  | t  r | j   } n  g  |  j D] } | j | k r( | ^ q( S(   N(   t
   isinstanceR@   RL   R   R   (   R5   t   namest   call(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   getcalls   s    c   	      C` s  t  } d } t |  } t j d  j } x | r| j d  \ } } x t |  j |  D] \ } } | j | k r t	 d | |  t
 | | | j  r t	 d t |  d |  n t	 d t |  d |  q\ | | d 7} Pn  t	 d | d	 |  q\ Wt j d
 | | f  q- Wd  S(   Ni    i   t	   NAMEMATCHt   CHECKERMATCHs   ->t   NOCHECKERMATCHt   -t   NONAMEMATCHt   withs   could not find %r check %r(   R+   t   listRZ   t	   _getframet   f_localst   popt	   enumerateR   R   t   printt   evalR}   t   reprRa   t   fail(	   R5   t   entriesR1   t   it
   backlocalsR   t   checkt   indR   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   assert_contains   s"    	 c         C` s   t  } x: t |  j  D]) \ } } | j | k r |  j | =| Sq Wd | f g } | j g  |  j D] } d | ^ qc  t j d j |   d  S(   Ns   could not find call %r, in:s     %ss   
(   R+   R   R   R   R^   Ra   R   R.   (   R5   R   R1   R   R   t   linesRz   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   popcall   s    
'c         C` s;   |  j  |  } t |  d k s3 t | | f   | d S(   Ni   i    (   R   R]   t   AssertionError(   R5   R   Ry   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   getcall   s    $s-   pytest_runtest_logreport pytest_collectreportc         C` s#   g  |  j  |  D] } | j ^ q S(   N(   R   t   report(   R5   R   Rz   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt
   getreports  s    t    c         C` s   g  } x |  j  d |  D]u } | rD | j d k rD | j rD q n  | r_ | j | k r_ q n  | s~ | | j j d  k r | j |  q q W| s t d | f   n  t |  d k r t d | | f   n  | d S(   s4   return a testreport whose dotted import path matchesR   R   s   ::s?   could not find test report matching %r: no test reports at all!i   s+   found 2 or more testreports matching %r: %si    (   R   t   whent   passedt   nodeidRL   RN   t
   ValueErrorR]   (   R5   t	   inamepartR   R   Ry   t   rep(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   matchreport  s     c         C` s)   g  |  j  |  D] } | j r | ^ q S(   N(   R   t   failed(   R5   R   R   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   getfailures#  s    c         C` s   |  j  d  S(   Nt   pytest_collectreport(   R   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   getfailedcollections&  s    c         C` s   g  } g  } g  } x |  j  d  D]u } | j rS | j d k r | j |  q q" | j rl | j |  q" | j s t d j |    | j |  q" W| | | f S(   Ns-   pytest_collectreport pytest_runtest_logreportR   s   Unexpected outcome: {!r}(   R   R   R   RN   t   skippedR   R   R-   (   R5   R   R   R   R   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   listoutcomes)  s    		c         C` s#   g  |  j    D] } t |  ^ q S(   N(   R   R]   (   R5   Rz   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   countoutcomes8  s    i    c         C` sa   |  j    \ } } } | t |  k s- t  | t |  k sE t  | t |  k s] t  d  S(   N(   R   R]   R   (   R5   R   R   R   t
   realpassedt   realskippedt
   realfailed(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   assertoutcome;  s    c         C` s   g  |  j  (d  S(   N(   R   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   clearA  s    N(   Rj   Rk   t   __doc__Rp   Rt   R   R   R   R   R   t   NoneR   R   R   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRq      s"   					
				c         C` s   t    S(   N(   t   LineComp(   Rn   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   linecompE  s    R   t   LineMatcherc         C` s   t  S(   N(   R   (   Rn   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   LineMatcher_fixtureJ  s    c         C` s   t  |  |  S(   N(   t   Testdir(   Rn   t   tmpdir_factory(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   testdirO  s    c          c` s/   t    }  t   } d  V| j   |  j   d  S(   N(   t   SysPathsSnapshott   SysModulesSnapshott   restore(   t	   snappathst   snapmods(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   _sys_snapshotT  s
    		
c          c` s,   d d l  m }  |    } | V| j   d  S(   Ni    (   t
   get_config(   t   _pytest.configR   t   _ensure_unconfigure(   R   R(   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   _config_for_test]  s    	s   (\d+) ([\w-]+)t	   RunResultc           B` sD   e  Z d  Z d   Z d   Z d   Z d d d d d d d  Z RS(   s  The result of running a command.

    Attributes:

    :ret: the return value
    :outlines: list of lines captured from stdout
    :errlines: list of lines captures from stderr
    :stdout: :py:class:`LineMatcher` of stdout, use ``stdout.str()`` to
       reconstruct stdout or the commonly used ``stdout.fnmatch_lines()``
       method
    :stderr: :py:class:`LineMatcher` of stderr
    :duration: duration in seconds

    c         C` sF   | |  _  | |  _ | |  _ t |  |  _ t |  |  _ | |  _ d  S(   N(   t   rett   outlinest   errlinesR   t   stdoutR:   t   duration(   R5   R   R   R   R   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRp   y  s    			c         C` s2   d |  j  t |  j j  t |  j j  |  j f S(   NsK   <RunResult ret=%r len(stdout.lines)=%d len(stderr.lines)=%d duration=%.2fs>(   R   R]   R   R   R:   R   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s    c         C` s   xl t  |  j  D][ } d | k r t j |  } | rk i  } x$ | D] \ } } t |  | | <qD W| Sq q Wt d   d S(   s|   Return a dictionary of outcomestring->num from parsing the terminal
        output that the test process produced.

        t   secondss    Pytest terminal report not foundN(   t   reversedR   t   rex_outcomet   findallt   intR   (   R5   RI   t   outcomesR   t   numt   cat(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   parseoutcomes  s    i    c   
      C` s   |  j    } i | j d d  d 6| j d d  d 6| j d d  d 6| j d d  d 6| j d d  d 6| j d d  d 6} i | d 6| d 6| d 6| d 6| d 6| d 6}	 | |	 k s t  d S(	   s   Assert that the specified outcomes appear with the respective
        numbers (0 means it didn't occur) in the text output from a test run.

        R   i    R   R   Rh   t   xpassedt   xfailedN(   R   t   getR   (
   R5   R   R   R   Rh   R   R   R   t   obtainedt   expected(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   assert_outcomes  s     
(   Rj   Rk   R   Rp   R   R   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR   i  s
   			t   CwdSnapshotc           B` s   e  Z d    Z d   Z RS(   c         C` s   t  j   |  _ d  S(   N(   R;   t   getcwdt   _CwdSnapshot__saved(   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRp     s    c         C` s   t  j |  j  d  S(   N(   R;   t   chdirR   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s    (   Rj   Rk   Rp   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s   	R   c           B` s   e  Z d d   Z d   Z RS(   c         C` s   | |  _  t t j  |  _ d  S(   N(   t   _SysModulesSnapshot__preservet   dictRZ   t   modulest   _SysModulesSnapshot__saved(   R5   t   preserve(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRp     s    	c         ` sY     j  r5   j j   f d   t j j   D  n  t j j   t j j   j  d  S(   Nc         3` s0   |  ]& \ } }   j  |  r | | f Vq d  S(   N(   R   (   RW   t   kt   m(   R5   (    s/   lib/python2.7/site-packages/_pytest/pytester.pys	   <genexpr>  s    (   R   R   R~   RZ   R   t   itemsR   (   R5   (    (   R5   s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s
    		#N(   Rj   Rk   R   Rp   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s   R   c           B` s   e  Z d    Z d   Z RS(   c         C` s%   t  t j  t  t j  f |  _ d  S(   N(   R   RZ   t   patht	   meta_patht   _SysPathsSnapshot__saved(   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRp     s    c         C` s   |  j  \ t j (t j (d  S(   N(   R   RZ   R   R   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s    (   Rj   Rk   Rp   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s   	R   c           B` s  e  Z d  Z e Z d e f d     YZ d   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 d1 d  Z d   Z d   Z d1 d  Z e 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" d#  Z' d$   Z( d2 e) d%  Z* d&   Z+ e, j- e, j- e d'  Z. d(   Z/ d)   Z0 d*   Z1 d+   Z2 d,   Z3 d-   Z4 d. d/  Z5 d. d0  Z6 RS(3   s  Temporary test directory with tools to test/run pytest itself.

    This is based on the ``tmpdir`` fixture but provides a number of methods
    which aid with testing pytest itself.  Unless :py:meth:`chdir` is used all
    methods will use :py:attr:`tmpdir` as their current working directory.

    Attributes:

    :tmpdir: The :py:class:`py.path.local` instance of the temporary directory.

    :plugins: A list of plugins to use with :py:meth:`parseconfig` and
       :py:meth:`runpytest`.  Initially this is an empty list but plugins can
       be added to the list.  The type of items to add to the list depends on
       the method using them so refer to them for details.

    t   TimeoutExpiredc           B` s   e  Z RS(    (   Rj   Rk   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s   c         C` sf  | |  _  t   |  _ | j j } | j | d t |  _ | j d | d t |  _ g  |  _	 t
   |  _ t   |  _ |  j   |  _ |  j   |  j  j |  j  |  j  j j d  } | d k r |  j |  _ n | d k r |  j |  _ n  t   } |  _ | j d t |  j   | j d d t | j d	 d t t |  j  } i | d
 6| d 6|  _ d  S(   Nt   numbereds   tmp-s   --runpytestR   R   t   PYTEST_DEBUG_TEMPROOTt   TOX_ENV_DIRt   raisingt   PYTEST_ADDOPTSt   HOMEt   USERPROFILE(   Rn   R   t   _mod_collectionst   functionRj   t   mktempR+   t   tmpdirt   test_tmproott   pluginsR   t   _cwd_snapshotR   t   _sys_path_snapshott#   _Testdir__take_sys_modules_snapshott   _sys_modules_snapshotR   Rs   t   finalizeR(   t	   getoptiont   runpytest_inprocesst   _runpytest_methodt   runpytest_subprocessR   t   monkeypatcht   setenvR@   t   delenvR   t   _env_run_update(   R5   Rn   R   R   t   methodt   mpt   tmphome(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRp     s,    		
c         C` s   d |  j  f S(   Ns   <Testdir %r>(   R  (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s    c         C` s   t  |  j  S(   N(   R@   R  (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   __str__  s    c         C` s8   |  j  j   |  j j   |  j j   |  j j   d S(   s  Clean up global state artifacts.

        Some methods modify the global interpreter state and this tries to
        clean this up.  It does not remove the temporary directory however so
        it can be looked at after the test run has finished.

        N(   R  R   R  R  R  t   undo(   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR	  	  s    c         C` s   d   } t  d |  S(   Nc         S` s   |  j  d  S(   Nt   zope(   RH   (   R   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   preserve_module  s    R   (   R   (   R5   R  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   __take_sys_modules_snapshot  s    	c         C` s*   t  |  | _ } |  j j | j  | S(   s:   Create a new :py:class:`HookRecorder` for a PluginManager.(   Rq   t   reprecRn   Rs   Rt   (   R5   R%   R  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   make_hook_recorder  s    c         C` s   |  j  j   d S(   sb   Cd into the temporary directory.

        This is done automatically upon instantiation.

        N(   R  R   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR   %  s    s   utf-8c         ` s  t  | j    }   f d    | rn d j  f d   | D  } |  j j j } | j d | | f  n  d  } x | D] \ } }	 |  j j |  j	 d |  }
 |
 j
   j   t |	  } d j  f d   | j D  } |
 j | j   j    d  | d  k r{ |
 } q{ q{ W| S(   Nc         ` s)   t  |  t  r |  j    St j |   S(   N(   R   t   bytesRA   t   sixt	   text_type(   t   s(   t   encoding(    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   to_text0  s    u   
c         3` s   |  ] }   |  Vq d  S(   N(    (   RW   Rz   (   R!  (    s/   lib/python2.7/site-packages/_pytest/pytester.pys	   <genexpr>4  s    i    t   extc         3` s   |  ] }   |  Vq d  S(   N(    (   RW   RI   (   R!  (    s/   lib/python2.7/site-packages/_pytest/pytester.pys	   <genexpr>=  s    R9   (   R   R   R.   Rn   R   Rj   t   insertR   R  t   newt   dirpatht
   ensure_dirR   R   t   writet   stript   encode(   R5   R"  t   argsR0   R   R   t   sourcet   basenameR   t   valuet   p(    (   R   R!  s/   lib/python2.7/site-packages/_pytest/pytester.pyt	   _makefile-  s     "c         O` s   |  j  | | |  S(   s  Create new file(s) in the testdir.

        :param str ext: The extension the file(s) should use, including the dot, e.g. `.py`.
        :param list[str] args: All args will be treated as strings and joined using newlines.
           The result will be written as contents to the file.  The name of the
           file will be based on the test function requesting this fixture.
        :param kwargs: Each keyword is the name of a file, while the value of it will
           be written as contents of the file.

        Examples:

        .. code-block:: python

            testdir.makefile(".txt", "line1", "line2")

            testdir.makefile(".ini", pytest="[pytest]\naddopts=-rs\n")

        (   R/  (   R5   R"  R*  R0   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   makefileC  s    c         C` s   |  j  d |  S(   s2   Write a contest.py file with 'source' as contents.t   conftest(   t
   makepyfile(   R5   R+  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   makeconftestX  s    c         C` s   |  j  d d | S(   s/   Write a tox.ini file with 'source' as contents.s   .init   tox(   R0  (   R5   R+  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   makeini\  s    c         C` s#   |  j  |  } t j j |  d S(   s7   Return the pytest section from the tox.ini config file.Ra   (   R5  t   pyt	   iniconfigt	   IniConfig(   R5   R+  R.  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt	   getinicfg`  s    c         O` s   |  j  d | |  S(   s.   Shortcut for .makefile() with a .py extension.s   .py(   R/  (   R5   R*  R0   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR2  e  s    c         O` s   |  j  d | |  S(   s/   Shortcut for .makefile() with a .txt extension.s   .txt(   R/  (   R5   R*  R0   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   maketxtfilei  s    c         C` s2   | d k r |  j } n  |  j j t |   d S(   s   Prepend a directory to sys.path, defaults to :py:attr:`tmpdir`.

        This is undone automatically when this object dies at the end of each
        test.
        N(   R   R  R  t   syspath_prependR@   (   R5   R   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   syspathinsertm  s    c         C` s   |  j  j |  S(   s   Create a new (sub)directory.(   R  t   mkdir(   R5   R   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR=  x  s    c         C` s    |  j  |  } | j d  | S(   s   Create a new python package.

        This creates a (sub)directory with an empty ``__init__.py`` file so it
        gets recognised as a python package.

        s   __init__.py(   R=  t   ensure(   R5   R   R.  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   mkpydir|  s    c         C` s  d d  l  } d d l m } | j | d d |  j j j d  } | d  k r_ t d   n  |  j j j	 j
 |  } x> |  j j j d  D]' } | j s t  | j
 | j   } q W| d  k rB|  j j j } | | } | | d } | j   r | }	 qQ| j   r| }	 qQt d	 j | | j |  j j j	     n | j
 |  }	 |	 j   r|	 j
 d
  j   r|	 j |  j  |  j S|	 j   r|  j j
 |	 j  }
 |	 j |
  |
 St d j |	    d  S(   Ni    (   t   PYTESTER_COPY_EXAMPLEt
   stackleveli   R   s2   pytester_example_dir is unset, can't copy examplest   pytester_example_paths   .pys+   {} cant be found as module or package in {}s   __init__.pys0   example "{}" is not found as a file or directory(   t   warningst   _pytest.warning_typesR@  R`   Rn   R(   t   getiniR   R   t   rootdirR.   t   nodet   iter_markersR*  R   R   Rj   t   isdirt   isfilet   LookupErrorR-   t   bestrelpathR   R  R,  (   R5   R   RC  R@  t   example_dirt   extra_elementt	   func_namet	   maybe_dirt
   maybe_filet   example_patht   result(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   copy_example  s>    
		$"c         C` s   t  |  } d t |  k s$ t  t j j |  } | j j d |  | j t |  g d t	 d } | j j
 d | d t  | S(   s$  Return the collection node of a file.

        :param config: :py:class:`_pytest.config.Config` instance, see
           :py:meth:`parseconfig` and :py:meth:`parseconfigure` to create the
           configuration

        :param arg: a :py:class:`py.path.local` instance of the file

        s   ::t   sessiont   genitemsi    t
   exitstatus(   R   R@   R   R6  R   t   localRu   t   pytest_sessionstartt   perform_collectR   t   pytest_sessionfinishR   (   R5   R(   t   argRU  R.  t   res(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   getnode  s    
"c         C` sy   |  j  |  } t |  } | j j |  } | j j d |  | j | g d t d } | j j d | d t	  | S(   s   Return the collection node of a file.

        This is like :py:meth:`getnode` but uses :py:meth:`parseconfigure` to
        create the (configured) pytest Config instance.

        :param path: a :py:class:`py.path.local` instance of the file

        RU  RV  i    RW  (
   t   parseconfigureR   t   fspathRL  Ru   RY  RZ  R   R[  R   (   R5   R   R(   RU  Rz   R]  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   getpathnode  s    	c         C` s>   | d j  } g  } x$ | D] } | j | j |   q W| S(   s   Generate all test items from a collection node.

        This recurses into the collection node and returns a list of all the
        test items contained within.

        i    (   RU  R^   RV  (   R5   t   colitemsRU  RS  t   colitem(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRV    s
    c         C` s1   |  j  |  } |  j j } | j   } | |  S(   s(  Run the "test_func" Item.

        The calling test instance (class containing the test method) must
        provide a ``.getrunner()`` method which should return a runner which
        can run the test protocol for a single item, e.g.
        :py:func:`_pytest.runner.runtestprotocol`.

        (   t   getitemRn   t   instancet	   getrunner(   R5   R+  Rc   t   testclassinstancet   runner(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   runitem  s    
c         G` s/   |  j  |  } t |  | g } |  j |   S(   s  Run a test module in process using ``pytest.main()``.

        This run writes "source" into a temporary file and runs
        ``pytest.main()`` on it, returning a :py:class:`HookRecorder` instance
        for the result.

        :param source: the source code of the test module

        :param cmdlineargs: any extra command line arguments to use

        :return: :py:class:`HookRecorder` instance of the result

        (   R2  R   t
   inline_run(   R5   R+  t   cmdlineargsR.  Ry   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   inline_runsource  s    c         G` sA   |  j  d |  } g  | j d  D] } | j ^ q" } | | f S(   s"  Run ``pytest.main(['--collectonly'])`` in-process.

        Runs the :py:func:`pytest.main` function to run all of pytest inside
        the test process itself like :py:meth:`inline_run`, but returns a
        tuple of the collected items and a :py:class:`HookRecorder` instance.

        s   --collect-onlyt   pytest_itemcollected(   Rj  R   Rc   (   R5   R*  t   recRz   R   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   inline_genitems  s    %c         ` s  | j  d g   } | j  d d  } t |  g  } zt   } x-  j j   D] \ } } | j | |  qP W| j | j  t	 j
     f d   }	 | j |	  d   t	 _
 | j  j   j  | j t   j  g   d t f   f d     Y}
 | j |
    t j t |  d | } t   d k rK j    } n d t f d	     Y} | | _ | t k r| r| j d
  } | r| d j j t k rt    qn  | SWd x | D] } |   qWXd S(   sx  Run ``pytest.main()`` in-process, returning a HookRecorder.

        Runs the :py:func:`pytest.main` function to run all of pytest inside
        the test process itself.  This means it can return a
        :py:class:`HookRecorder` instance which gives more detailed results
        from that run than can be done by matching stdout/stderr from
        :py:meth:`runpytest`.

        :param args: command line arguments to pass to :py:func:`pytest.main`

        :param plugins: (keyword-only) extra plugin instances the
           ``pytest.main()`` instance should use

        :return: a :py:class:`HookRecorder` instance
        R  t   no_reraise_ctrlcc           ` s     t  _ d  S(   N(   R   t   _warn_already_imported(    (   t	   orig_warn(    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   revert_warn_already_imported5  s    c          W` s   d  S(   N(   R   (   t   a(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   <lambda>9  R   t   Collectc           ` s   e  Z    f d    Z RS(   c         ` s     j   j | j   d  S(   N(   RN   R  R%   (   Rz   R(   (   Rn  R5   (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR*   K  s    (   Rj   Rk   R*   (    (   Rn  R5   (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRv  J  s   i   R  c           B` s   e  Z RS(    (   Rj   Rk   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR  T  s   t   pytest_keyboard_interruptiN(   R   R   R2   R   R  R   R  RN   R  R   Rq  R  R   R   t   objectRa   t   mainR   R]   R   R   R   t   excinfot   typet   KeyboardInterrupt(   R5   R*  R0   R  Rp  t
   finalizerst   mp_runR   t   vRs  Rv  R   R  R   t	   finalizer(    (   Rr  Rn  R5   s/   lib/python2.7/site-packages/_pytest/pytester.pyRj    s<    
			c   
      ` sG  | j  d t  } | r% |  j   n  t j   } t d t  } | j   z| y |  j | |   } Wn_ t k
 r   d t	 f   f d     Y} n1 t
 k
 r t j   d t	 f d     Y} n XWd | j   \ } } | j   t j j |  t j j |  Xt | j | j d  | j d  t j   |  }	 | |	 _ |	 S(   s}   Return result of running pytest in-process, providing a similar
        interface to what self.runpytest() provides.
        R<  t   CaptureR  c           ` s   e  Z   j d  Z RS(   i    (   Rj   Rk   R*  R   (    (   t   e(    s/   lib/python2.7/site-packages/_pytest/pytester.pyR  t  s   c           B` s   e  Z d  Z RS(   i   (   Rj   Rk   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR  z  s   Ns   
(   R   R   R<  t   timeR   R	   t   start_capturingRj  t
   SystemExitRx  t	   Exceptiont	   tracebackt	   print_exct
   readouterrt   stop_capturingRZ   R   R'  R:   R   R   RL   R  (
   R5   R*  R0   R<  t   nowt   captureR  R6   t   errR]  (    (   R  s/   lib/python2.7/site-packages/_pytest/pytester.pyR  d  s*    


4	c         O` s   |  j  |  } |  j | |   S(   s   Run pytest inline or in a subprocess, depending on the command line
        option "--runpytest" and return a :py:class:`RunResult`.

        (   t   _ensure_basetempR  (   R5   R*  R0   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s    c         C` sW   t  |  } xD | D] } t |  j d  r Pq q W| j d |  j j d   | S(   Ns
   --basetemps   --basetemp=%st   basetemp(   R   R
   RH   RN   R  R%  (   R5   R*  Rz   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR    s    c         G` sJ   |  j  |  } d d l } | j j | |  j  } |  j j | j  | S(   s  Return a new pytest Config instance from given commandline args.

        This invokes the pytest bootstrapping code in _pytest.config to create
        a new :py:class:`_pytest.core.PluginManager` and call the
        pytest_cmdline_parse hook to create a new
        :py:class:`_pytest.config.Config` instance.

        If :py:attr:`plugins` has been populated they should be plugin modules
        to be registered with the PluginManager.

        i    N(   R  R   R(   t   _prepareconfigR  Rn   Rs   R   (   R5   R*  Ro   R(   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   parseconfig  s
    c         G` s0   |  j  |   } | j   |  j j | j  | S(   s   Return a new pytest configured Config instance.

        This returns a new :py:class:`_pytest.config.Config` instance like
        :py:meth:`parseconfig`, but also calls the pytest_configure hook.

        (   R  t   _do_configureRn   Rs   R   (   R5   R*  R(   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR_    s    
t	   test_funcc         C` sV   |  j  |  } x! | D] } | j | k r | Sq Wd sR t d | | | f   d S(   sq  Return the test item for a test function.

        This writes the source to a python file and runs pytest's collection on
        the resulting module, returning the test item for the requested
        function name.

        :param source: the module source

        :param funcname: the name of the test function for which to return a
            test item

        i    s)   %r item not found in module:
%s
items: %sN(   t   getitemsR   R   (   R5   R+  t   funcnameR   Rc   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRd    s    c         C` s   |  j  |  } |  j | g  S(   s   Return all test items collected from the module.

        This writes the source to a python file and runs pytest's collection on
        the resulting module, returning all test items contained within.

        (   t   getmodulecolRV  (   R5   R+  t   modcol(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR    s    c         C` s   t  | t  r= |  j j t |   } | sn t d   n1 i t |  j   |  j j	 j
 6} |  j |   } | r |  j d d  n  |  j | |  |  _ } |  j | |  S(   s  Return the module collection node for ``source``.

        This writes ``source`` to a file using :py:meth:`makepyfile` and then
        runs the pytest collection on it, returning the collection node for the
        test module.

        :param source: the source code of the module to collect

        :param configargs: any extra arguments to pass to
            :py:meth:`parseconfigure`

        :param withinit: whether to also write an ``__init__.py`` file to the
            same directory to ensure it is a package

        s   not supported for pathsRp   t   #(   R   R   R  R.   R@   R   R   R(  Rn   R   Rj   R2  R_  R(   R^  (   R5   R+  t
   configargst   withinitR   t   kwR(   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR    s    "c         C` sZ   | |  j  k r+ t | j    |  j  | <n  x( |  j  | D] } | j | k r9 | Sq9 Wd S(   s6  Return the collection node for name from the module collection.

        This will search a module collection node for a collection node
        matching the given name.

        :param modcol: a module collection node; see :py:meth:`getmodulecol`

        :param name: the name of the node to return

        N(   R   R   R\   R   (   R5   R  R   Rc  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   collect_by_name  s
    c         K` s  t  j j   } t  j j t d t  j   | j d d  g   | d <| j	 |  j
  | | d <| t j k r t j | d <n) t | t  r t j | d <n
 | | d <t j | d | d | | } | t j k r | j j   n" t | t  r| j j |  n  | S(   s   Invoke subprocess.Popen.

        This calls subprocess.Popen making sure the current working directory
        is in the PYTHONPATH.

        You probably want to use :py:meth:`run` instead.

        t
   PYTHONPATHR   t   envt   stdinR   R:   N(   R;   t   environR   t   pathsepR.   t   filterR   R   R   R~   R  R   t   CLOSE_STDINR   t   PIPER   R  t   PopenR  t   closeR'  (   R5   t   cmdargsR   R:   R  R  R  t   popen(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR    s     	.

c         ` s  t  } | j d d   | j d t j  } t |  g    D]- } t | t j j	  re t
 |  n | ^ q>    j j d  }  j j d  } t d    t d t j j	    t j t
 |  d d d	 } t j t
 |  d d d	 }	 zDt j   }
  j   d | d | d |	 d
 t j d k  t | t  rR j j   n       f d   }  d k r j   } n t j ry  j   } Wq7t j k
 r|   q7Xnu t j    } t d  d  } xO t  r6 j   } | d k	 r
Pn  t j   | k r&|   n  t j |  qWWd | j   |	 j   Xt j t
 |  d d d	 } t j t
 |  d d d	 }	 z( | j   j    } |	 j   j    } Wd | j   |	 j   X j! | t j"   j! | t j#  t$ | | | t j   |
  S(   sz  Run a command with arguments.

        Run a process using subprocess.Popen saving the stdout and stderr.

        :param args: the sequence of arguments to pass to `subprocess.Popen()`
        :param timeout: the period in seconds after which to timeout and raise
            :py:class:`Testdir.TimeoutExpired`
        :param stdin: optional standard input.  Bytes are being send, closing
            the pipe, otherwise it is passed through to ``popen``.
            Defaults to ``CLOSE_STDIN``, which translates to using a pipe
            (``subprocess.PIPE``) that gets closed.

        Returns a :py:class:`RunResult`.

        t   timeoutR  R   R:   s   running:s        in:t   wR   t   utf8t	   close_fdst   win32c          ` sE   t  }  d j d  d    }  j    j    j |   d  S(   Ns3   {seconds} second timeout expired running: {command}R   t   command(   R+   R-   t   killt   waitR   (   R1   t   timeout_message(   R  R  R5   R  (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   handle_timeoutY  s    	

g?i
   Nt   r(%   R+   R   R   R   R  R2   R   R6  R   RX  R@   R  R.   R   t   codecsR=   R  R  RZ   t   platformR  R  R  R  R  t   PY3R   R   t   mint   pollt   sleept   readt
   splitlinest   _dump_linesR   R:   R   (   R5   R  R0   R1   R  R\  t   p1t   p2t   f1t   f2R  R  R   t   endt
   resolutionR6   R  (    (   R  R  R5   R  s/   lib/python2.7/site-packages/_pytest/pytester.pyt   run.  sd    
:		


c         C` sN   y% x | D] } t  | d | q
 WWn" t k
 rI t  d | f  n Xd  S(   Nt   files(   couldn't print to %s because of encoding(   R   t   UnicodeEncodeError(   R5   R   t   fpRI   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR    s
    c         C` s   t  j d f S(   Ns   -mpytest(   RZ   t
   executable(   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   _getpytestargs  s    c         C` s   |  j  t j |  S(   sl   Run a python script using sys.executable as interpreter.

        Returns a :py:class:`RunResult`.

        (   R  RZ   R  (   R5   t   script(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt	   runpython  s    c         C` s   |  j  t j d |  S(   s8   Run python -c "command", return a :py:class:`RunResult`.s   -c(   R  RZ   R  (   R5   R  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   runpython_c  s    c         O` s   t  } | j d d	  } t |  t j j j d d d d	 d |  j  } d | f | } g  |  j	 D] } t
 | t  rd | ^ qd } | r d | d f | } n  |  j   | } |  j d | |  S(
   s  Run pytest as a subprocess with given arguments.

        Any plugins added to the :py:attr:`plugins` list will be added using the
        ``-p`` command line option.  Additionally ``--basetemp`` is used to put
        any temporary files and directories in a numbered directory prefixed
        with "runpytest-" to not conflict with the normal numbered pytest
        location for temporary files and directories.

        :param args: the sequence of arguments to pass to the pytest subprocess
        :param timeout: the period in seconds after which to timeout and raise
            :py:class:`Testdir.TimeoutExpired`

        Returns a :py:class:`RunResult`.
        R  t   prefixs
   runpytest-t   keepRF  s   --basetemp=%ss   -pi    N(   R+   R   R   R2   R6  R   RX  t   make_numbered_dirR  R  R   R@   R  R  (   R5   R*  R0   R1   R  R.  Rz   R  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR    s    
+g      $@c         C` sV   |  j  j d  } d j t t |  j     } d | | | f } |  j | d | S(   s   Run pytest using pexpect.

        This makes sure to use the right pytest and sets up the temporary
        directory locations.

        The pexpect child is returned.

        s   temp-pexpectt    s   %s --basetemp=%s %st   expect_timeout(   R  R=  R.   t   mapR@   R  t   spawn(   R5   t   stringR  R  t   invoket   cmd(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   spawn_pytest  s    	c         C` s   t  j d d  } t t d  rC d t j   k rC t  j d  n  t j j d  re t  j d  n  |  j	 j
 d  j d	  } t j j   } | j |  j  | j | d
 | d | } |  j j | j  | | _ | S(   sN   Run a command using pexpect.

        The pexpect child is returned.

        t   pexpects   3.0RV   t   64s   pypy-64 bit not supportedt   freebsds)   pexpect does not work reliably on freebsds	   spawn.outR9   t   logfileR  (   Ra   t   importorskipRY   RZ   R  t   machinet   skipRH   t   xfailR  R.   R=   R;   R  R   R~   R  R  Rn   Rs   R  R  (   R5   R  R  R  R  R  t   child(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR    s    !	N(    (7   Rj   Rk   R   Rx  R  R  R   Rp   R   R  R	  R  R  R   R/  R0  R3  R5  R9  R2  R:  R   R<  R=  R?  RT  R   R^  Ra  RV  Ri  Rl  Ro  Rj  R  R   R  R  R_  Rd  R  R   R  R  R   R  R  R  R  R  R  R  R  R  R  (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     sb   																,							Q	#						
	!	[					c         C` s7   y |  j  d  SWn t k
 r2 d t |   f SXd  S(   Ns   utf-8s2   INTERNAL not-utf8-decodeable, truncated string:
%s(   RA   t   UnicodeDecodeErrorR   (   R6   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt
   getdecoded  s    R   c           B` s   e  Z d    Z d   Z RS(   c         C` s   t  j j   |  _ d  S(   N(   R6  t   iot   TextIOt   stringio(   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRp     s    c         C` sW   t  } |  j j   } |  j j d  |  j j d  | j d  } t |  j |  S(   sl   Assert that lines2 are contained (linearly) in lines1.

        Return a list of extralines found.

        i    s   
(   R+   R  R"   t   truncatet   seekRL   R   t   fnmatch_lines(   R5   Re   R1   t   valRd   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   assert_contains_lines  s    (   Rj   Rk   Rp   R  (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s   	c           B` s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 e d	    Z d
   Z d   Z d   Z RS(   s   Flexible matching of text.

    This is a convenience class to test large texts like the output of
    commands.

    The constructor takes a list of lines without their trailing newlines, i.e.
    ``text.splitlines()``.

    c         C` s   | |  _  g  |  _ d  S(   N(   R   t   _log_output(   R5   R   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRp     s    	c         C` s   d j  |  j  S(   s    Return the entire original text.s   
(   R.   R   (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR@   	  s    c         C` sC   t  | t  r t |  } n  t  | t  r? | j   j } n  | S(   N(   R   R@   R   R(  R   (   R5   Re   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt	   _getlines  s
    c         C` s   |  j  | t  d S(   s   Check lines exist in the output using in any order.

        Lines are checked using ``fnmatch.fnmatch``. The argument is a list of
        lines which have to occur in the output, in any order.

        N(   t   _match_lines_randomR   (   R5   Re   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   fnmatch_lines_random  s    c         C` s   |  j  | d    d S(   s   Check lines exist in the output using ``re.match``, in any order.

        The argument is a list of lines which have to occur in the output, in
        any order.

        c         S` s   t  j | |   S(   N(   t   ret   match(   R   t   pat(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRu  $  R   N(   R  (   R5   Re   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   re_match_lines_random  s    c         C` s   |  j  |  } xw | D]o } xf |  j D]; } | | k sG | | |  r& |  j d t |   Pq& q& W|  j d |  t |  j   q Wd S(   s   Check lines exist in the output.

        The argument is a list of lines which have to occur in the output, in
        any order.  Each line can contain glob whildcards.

        s	   matched: s   line %r not found in outputN(   R  R   t   _logR   R   t	   _log_text(   R5   Re   t
   match_funcRI   Rz   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR  &  s    c         C` s^   xG t  |  j  D]6 \ } } | | k s7 t | |  r |  j | d Sq Wt d |   d S(   st   Return all lines following the given line in the text.

        The given line can contain glob wildcards.

        i   s   line %r not found in outputN(   R   R   R   R   (   R5   t   fnlineR   RI   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   get_lines_after7  s    c         G` s'   |  j  j d j d   | D   d  S(   NR  c         s` s   |  ] } t  |  Vq d  S(   N(   R@   (   RW   Rz   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pys	   <genexpr>C  s    (   R  RN   R.   (   R5   R*  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR  B  s    c         C` s   d j  |  j  S(   Ns   
(   R.   R  (   R5   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR  E  s    c         C` s   t  } |  j | t d  d S(   s  Search captured text for matching lines using ``fnmatch.fnmatch``.

        The argument is a list of lines which have to match and can use glob
        wildcards.  If they do not match a pytest.fail() is called.  The
        matches and non-matches are also printed on stdout.

        R   N(   R+   t   _match_linesR   (   R5   Re   R1   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR  I  s    c         C` s    t  } |  j | d   d  d S(   s  Search captured text for matching lines using ``re.match``.

        The argument is a list of lines which have to match using ``re.match``.
        If they do not match a pytest.fail() is called.

        The matches and non-matches are also printed on stdout.

        c         S` s   t  j | |   S(   N(   R  R  (   R   R  (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyRu  ^  R   s   re.matchN(   R+   R  (   R5   Re   R1   (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   re_match_linesT  s    	c   
      C` sL  t  | t  s t  |  j |  } |  j } d } g  } t } x| D] } t }	 x | r| j d  } | | k r |  j	 d t
 |   Pn~ | | |  r |  j	 d | t
 |   |  j	 d t
 |   Pn; |	 s |  j	 d t
 |   t }	 n  |  j	 d t
 |   | j |  qV W|  j	 d | f  t j |  j  qG Wd S(	   s  Underlying implementation of ``fnmatch_lines`` and ``re_match_lines``.

        :param list[str] lines2: list of string patterns to match. The actual
            format depends on ``match_func``
        :param match_func: a callable ``match_func(line, pattern)`` where line
            is the captured line from stdout/stderr and pattern is the matching
            pattern
        :param str match_nickname: the nickname for the match function that
            will be logged to stdout when a match occurs

        i    s   exact match:s   %s:s      with:s   nomatch:s       and:s   remains unmatched: %rN(   R   R   R   R  R   R   R+   R   R   R  R   RN   Ra   R   R  (
   R5   Re   R  t   match_nicknameRd   t   nextlinet
   extralinesR1   RI   t   nomatchprinted(    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR  `  s0    
		(   Rj   Rk   R   Rp   R@   R  R  R  R  R  R  t   propertyR  R  R  R  (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyR     s   													(C   R   t
   __future__R    R   R   R  R[   R;   R  R  R   RZ   R  R  R   t   weakrefR   R6  R  Ra   t   _pytest._codeR   t   _pytest._io.safereprR   t   _pytest.assertion.rewriteR   t   _pytest.captureR   R	   t   _pytest.compatR
   R   t   _pytest.mainR   R   R   t   _pytest.monkeypatchR   t   _pytest.pathlibR   RM   R    R*   R2   Rx  R#   t   fixtureRo   Rm   R{   R|   Rq   R   R   R   R   R   t   compileR   R   R   R   R   R   R  R   R   (    (    (    s/   lib/python2.7/site-packages/_pytest/pytester.pyt   <module>   sp   				H

			H   	