+
    ^|ii.                     H   R t ^ RIt^ RIt^ RIt^ RIHt ]P                  ! ]4      t ! R R]P                  4      t	 ! R R]P                  4      t ! R R]P                  4      t ! R	 R
]P                  4      t]P                   ! R4      t ! R R]P$                  4      tR# )a  Nose Plugin that supports IPython doctests.

Limitations:

- When generating examples for use as doctests, make sure that you have
  pretty-printing OFF.  This can be done either by setting the
  ``PlainTextFormatter.pprint`` option in your configuration file to  False, or
  by interactively disabling it with  %Pprint.  This is required so that IPython
  output matches that of normal Python, which is used by doctest for internal
  execution.

- Do not rely on specific prompt numbers for results (such as using
  '_34==True', for example).  For IPython tests run via an external process the
  prompt numbers may be different, and IPython tests run as normal python code
  won't even have these special _NN variables set at all.
N)modified_envc                   2   a a ] tR t^(t oV 3R ltRtVtV ;t# )DocTestFinderc                   < \         SV `  WW4V4      p\        \        VR R4      4      '       d5   Ve1   VP                   F   pRVP
                  \        P                  &   K"  	  V# )__skip_doctest__FT)super	_get_testboolgetattrexamplesoptionsdoctestSKIP)	selfobjnamemoduleglobssource_linestestexample	__class__s	   &&&&&&  B/usr/lib/python3/dist-packages/IPython/testing/plugin/ipdoctest.pyr   DocTestFinder._get_test)   sW    w F<H/788T=M==04- )      )__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell____classcell__r   __classdict__s   @@r   r   r   (   s      r   r   c                   N   a  ] tR t^3t o Rt]P                  ! R4      tR tRt	V t
R# )IPDoctestOutputCheckerzSecond-chance checker with support for random tests.

If the default comparison doesn't pass, this checker looks in the expected
output string for flags that tell us to ignore the output.
z#\s*random\s+c                    \         P                  P                  WVV4      pV'       g$   V P                  P	                  V4      '       d   R# V# )zCheck output, accepting special markers embedded in the output.

If the output didn't pass the default validation but the special string
'#random' is included, we accept it.T)r   OutputCheckercheck_output	random_research)r   wantgotoptionflagsrets   &&&& r   r)   #IPDoctestOutputChecker.check_output<   s@     ##00S1<>t~~,,T22
r   r   N)r   r   r   r   __doc__recompiler*   r)   r    r!   r$   s   @r   r&   r&   3   s%      

+,I r   r&   c                       ] tR t^OtRtR# )	IPExampler   N)r   r   r   r   r    r   r   r   r6   r6   O   s    $r   r6   c                   `  a  ] tR t^Rt o RtRtRtRtRtRt	]
P                  ! ]	]]]]3,          ]
P                  ]
P                  ,          4      t]
P                  ! ]	]]]]3,          ]
P                  ]
P                  ,          4      t]
P                  ! R4      tR tRR	 ltRR
 ltR tRtV tR# )IPDocTestParserz
A class used to parse strings containing doctest examples.

Note: This is a version modified to properly recognize IPython input and
convert any IPython examples into valid Python ones.
z>>>z\.\.\.zIn\ \[\d+\]:z\ \ \ \.\.\.+:a]  
        # Source consists of a PS1 line followed by zero or more PS2 lines.
        (?P<source>
            (?:^(?P<indent> [ ]*) (?P<ps1> %s) .*)    # PS1 line
            (?:\n           [ ]*  (?P<ps2> %s) .*)*)  # PS2 lines
        \n? # a newline
        # Want consists of any non-blank lines that do not start with PS1.
        (?P<want> (?:(?![ ]*$)    # Not a blank line
                     (?![ ]*%s)   # Not a line starting with PS1
                     (?![ ]*%s)   # Not a line starting with PS2
                     .*$\n?       # But any other line
                  )*)
                  z#\s*all-random\s+c                    \         P                  P                  V4      p\        VP	                  4       4      ^8X  d   \         P                  V4      # V# )z/Convert input IPython source into valid Python.)_ipinput_transformer_managertransform_celllen
splitlines	prefilter)r   sourceblocks   && r   ip2pyIPDocTestParser.ip2py   sB    --<<VDu!"a'==''Lr   c                $   VP                  4       pV P                  V4      pV^ 8  d3   RP                  VP                  R4       Uu. uF  qDVR NK	  	  up4      p. p^ ^ rvV P                  P                  V4      '       d   RpMRpRp	\        V P                  P                  V4      4      p
V
'       d   \        P                  pM,\        V P                  P                  V4      4      p
\        pRp	V
 EF   pVP                  WVP                  4        4       WqP                  RWlP                  4       4      ,          pV P!                  WWy4      w  rppW,          pV P#                  V4      '       g<   VP                  V! WVVV\%        VP'                  R4      4      ,           VR7      4       WqP                  RVP                  4       VP)                  4       4      ,          pVP)                  4       pEK  	  VP                  WR 4       V# u upi )	a  
Divide the given string into examples and intervening text,
and return them as a list of alternating Examples and strings.
Line numbers for the Examples are 0-based.  The optional
argument `name` is a name identifying this string, and is only
used for error messages.

