
    Mheu                        U d 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mZmZmZmZmZmZmZmZmZmZmZmZ ddlZddlmZ ddlm Z m!Z!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- n# e.$ r	 ddl+m-Z- Y nw xY wddl/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9 er
ddl:Z:ddl;m<Z< dZ=dZ>dZ?dZ@dZAe=e>e?e@eAfZBdaCdaDeed                  eEd<    eFd ejG        H                    d          D                       ZIde*ddfd ZJdVd!ZKd"ed#e0deed$                  fd%ZLeId         d&k     reLZMd#e0deed$                  fd'ZLe5ZNd( Z5d)edeOfd*ZPd+e(d)ed#e0deOfd,ZQd)edeOfd-ZR G d. d/e"          ZS G d0 d1eT          ZUded2         fd3ZV	 	 	 	 dWd5ed         d6eeO         d7eWd8eOdd2f
d9ZX G d: d;ejY                  ZZdee[eWf         fd<Z\d= Z]d> Z^ G d? d@ej_                  Z`dXdCZadDebdeOfdEZcededF         fdG            Zd G dH dIej_                  ZedJeZde-fdKZfded         fdLZgdYdMZhdeWfdNZideWfdOZjdeWfdPZkdQe[deWfdRZl ejm        dST          dee[ef         fdU            ZndS )Zz6Discover and run ipdoctests in modules and test files.    N)contextmanager)Path)TYPE_CHECKINGAnyCallableDict	GeneratorIterableListOptionalPatternSequenceTupleTypeUnion)outcomes)ExceptionInfoReprFileLocationTerminalRepr)TerminalWritersafe_getattr)Config)Parser)
TopRequest)FixtureRequest)	Collector)OutcomeException)
fnmatch_eximport_path)approx)PytestWarning   IPDoctestOutputCheckernonecdiffndiffudiffonly_first_failurer%   CHECKER_CLASSc                 ,    g | ]}t          |          S  )int).0parts     g/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/testing/plugin/pytest_ipdoctest.py
<listcomp>r2   M   s    LLLdD		LLL    .parserreturnc                    |                      ddddg           |                      ddd	           |                     d
          }|                    ddddd           |                    dt          j        ddt
          d           |                    ddg ddd           |                    ddddd           |                    dddd d!           d S )"Nipdoctest_optionflagszoption flags for ipdoctestsargsELLIPSIS)typedefaultipdoctest_encodingz!encoding used for ipdoctest fileszutf-8)r<   collectz--ipdoctest-modules
store_trueFz!run ipdoctests in all .py modulesipdoctestmodules)actionr<   helpdestz--ipdoctest-reportr)   z;choose another output format for diffs on ipdoctest failureipdoctestreport)r;   r<   rB   choicesrC   z--ipdoctest-globappendpatz4ipdoctests file matching pattern, default: test*.txtipdoctestglob)rA   r<   metavarrB   rC   z --ipdoctest-ignore-import-errorszignore ipdoctest ImportErrorsipdoctest_ignore_import_errorsz--ipdoctest-continue-on-failurez>for a given ipdoctest, continue to run after the first failureipdoctest_continue_on_failure)addinigetgroup	addoptionstrlowerDOCTEST_REPORT_CHOICES)r5   groups     r1   pytest_addoptionrS   P   sO   
MM%	     MMA7     OOI&&E	OO0     
OOYJ&     
OOC     
OO*,-     
OO)M,      r3   c                  
    d a d S N)RUNNER_CLASSr-   r3   r1   pytest_unconfigurerW      s     LLLr3   	file_pathparent)IPDoctestModuleIPDoctestTextfilec                 4   |j         }| j        dk    rV|j        j        rIt	          t          |           t          |           f          st                              ||           }|S n/t          || |          rt                              ||           }|S d S )Nz.pypath)configsuffixoptionr@   any_is_setup_py_is_main_pyrZ   from_parent_is_ipdoctestr[   )rX   rY   r_   modtxts        r1   pytest_collect_fileri      s     ]F5  =) 	#)$$k)&<&<=3
 3
 	 $3#>#>vI#>#V#VCJ	vy&	1	1 !2!>!>vI!>!V!V
4r3      c                 <    t          t          |           |          S rU   )_collect_filer   )r^   rY   s     r1   ri   ri      s     T$ZZ000r3   c                 X    dd l }t          |j                            |                     S )Nr   )py.path_import_pathr^   local)r^   rootpys      r1   r    r       s'    BGMM$//000r3   r^   c                 T    | j         dk    rdS |                                 }d|v pd|v S )Nzsetup.pyFs
   setuptoolss	   distutils)name
read_bytes)r^   contentss     r1   rc   rc      s8    yJu  HH$@(@@r3   r_   c                     j         dv r|j                                      rdS |                     d          pdg}t	          fd|D                       S )N)z.txtz.rstTrH   z	test*.txtc              3   8   K   | ]}t          |          V  d S rU   )r   )r/   globr^   s     r1   	<genexpr>z _is_ipdoctest.<locals>.<genexpr>   s-      88$z$%%888888r3   )r`   session
isinitpath	getoptionrb   )r_   r^   rY   globss    `  r1   rf   rf      sh    {&&&6>+D+DT+J+J&t_-->+E8888%888888r3   c                     | j         dk    S )Nz__main__.py)rt   r]   s    r1   rd   rd      s    9%%r3   c                   V    e Zd Zdeeeee         f                  ddfdZdeddfdZ	dS )ReprFailDoctestreprlocation_linesr6   Nc                     || _         d S rU   )r   )selfr   s     r1   __init__zReprFailDoctest.__init__   s     #5r3   twc                 ~    | j         D ]4\  }}|D ]}|                    |           |                    |           5d S rU   )r   line
toterminal)r   r   reprlocationlinesr   s        r1   r   zReprFailDoctest.toterminal   sZ    #'#: 	( 	(L%  ##B''''	( 	(r3   )
__name__
__module____qualname__r   r   r   rO   r   r   r   r-   r3   r1   r   r      sn        5"*51A8C=1P+Q"R5	5 5 5 5
(^ ( ( ( ( ( ( (r3   r   c                   4     e Zd Zded         ddf fdZ xZS )MultipleDoctestFailuresfailureszdoctest.DocTestFailurer6   Nc                 V    t                                                       || _        d S rU   )superr   r   )r   r   	__class__s     r1   r   z MultipleDoctestFailures.__init__   s$     r3   )r   r   r   r   r   __classcell__r   s   @r1   r   r      sQ        !*B!C ! ! ! ! ! ! ! ! ! ! !r3   r   IPDocTestRunnerc                  <    dd l ddlm}   G fdd|           }|S )Nr   r#   )r   c                        e Zd ZdZ	 	 	 	 dded         dee         ded	ed
df
 fdZddddded
dffdZ	ddddde
ee         eej        f         d
dffdZ xZS )/_init_runner_class.<locals>.PytestDoctestRunnerzRunner to collect failures.

        Note that the out variable in this case is a list instead of a
        stdout-like object.
        Nr   Tcheckerr%   verboseoptionflagscontinue_on_failurer6   c                 ^    t                                          |||           || _        d S )N)r   r   r   )r   r   r   )r   r   r   r   r   r   s        r1   r   z8_init_runner_class.<locals>.PytestDoctestRunner.__init__   s2     GGWg;WWW':D$$$r3   testdoctest.DocTestexamplezdoctest.Examplegotc                 h     j         |||          }| j        r|                    |           d S |rU   )DocTestFailurer   rF   )r   outr   r   r   failuredoctests         r1   report_failurez>_init_runner_class.<locals>.PytestDoctestRunner.report_failure   sC     -g,T7C@@G' 

7#####r3   exc_infoc                    t          |d         t                    r|d         t          |d         t          j                  rt	          j        d            j        |||          }| j        r|                    |           d S |)Nr#   zQuitting debugger)	
isinstancer   bdbBdbQuitr   exitUnexpectedExceptionr   rF   )r   r   r   r   r   r   r   s         r1   report_unexpected_exceptionzK_init_runner_class.<locals>.PytestDoctestRunner.report_unexpected_exception   s     (1+'788 "qk!(1+s{33 312221g1$JJG' 

7#####r3   NNr   T)r   r   r   __doc__r   boolr.   r   rO   r   r   r   BaseExceptiontypesTracebackTyper   r   )r   r   s   @r1   PytestDoctestRunnerr      s5       	 	 ;?&* (,	; 	;67	; d^	; 		;
 "&	; 	; 	; 	; 	; 	; 	;	 $	 '		
 	 	 	 	 	 	 		 $	 '		
 D/@SST	 	 	 	 	 	 	 	 	 	 	r3   r   )r   	ipdoctestr   )r   r   r   s     @r1   _init_runner_classr      s[    NNN******- - - - - - -o - - -^ r3   Tr   r   r   r   c                 R    t           t                      a t          | |||          S )Nr   r   r   r   )rV   r   r   s       r1   _get_runnerr     s:     )++ /	   r3   c                   `    e Zd ZU eeef         ed<   	 	 ddeddded         ded	         d
df
 fdZe	dddedddd	f fd            Z
ddZddZddZddZdee         d
eeef         f fdZd
eedef         ee         ef         fdZed         dk     red
efd            Z xZS  xZS )IPDoctestItem_user_ns_origNrt   rY   z)Union[IPDoctestTextfile, IPDoctestModule]runnerr   dtestr   r6   c                     t                                          ||           || _        || _        d | _        d | _        i | _        d S rU   )r   r   r   r   objfixture_requestr   )r   rt   rY   r   r   r   s        r1   r   zIPDoctestItem.__init__  sJ     	v&&&
9=r3   c                N    t                                          ||||          S )zThe public named constructor.)rt   rY   r   r   )r   re   )clsrY   rt   r   r   r   s        r1   re   zIPDoctestItem.from_parent*  s'     ww""VFRW"XXXr3   c                    | j         Jt          |           | _        t          | j        j                  }| j                            d                                          D ]
\  }}|||<   | j         j                            |           ddlm	} t          | j         j        d         |          ri | _        | j                            t          j                   t          j                            | j         j                   t          j                            dd            t           t          j        d<   t          j        | j         _        d S d S d S )N)
getfixtureipdoctest_namespacer#   	IPExampler   ___builtins__)r   _setup_fixturesr   dictgetfixturevalueitemsr~   updater   r   r   examplesr   _ipuser_nspopbuiltins)r   r~   rt   valuer   s        r1   setupzIPDoctestItem.setup7  s<   :!#24#8#8D D$8$HIIIE#3CC%   egg$ $e $dJ##E***,,,,,,$*-a0)<< / &(""))#+666""4:#3444 T***.6N+#&;
   - "!/ /r3   c                 .   ddl m} t          | j        j        d         |          rPi | j        _        t          j                                         t          j        	                    | j
                   | `
| j        j                                         d S )Nr#   r   r   )r   r   r   r   r   r~   r   r   clearr   r   )r   r   s     r1   teardownzIPDoctestItem.teardownP  s    (((((( dj)!,i88 	#!DJKKt1222"
     r3   c                    | j         J | j        J t          | j                    |                                  g }t	          t
          d          }t          t
          dd           }t          j                    }t          j	        | j
        j                   	 | j                            | j         |d           t          j	        |           |rt          t
          d|           nt	          t
          d          rt          t
          d           n]# t          j	        |           |rt          t
          d|           w t	          t
          d          rt          t
          d           w w xY w|rt          |          d S )Nr   F)r   clear_globs)r   r   _check_all_skipped$_disable_output_capturing_for_darwinhasattrr   getattrosgetcwdchdirfspathdirnamerunsetattrdelattrr   )r   r   had_underscore_valueunderscore_original_valuecurdirs        r1   runtestzIPDoctestItem.runtest\  s   z%%%{&&&4:&&&1133313  'x55$+Hc4$@$@!
 
$%%%		' KOODJH%OHHHHV# '#'@AAAA3'' '#&&&	 HV# '#'@AAAA3'' '#&&&&'  	4)(333	4 	4s   "D AE.c                 T   t          j                    dk    rdS | j        j                            d          }|rm|                    d           |                                \  }}t          j        	                    |           t          j
        	                    |           dS dS )zNDisable output capturing. Otherwise, stdout is lost to ipdoctest (pytest#985).DarwinNcapturemanagerT)in_)platformsystemr_   pluginmanager	getpluginsuspend_global_captureread_global_capturesysstdoutwritestderr)r   capmanr   errs       r1   r   z2IPDoctestItem._disable_output_capturing_for_darwinz  s    ?((F*445EFF 	"))d)3331133HCJS!!!JS!!!!!		" 	"r3   excinfoc                    dd l }d }t          |j        |j        |j        f          r	|j        g}n&t          |j        t
                    r|j        j        }|!t                                          |          S g }|D ]}|j	        }|j
        j        }j        d }nj        |j        z   dz   }t          |          j        }	t          |||	          }
t!                      }t#          | j                            d                    }|z|j
        j        J |j
        j                            d          }j        J fdt-          |          D             }|t/          |j        dz
  d          |j        dz            }n>dg}d}|j                                        D ]}|                    d	| d
|            d} t          ||j                  r3||                    ||j        |                              d          z  }nTt;          j        |j                  }|dtA          |j                  z  gz  }|d tC          j"        |j         D             z  }|                    |
|f           tG          |          S )Nr   r#   rD   Fc                 :    g | ]\  }}d |j         z   dz   |fz  S )z%03d %sr#   )lineno)r/   ixr   s      r1   r2   z.IPDoctestItem.repr_failure.<locals>.<listcomp>  s?       =CaIT[1!4a 88  r3   	   z?EXAMPLE LOCATION UNKNOWN, not showing all tests of that examplez>>>z???  z...
zUNEXPECTED EXCEPTION: %sc                 8    g | ]}|                     d           S )r  )strip)r/   r  s     r1   r2   z.IPDoctestItem.repr_failure.<locals>.<listcomp>  s/       &'AGGDMM  r3   )$r   r   r   r   r   r   r   r   repr_failurer   r   filenamer  r;   r   r   _get_checker_get_report_choicer_   r}   	docstring
splitlines	enumeratemaxsourcerF   output_differencer   splitr   from_exc_infor   repr	tracebackformat_exceptionr   )r   r   r   r   r   r   r   r  r  messager   r   report_choicer   indentr   inner_excinfor   r   s                    @r1   r  zIPDoctestItem.repr_failure  s    	  	 MG2G4OP
 
 	.  HH'>?? 	.}-H77''000 )	= )	=GoG<D}H{"w~597mm,G+HfgFFL"nnG.t{/D/DEV/W/WXXM!|-999.99%@@{...   GPQVGWGW   c'.1"4a887>A;MMN V #N5577 # #DLL!7!7!7!7!7888"FF'7#9:: 	22W[- %++ !. ;G<L M M4tM<O7P7PPQQ  +4+EwGW+X    %%|U&;<<<<1222r3   zos.PathLike[str]c                 L    | j         J | j        | j         j        d| j        z  fS )Nz[ipdoctest] %s)r   r^   r  rt   r   s    r1   
reportinfozIPDoctestItem.reportinfo  s,    z%%%y$*+-=	-IIIr3   r   rj   c                 *    t          | j                  S rU   r   r   r  s    r1   r^   zIPDoctestItem.path      $$$r3   )NNr6   N)r   r   r   r   rO   r   __annotations__r   r   classmethodre   r   r   r   r   r   r   r   r   r  r   r.   r   pytest_versionpropertyr   r^   r   r   s   @r1   r   r     s        S>!!! /3-1     <  *+	 
 )*  
            
Y;
Y 	
Y
 "
Y !
Y 
Y 
Y 
Y 
Y [
Y/ / / /2
! 
! 
! 
!4 4 4 4<	" 	" 	" 	">3}->3 
sL 	!>3 >3 >3 >3 >3 >3@JE%(:C(?"@(3-QT"TU J J J J a1		%$ 	% 	% 	% 
	% 	% 	% 	% 	% r3   r   c                      dd l } t          | j        | j        | j        | j        | j        | j        t                      t                      t                      	  	        S )Nr   )	DONT_ACCEPT_TRUE_FOR_1DONT_ACCEPT_BLANKLINENORMALIZE_WHITESPACEr:   IGNORE_EXCEPTION_DETAILCOMPARISON_FLAGSALLOW_UNICODEALLOW_BYTESNUMBER)r   r   r*  r+  r,  r:   r-  r.  _get_allow_unicode_flag_get_allow_bytes_flag_get_number_flagr   s    r1   _get_flag_lookupr6    sa    NNN&=%;$9! ' ? 1-//)++!!
 
 
 
r3   c                 z    | j                             d          }t                      }d}|D ]}|||         z  }|S )Nr8   r   )r_   getinir6  )rY   optionflags_strflag_lookup_tableflag_accflags        r1   get_optionflagsr=    sO    m**+BCCO(**H , ,%d++Or3   c                 b    |                      d          }|r|                      d          rd}|S )NrK   usepdbF)getvalue)r_   r   s     r1   _get_continue_on_failurerA    s?     //*IJJ ( ??8$$ 	("'r3   c                        e Zd ZdZdee         fdZed         dk     r,ede	fd            Z
eddddee	         f fd	            Z xZS  xZS )
r[   Nr6   c              #     K   dd l }ddlm} | j                            d          }| j                            |          }t          | j                  }| j        j        }ddi}t          |           }t          d|t                      t          | j                            }	 |            }
|
                    ||||d          }|j        r't                              | |j        |	|	          V  d S d S )
Nr   r#   )IPDocTestParserr=   r   __main__Fr   r   r   r   rt   r   r   )r   r   rD  r_   r8  r^   	read_textrO   rt   r=  r   r  rA  get_doctestr   r   re   )r   r   rD  encodingtextr  rt   r~   r   r   r5   r   s               r1   r>   zIPDoctestTextfile.collect  s#     ...... ;%%&:;;y""8,,ty>>y~Z(%d++# NN 8 E E	
 
 
 !""!!$tXqAA= 	++49V4 ,       	 	r3   r   rj   c                 *    t          | j                  S rU   r"  r  s    r1   r^   zIPDoctestTextfile.path  r#  r3   r   r^   r^   c                |    |dd l }|j                            |          } t                      j        d||d|S Nr   )rY   r   r-   rn   r^   rp   r   re   r   rY   r   r^   kwrr   r   s         r1   re   zIPDoctestTextfile.from_parent  K     t,,&577&JfVJJrJJJr3   )r   r   r   r   r
   r   r>   r'  r(  r   r^   r&  r   re   r   r   s   @r1   r[   r[     s        
C-0    8 a1		%$ 	% 	% 	% 
	% 

 #'	K 	K 	K
 4.	K 	K 	K 	K 	K 
	K 	K 	K 	K 	K r3   r[   r   r   c                     ddl t          fd| j        D                       }|rt          j        d           dS dS )zVRaise pytest.skip() if all examples in the given DocTest have the SKIP
    option set.r   Nc              3   X   K   | ]$}|j                             j        d           V  %dS )FN)optionsgetSKIP)r/   r  r   s     r1   rz   z%_check_all_skipped.<locals>.<genexpr>.  s5      PPQaimmGL%88PPPPPPr3   z%all docstests skipped by +SKIP option)r   allr   pytestskip)r   all_skippedr   s     @r1   r   r   )  s[     NNNPPPP$-PPPPPK =;<<<<<= =r3   r   c                 (    t          | dd          duS )zmReturn if an object is possibly a mock object by checking the
    existence of a highly improbable attribute.1pytest_mock_example_attribute_that_shouldnt_existNr   )r   s    r1   
_is_mockedr_  3  s!     	SMtTT	r3   )NNNc               #     K   t           j        dddt          dt          f         dt          t          t          gt          f                  dt          ffd} | t           _        	 dV  t           _        dS # t           _        w xY w)zContext manager which replaces ``inspect.unwrap`` with a version
    that's aware of mock objects and doesn't recurse into them.Nstopfunc.rb  r6   c                     	 |	|t           u r  t                     S |   fd          S # t          $ r'}t          j        d|d dt                      d }~ww xY w)Nra  c                 8    t          |           p
           S rU   )r_  )r   _stoprc  s    r1   <lambda>zF_patch_unwrap_mock_aware.<locals>._mock_aware_unwrap.<locals>.<lambda>I  s    joo6Tt r3   zGot z when unwrapping z.  This is usually caused by a violation of Python's object protocol; see e.g. https://github.com/pytest-dev/pytest/issues/5080)r_  	Exceptionwarningswarnr"   )rc  rb  erf  real_unwraps   `  @r1   _mock_aware_unwrapz4_patch_unwrap_mock_aware.<locals>._mock_aware_unwrapB  s    	|tz11"{4j9999E;t*T*T*T*T*TUUUU 	 	 	MM GHaaO 	   	s   5 5 