Nz	
# random FTindent)linenorG   r   )
expandtabs_min_indentjoinsplit_RANDOM_TESTr+   list_EXAMPLE_RE_PYfinditerr   Example_EXAMPLE_RE_IPr6   appendstartcount_parse_example_IS_BLANK_OR_COMMENTr=   groupend)r   stringr   
min_indentloutputcharnorH   random_markerrB   termsrQ   mr@   r   r,   exc_msgs   &&&              r   parseIPDocTestParser.parse   s    ""$%%f-
>YYT8JK8J1*+8JKLFA ##F++(MM  T((11&9:ooG ,,55f=>EGEAMM&	23ll4;;F ((&? -VdG
 !D ,,V44gfG-3-7AGGH<M8N-N.57 8
 ll4AEEG<<FUUWF- 0 	fWo&g  Ls   Hc           	     *   \        VP                  R4      4      pVP                  R4      P                  R4      pVP                  R4      pVP                  R4      p\        V4      p	V P                  WeW#V	4       V'       d)   V P	                  VR,          RV,          V,           W#4       RP                  V U
u. uF  qWY,           ^,           R NK  	  up
4      pV'       d   V P                  V4      pVP                  R	4      pVP                  R4      p\        V4      ^8  d(   \        P                  ! R
VR,          4      '       d   VR V P	                  VRV,          VV\        V4      ,           4       \        P                  ! RRV^ ,          4      V^ &   RP                  V Uu. uF  qVR NK	  	  up4      pV P                  P                  V4      pV'       d   VP                  R4      pMRpV P                  WV4      pVVW3# u up
i u upi )a  
Given a regular expression match from `_EXAMPLE_RE` (`m`),
return a pair `(source, want)`, where `source` is the matched
example's source code (with prompts and indentation stripped);
and `want` is the example's expected output (with indentation
stripped).

`name` is the string's name, and `lineno` is the line number
where the example starts; both are used for error messages.

Optional:
`ip2py`: if true, filter the input via IPython to convert the syntax
into valid python.
rG   r@   rE   ps1ps2:   NN Nr,   z *$zOut\[\d+\]: \s*?\n?rF   msg)r=   rX   rL   _check_prompt_blank_check_prefixrK   rB   r2   matchsub_EXCEPTION_RE_find_options)r   ra   r   rH   rB   rG   r   rf   rg   ps1_lenslr@   r,   
want_lineswlrb   r   s   &&&&&            r   rV   IPDocTestParser._parse_example   s   " QWWX&' wwx(..t4 ggenggenc(  tGL|B/Vc1A4PLILbv~a/01LIJZZ'F
 wwvZZ%
z?Q288FJrN#C#C2:s6z4!C$55	7 5bAG
1yy
;
"VW+
;< $$T*ggenGG $$V6:w--? J& <s   :H)Hc                    W%,           pV^,           p\        V4       FN  w  r\        V	4      V8  g   K  W,          R8w  g   K&  \        RWH,           ^,           : RV: RWV : RV	: 24      h	  R# )al  
Given the lines of a source string (including prompts and
leading indentation), check to make sure that every prompt is
followed by a space character.  If any line is not followed by
a space character, then raise ValueError.

Note: IPython-modified version which takes the input prompt length as a
parameter, so that prompts of variable length can be dealt with.
ri   zline z of the docstring for z lacks blank after z: N)	enumerater=   
ValueError)
r   linesrG   r   rH   rr   	space_idxmin_lenilines
   &&&&&&    r   rl   #IPDocTestParser._check_prompt_blank  sf     N	A+ 'GA4yW$C)? "((1**d"&i"8$"@ A A (r   r   N)z<string>)F)r   r   r   r   r1   _PS1_PY_PS2_PY_PS1_IP_PS2_IP_RE_TPLr2   r3   	MULTILINEVERBOSErO   rR   rM   rB   rc   rV   rl   r    r!   r4   s   @r   r8   r8   R   s      GGGGG ZZGGGG+L!L!#

!:<N ZZGGGG+L!L!#

!:<N ::23LBH?.BA Ar   r8   r   c                   :   a a ] tR tRt oRtRV 3R lltRtVtV ;t# )IPDocTestRunneri#  zKTest runner that synchronizes the IPython namespace with test globals.
    c                   < \        R RRR/4      ;_uu_ 4        \        \        V `  VW#V4      uuRRR4       #   + '       g   i     R# ; i)COLUMNS80LINES24N)r   r   r   run)r   r   compileflagsoutclear_globsr   s   &&&&&r   r   IPDocTestRunner.run'  s=    9dGT:;;243?KQ <;;;s	   9A
	r   )NNT)	r   r   r   r   r1   r   r    r!   r"   r#   s   @@r   r   r   #  s     Q Qr   r   )r1   r   loggingr2   testpathr   	getLoggerr   logr   r(   r&   rQ   r6   DocTestParserr8   register_optionflagr   DocTestRunnerr   r   r   r   <module>r      s   *   	 ! !G)) W22 8 ' &KAg++ KA\ ""6*Qg++ Qr   