A&"A!!A&)inspectunwrapr   r   r   )rm  rl  s    @r1   _patch_unwrap_mock_awarerp  <  s       .K MQ  sCx +3HcUCZ4H+I	     " (GN%$$$$$s   &A8 8Bc                        e Zd Zdee         fdZed         dk     r,edefd            Z	e
ddddee         f fd	            Z xZS  xZS )
rZ   r6   c              #     K   dd l }ddlm}m}  G d d|          }| j        j        dk    rt          d         dk     r>| j        j        	                    | j        | j        
                    d                    }nd	| j        j        i}t          d
k    rd|d<    | j        j        j	        | j        | j        
                    d          fi |}nz	 d| j        j        i}t          d
k    rd|d<   t          | j        fi |}nH# t          $ r; | j                            d          rt          j        d| j        z             n Y nw xY w | |                      }t#          |           }t%          d|t'                      t)          | j                            }	|                    ||j                  D ].}
|
j        r%t0                              | |
j        |	|
          V  /d S )Nr   r#   )DocTestFinderrD  c                   2     e Zd ZdZ fdZ	 	 d fdZ xZS )7IPDoctestModule.collect.<locals>.MockAwareDocTestFinderzA hackish ipdoctest finder that overrides stdlib internals to fix a stdlib bug.

            https://github.com/pytest-dev/pytest/issues/3456
            https://bugs.python.org/issue25532
            c                     t          |t                    rt          |d|          }t          |d          rt	          j        |          }t                                          ||          S )a3  Doctest code does not take into account `@property`, this
                is a hackish way to fix it. https://bugs.python.org/issue17446

                Wrapped Doctests will need to be unwrapped so the correct
                line number is returned. This will be reported upstream. #8796
                fget__wrapped__)r   r(  r   r   rn  ro  r   _find_lineno)r   r   source_linesr   s      r1   ry  zDIPDoctestModule.collect.<locals>.MockAwareDocTestFinder._find_linenof  sm     c8,, 4!#vs33C3.. .!.--C ww++   r3   r6   Nc           
          t          |          rd S t                      5  t                                          |||||||           d d d            d S # 1 swxY w Y   d S rU   )r_  rp  r   _find)	r   testsr   rt   modulerz  r~   seenr   s	           r1   r|  z=IPDoctestModule.collect.<locals>.MockAwareDocTestFinder._findz  s     c?? F-//  GGMMsD&,t                   s   (AAAr$  )r   r   r   r   ry  r|  r   r   s   @r1   MockAwareDocTestFinderru  _  sh             (		 	 	 	 	 	 	 	 	 	r3   r  zconftest.pyrj   
importmoderootpath)   r#   Fconsider_namespace_packagesrq   rJ   zunable to import module %r)r5   rF  rG  )r   r   rs  rD  r^   rt   r'  r_   r   _importconftestr}   r  r    ImportErrorr@  rZ  r[  r=  r   r  rA  findr   r   r   re   )r   r   rs  rD  r  r~  kwargsfinderr   r   r   s              r1   r>   zIPDoctestModule.collect[  sn     ========$	 $	 $	 $	 $	] $	 $	 $	L 9>]**a 1$$2BBIK)),77 
 %dk&:;!V++<AF89B2BIK)),77   	 $+"67!V++<AF89$TY99&99   ;''(HII K <ty HIIII JI ('/@/@AAA%d++# NN 8 E E	
 
 
 KK88 	 	D} #//tyt 0     	 	s   0D AEEr   rj   c                 *    t          | j                  S rU   r"  r  s    r1   r^   zIPDoctestModule.path  r#  r3   NrM  r^   c                |    |dd l }|j                            |          } t                      j        d||d|S rO  rP  rQ  s         r1   re   zIPDoctestModule.from_parent  rS  r3   )r   r   r   r
   r   r>   r'  r(  r   r^   r&  r   re   r   r   s   @r1   rZ   rZ   Z  s        R-0 R R R Rh a1		%$ 	% 	% 	% 
	% 

 #'	K 	K 	K
 4.	K 	K 	K 	K 	K 
	K 	K 	K 	K 	K r3   rZ   doctest_itemc                     d
d}i | _         | j        j        }| |dd}t          dk    rd|d<    |j        di || _        t          | d	          }t          dk    r|                                 |S )zIUsed by IPDoctestTextfile and IPDoctestItem to setup fixture information.r6   Nc                      d S rU   r-   r-   r3   r1   rc  z_setup_fixtures.<locals>.func  s    r3   )noderc  r   )r  r   FfuncargsT)	_ispytestr$  r-   )r  r{   _fixturemanagerr'  getfixtureinfo_fixtureinfor   _fillfixtures)r  rc  fmr  r   s        r1   r   r     s        L			-B"D>>F"z 1 1 ! !
! !L %\TBBBO%%'''r3   c                  D    dd l } dd lddlm}  G fdd|          }|S )Nr   r#   r$   c                        e Zd Z                    dj                  Z                    dj                  Z                    dj                  Zde	de	de
def fdZde	de	de	fd	Z xZS )
2_init_checker_class.<locals>.LiteralsOutputCheckerz(\W|^)[uU]([rR]?[\'\"])z(\W|^)[bB]([rR]?[\'\"])a  
            (?P<number>
              (?P<mantissa>
                (?P<integer1> [+-]?\d*)\.(?P<fraction>\d+)
                |
                (?P<integer2> [+-]?\d+)\.
              )
              (?:
                [Ee]
                (?P<exponent1> [+-]?\d+)
              )?
              |
              (?P<integer3> [+-]?\d+)
              (?:
                [Ee]
                (?P<exponent2> [+-]?\d+)
              )
            )
            wantr   r   r6   c                    t                                          |||          rdS |t                      z  }|t                      z  }|t	                      z  }|s|s|sdS dt
          t                   dt          dt          f	fd}|r" || j        |          } || j        |          }|r" || j        |          } || j        |          }|r| 	                    ||          }t                                          |||          S )NTFregexrh   r6   c                 2                         | d|          S )Nz\1\2)sub)r  rh   res     r1   remove_prefixeszX_init_checker_class.<locals>.LiteralsOutputChecker.check_output.<locals>.remove_prefixes  s    vveWc222r3   )
r   check_outputr2  r3  r4  r   rO   _unicode_literal_re_bytes_literal_re_remove_unwanted_precision)
r   r  r   r   allow_unicodeallow_bytesallow_numberr  r   r  s
           r1   r  z?_init_checker_class.<locals>.LiteralsOutputChecker.check_output  sI   ww##D#{;; t'*A*C*CCM%(=(?(??K&)9););;L   \ u3ws| 3# 3# 3 3 3 3 3 3  E&t'?FF%od&>DD C&t'=tDD%od&<cBB A55dC@@77''c;???r3   c                    t          | j                            |                    }t          | j                            |                    }t          |          t          |          k    r|S d}t	          ||          D ]o\  }}|                    d          }|                    d          }	|	|                    d          }	|dnt          |          }
|	|
t          |	          z  }
t          |                                          t          t          |                                          d|
 z            k    r|d |	                                |z            |                                z   ||
                                |z   d          z   }||
                                |	                                z
  |
                                |	                                z
  z
  z  }q|S )Nr   fraction	exponent1	exponent2
   )abs)list
_number_refinditerlenziprR   r.   floatr!   startend)r   r  r   wantsgotsoffsetwgr  exponent	precisions              r1   r  zM_init_checker_class.<locals>.LiteralsOutputChecker._remove_unwanted_precision  s   11$7788E005566D5zzSYY&&
FE4(( J J1*+''**=*=*+''+*>*># ww{33H!)!1AAs8}}	'X.I##veAGGII.>.>B
N'S'S'SSS
 0aggii&001AGGII=AEEGGfDTDVDV@WW  aeegg		1QUUWWqwwyy5HIIFJr3   )r   r   r   compileUNICODEr  r  VERBOSEr  rO   r.   r   r  r  r   )r   r  s   @r1   LiteralsOutputCheckerr    s        
 !jj)CRZPPJJ'A2:NNZZ& J)
 

.	@S 	@s 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@6	3 	S 	S 	 	 	 	 	 	 	 	r3   r  )r   r  r   r%   )r   r%   r  r  s      @r1   _init_checker_classr    so    NNNIII111111O O O O O O O 6 O O Ob ! r3   c                  H    t           t                      a t                      S )a  Return a IPDoctestOutputChecker subclass that supports some
    additional options:

    * ALLOW_UNICODE and ALLOW_BYTES options to ignore u'' and b''
      prefixes (respectively) in string literals. Useful when the same
      ipdoctest should run in Python 2 and Python 3.

    * NUMBER to ignore floating-point differences smaller than the
      precision of the literal number in the ipdoctest.

    An inner class is used to avoid importing "ipdoctest" at the module
    level.
    )r+   r  r-   r3   r1   r  r  2  s     +--??r3   c                  *    ddl }  | j        d          S )z+Register and return the ALLOW_UNICODE flag.r   Nr/  r   register_optionflagr5  s    r1   r2  r2  F  s    NNN&7&777r3   c                  *    ddl }  | j        d          S )z)Register and return the ALLOW_BYTES flag.r   Nr0  r  r5  s    r1   r3  r3  M  s    NNN&7&}555r3   c                  *    ddl }  | j        d          S )z$Register and return the NUMBER flag.r   Nr1  r  r5  s    r1   r4  r4  T  s    NNN&7&x000r3   keyc           
          ddl }t          |j        t          |j        t
          |j        t          |j        t          di|          S )zReturn the actual `ipdoctest` module flag value.

    We want to do it as late as possible to avoid importing `ipdoctest` and all
    its dependencies when parsing options, as it adds overhead and breaks tests.
    r   N)
r   DOCTEST_REPORT_CHOICE_UDIFFREPORT_UDIFFDOCTEST_REPORT_CHOICE_CDIFFREPORT_CDIFFDOCTEST_REPORT_CHOICE_NDIFFREPORT_NDIFF(DOCTEST_REPORT_CHOICE_ONLY_FIRST_FAILUREREPORT_ONLY_FIRST_FAILUREDOCTEST_REPORT_CHOICE_NONE)r  r   s     r1   r  r  [  sH     NNN 	$W%9#W%9#W%90'2S"A 
 r3   r{   )scopec                      t                      S )zcFixture that returns a :py:class:`dict` that will be injected into the
    namespace of ipdoctests.)r   r-   r3   r1   r   r   l  s     66Mr3   r$  r   )r   r   r6   N)r6   r%   )or   r   r   rn  r   r   r   r  r   ri  
contextlibr   pathlibr   typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   rZ  _pytestr   _pytest._code.coder   r   r   _pytest._ior   _pytest.compatr   _pytest.configr   _pytest.config.argparsingr   _pytest.fixturesr   r   r  _pytest.nodesr   _pytest.outcomesr   _pytest.pathlibr   r    _pytest.python_apir!   _pytest.warning_typesr"   r   r   r%   r  r  r  r  r  rQ   rV   r+   r%  tuple__version__r  r'  rS   rW   ri   rl   ro   r   rc   rf   rd   r   rh  r   r   r.   r   Itemr   rO   r6  r=  rA  Moduler[   r   objectr_  rp  rZ   r   r  r  r2  r3  r4  r  fixturer   r-   r3   r1   <module>r     sz   = < < 



   				  



       % % % % % %                                            L L L L L L L L L L & & & & & & ' ' ' ' ' ' ! ! ! ! ! ! , , , , , ,0======= 0 0 0////////0 # # # # # # - - - - - - 3 3 3 3 3 3 3 3 % % % % % % / / / / / / 2NNN111111# % % % +? ( ,  :>x567 > > >LLf.@.F.Fs.K.KLLLMM/V / / / / /d    e:;<   " !q'M11 
%>?	@1 1 1 1 L1 1 1At A A A A A9& 9 9i 9D 9 9 9 9&d &t & & & &
( 
( 
( 
( 
(l 
( 
( 
(! ! ! ! !i ! ! !3D!23 3 3 3 3n 37" $	 ./d^  	
    (u% u% u% u% u%FK u% u% u%p$sCx.         2K 2K 2K 2K 2K 2K 2K 2Kj= = = =F t     %),<"= % % % %:hK hK hK hK hKfm hK hK hKV- N    (V!T":; V! V! V! V!r   (8 8 8 8 86s 6 6 6 61# 1 1 1 1C C    " i   T#s(^    !   s   ?B BB