§
    �Ÿji.  ã                   ó.  — d Z ddlZddlZddlZddlmZ  ej        e¦  «        Z G d„ dej	        ¦  «        Z	 G d„ dej
        ¦  «        Z G d„ d	ej        ¦  «        Z G d
„ dej        ¦  «        Z ej        d¦  «        Z G d„ dej        e¦  «        ZdS )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                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )ÚDocTestFinderc                 óÎ   •— t          ¦   «                              |||||¦  «        }t          t          |dd¦  «        ¦  «        r |�|j        D ]}d|j        t          j        <   Œ|S )NÚ__skip_doctest__FT)ÚsuperÚ	_get_testÚboolÚgetattrÚexamplesÚoptionsÚdoctestÚSKIP)	ÚselfÚobjÚnameÚmoduleÚglobsÚsource_linesÚtestÚexampleÚ	__class__s	           €úm/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/testing/plugin/ipdoctest.pyr	   zDocTestFinder._get_test)   sk   ø€ Ý‰wŒw× Ò   d¨F°E¸<ÑHÔHˆå•˜Ð/°Ñ7Ô7Ñ8Ô8ð 	5¸TÐ=MØœ=ð 5ð 5�Ø04�”¥¤Ñ-Ð-àˆó    )Ú__name__Ú
__module__Ú__qualname__r	   Ú__classcell__©r   s   @r   r   r   (   s8   ø€ € € € € ðð ð ð ð ð ð ð ð r   r   c                   ó8   — e Zd ZdZ ej        d¦  «        Zd„ ZdS )ÚIPDoctestOutputCheckerzÈSecond-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                 ó†   — t           j                             | |||¦  «        }|s| j                             |¦  «        rdS |S )z½Check 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$   z#IPDoctestOutputChecker.check_output<   sN   € õ Ô#×0Ò0°°t¸SØ1<ñ>ô >ˆàð 	�t”~×,Ò,¨TÑ2Ô2ð 	à�4àˆ
r   N)r   r   r   Ú__doc__ÚreÚcompiler%   r$   © r   r   r!   r!   3   sA   € € € € € ðð ð �”
Ð+Ñ,Ô,€Iðð ð ð ð r   r!   c                   ó   — e Zd ZdS )Ú	IPExampleN)r   r   r   r.   r   r   r0   r0   O   s   € € € € € € € r   r0   c                   óö   — e Zd ZdZdZdZdZdZdZ e	j
        eeeeefz  e	j        e	j        z  ¦  «        Z e	j
        eeeeefz  e	j        e	j        z  ¦  «        Z e	j
        d¦  «        Zd„ Zdd
„Zdd„Zd„ ZdS )Ú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                 óÂ   — t           j                             |¦  «        }t          |                     ¦   «         ¦  «        dk    rt                                |¦  «        S |S )z/Convert input IPython source into valid Python.é   )Ú_ipÚinput_transformer_managerÚtransform_cellÚlenÚ
splitlinesÚ	prefilter)r   ÚsourceÚblocks      r   Úip2pyzIPDocTestParser.ip2py   sN   € åÔ-×<Ò<¸VÑDÔDˆÝˆu×ÒÑ!Ô!Ñ"Ô" aÒ'Ð'Ý—=’= Ñ'Ô'Ð'àˆLr   ú<string>c                 óˆ  ‡— |                      ¦   «         }|                      |¦  «        Š‰dk    r4d                     ˆfd„|                     d¦  «        D ¦   «         ¦  «        }g }d\  }}| j                             |¦  «        rd}nd}d}t          | j                             |¦  «        ¦  «        }|rt          j
        }	n0t          | j                             |¦  «        ¦  «        }t          }	d}|D �].}
|                     |||
                     ¦   «         …         ¦  «         ||                     d||
                     ¦   «         ¦  «        z  }|                      |
|||¦  «        \  }}}}||z  }|                      |¦  «        sG|                      |	||||‰t%          |
                     d	¦  «        ¦  «        z   |¬
¦  «        ¦  «         ||                     d|
                     ¦   «         |
                     ¦   «         ¦  «        z  }|
                     ¦   «         }�Œ0|                     ||d…         ¦  «         |S )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.
        r   ú
c                 ó$   •— g | ]}|‰d …         ‘ŒS ©Nr.   )Ú.0ÚlÚ
min_indents     €r   ú
<listcomp>z)IPDocTestParser.parse.<locals>.<listcomp>–   s!   ø€ ÐKÐKÐK°1  * + +¤ÐKÐKÐKr   )r   r   z	
# randomÚ FTÚindent)ÚlinenorH   r   N)Ú
expandtabsÚ_min_indentÚjoinÚsplitÚ_RANDOM_TESTr&   ÚlistÚ_EXAMPLE_RE_PYÚfinditerr   ÚExampleÚ_EXAMPLE_RE_IPr0   ÚappendÚstartÚcountÚ_parse_exampleÚ_IS_BLANK_OR_COMMENTr8   ÚgroupÚend)r   Ústringr   ÚoutputÚcharnorI   Úrandom_markerr=   ÚtermsrR   Úmr;   r   r'   Úexc_msgrE   s                  @r   ÚparsezIPDocTestParser.parse‡   sE  ø€ ð ×"Ò"Ñ$Ô$ˆà×%Ò% fÑ-Ô-ˆ
Ø˜Š>ˆ>Ø—Y’YÐKÐKÐKÐK¸¿ºÀTÑ8JÔ8JÐKÑKÔKÑLÔLˆFàˆØ‰ˆ�ð Ô×#Ò# FÑ+Ô+ð 	Ø(ˆMˆMàˆMð ˆõ �TÔ(×1Ò1°&Ñ9Ô9Ñ:Ô:ˆØð 	å”oˆGˆGõ ˜Ô,×5Ò5°fÑ=Ô=Ñ>Ô>ˆEÝˆGØˆEàð 	ñ 	ˆAà�MŠM˜& ¨¯ª©	¬	Ð!1Ô2Ñ3Ô3Ð3à�f—l’l 4¨°·²±´Ñ;Ô;Ñ;ˆFð ×(Ò(¨¨D°&¸Ñ?Ô?ñ -ˆV�W˜d Gð
 �MÑ!ˆDð ×,Ò,¨VÑ4Ô4ð 8Ø—’˜g˜g f¨d°GØ-3Ø-7½¸A¿GºGÀHÑ<MÔ<MÑ8NÔ8NÑ-NØ.5ð7ñ 7ô 7ñ 8ô 8ð 8ð
 �f—l’l 4¨¯ª©¬°A·E²E±G´GÑ<Ô<Ñ<ˆFà—U’U‘W”WˆF‰Fà�Š�f˜V˜W˜W”oÑ&Ô&Ð&Øˆr   Fc           	      ó.  ‡‡— t          |                     d¦  «        ¦  «        Š|                     d¦  «                             d¦  «        }|                     d¦  «        }|                     d¦  «        }t          |¦  «        Š|                      |‰||‰¦  «         |r&|                      |dd…         d‰z  |z   ||¦  «         d                     ˆˆfd	„|D ¦   «         ¦  «        }|r|                      |¦  «        }|                     d
¦  «        }	|	                     d¦  «        }
t          |
¦  «        dk    rt          j        d|
d         ¦  «        r|
d= |                      |
d‰z  ||t          |¦  «        z   ¦  «         t          j	        dd|
d         ¦  «        |
d<   d                     ˆfd„|
D ¦   «         ¦  «        }	| j
                             |	¦  «        }|r|                     d¦  «        }nd}|                      |||¦  «        }|||	|fS )a7  
        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.
        rH   r;   r@   Úps1Úps2r4   Nú c                 ó0   •— g | ]}|‰‰z   d z   d…         ‘ŒS )r4   Nr.   )rC   ÚslrH   Úps1_lens     €€r   rF   z2IPDocTestParser._parse_example.<locals>.<listcomp>ë   s-   ø€ ÐIÐIÐI°b˜B˜v g™~¨aÑ/Ð0Ð0Ô1ÐIÐIÐIr   r'   z *$éÿÿÿÿzOut\[\d+\]: \s*?\n?rG   r   c                 ó$   •— g | ]}|‰d …         ‘ŒS rB   r.   )rC   ÚwlrH   s     €r   rF   z2IPDocTestParser._parse_example.<locals>.<listcomp>þ   s!   ø€ Ð;Ð;Ð;¨"˜"˜V˜W˜Wœ+Ð;Ð;Ð;r   Úmsg)r8   rY   rM   Ú_check_prompt_blankÚ_check_prefixrL   r=   r,   ÚmatchÚsubÚ_EXCEPTION_REÚ_find_options)r   r`   r   rI   r=   r   rd   re   r;   r'   Ú
want_linesra   r   rH   ri   s                @@r   rW   zIPDocTestParser._parse_exampleË   s!  øø€ õ" �Q—W’W˜XÑ&Ô&Ñ'Ô'ˆð —w’w˜xÑ(Ô(×.Ò.¨tÑ4Ô4ˆð �gŠg�e‰nŒnˆØ�gŠg�e‰nŒnˆÝ�c‘(”(ˆà× Ò  ¨v°t¸VÀGÑLÔLÐLØð 	QØ×Ò˜|¨A¨B¨BÔ/°°V±¸cÑ1AÀ4ÈÑPÔPÐPà—’ÐIÐIÐIÐIÐI¸LÐIÑIÔIÑJÔJˆàð 	(à—Z’Z Ñ'Ô'ˆFð
 �wŠw�v‰ŒˆØ—Z’Z Ñ%Ô%ˆ
Ýˆz‰?Œ?˜QÒÐ¥2¤8¨F°J¸r´NÑ#CÔ#CÐØ˜2�Ø×Ò˜: s¨6¡z°4Ø!¥C¨Ñ$5Ô$5Ñ5ñ	7ô 	7ð 	7õ œÐ5°b¸ÀA¼ÑGÔGˆ
�1‰à�yŠyÐ;Ð;Ð;Ð;°
Ð;Ñ;Ô;Ñ<Ô<ˆð Ô×$Ò$ TÑ*Ô*ˆØð 	Ø—g’g˜e‘n”nˆGˆGàˆGð ×$Ò$ V¨T°6Ñ:Ô:ˆà�w  gÐ-Ð-r   c                 óÔ   — ||z   }|dz   }t          |¦  «        D ]M\  }}	t          |	¦  «        |k    r5|	|         dk    r)t          d||z   dz   ›d|›d|	||…         ›d|	›�¦  «        ‚ŒNdS )a¤  
        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.
        r4   rf   zline z of the docstring for z lacks blank after z: N)Ú	enumerater8   Ú
ValueError)
r   ÚlinesrH   r   rI   ri   Ú	space_idxÚmin_lenÚiÚlines
             r   rn   z#IPDocTestParser._check_prompt_blank  s¨   € ð ˜7‘Nˆ	Ø˜A‘+ˆÝ  Ñ'Ô'ð 	Að 	A‰GˆAˆtÝ�4‰yŒy˜WÒ$Ð$¨¨i¬¸CÒ)?Ð)?Ý �jà"(¨¡(¨1¡* * *¨d¨d¨dØ"& v¨iÐ'7Ô"8Ð"8Ð"8¸$¸$ð"@ñ Aô Að Aøð	Að 	Ar   N)r>   )F)r   r   r   r+   Ú_PS1_PYÚ_PS2_PYÚ_PS1_IPÚ_PS2_IPÚ_RE_TPLr,   r-   Ú	MULTILINEÚVERBOSErP   rS   rN   r=   rb   rW   rn   r.   r   r   r2   r2   R   s  € € € € € ðð ð €GØ€Gà€GØ€Gð€Gð  �R”Z ¨G°G¸GÀGÐ+LÑ!LØ!#¤°´
Ñ!:ñ<ô <€Nð  �R”Z ¨G°G¸GÀGÐ+LÑ!LØ!#¤°´
Ñ!:ñ<ô <€Nð �2”:Ð2Ñ3Ô3€Lðð ð ðBð Bð Bð BðH?.ð ?.ð ?.ð ?.ðBAð Að Að Að Ar   r2   r   c                   ó$   ‡ — e Zd ZdZdˆ fd„	Zˆ xZS )ÚIPDocTestRunnerzKTest runner that synchronizes the IPython namespace with test globals.
    NTc                 ó²   •— t          dddœ¦  «        5  t          t          | ¦  «                             ||||¦  «        cd d d ¦  «         S # 1 swxY w Y   d S )NÚ80Ú24)ÚCOLUMNSÚLINES)r   r   r…   Úrun)r   r   ÚcompileflagsÚoutÚclear_globsr   s        €r   r‹   zIPDocTestRunner.run'  s¹   ø€ å d°TÐ:Ð:Ñ;Ô;ð 	Qð 	QÝ�¨Ñ.Ô.×2Ò2°4Ø3?ÀÀKñQô Qð	Qð 	Qð 	Qð 	Qñ 	Qô 	Qð 	Qð 	Qð 	Qð 	Qð 	Qð 	Qøøøð 	Qð 	Qð 	Qð 	Qð 	Qð 	Qs   ”+AÁAÁA)NNT)r   r   r   r+   r‹   r   r   s   @r   r…   r…   #  sQ   ø€ € € € € ðð ðQð Qð Qð Qð Qð Qð Qð Qð Qð Qr   r…   )r+   r   Úloggingr,   Útestpathr   Ú	getLoggerr   Úlogr   r#   r!   rR   r0   ÚDocTestParserr2   Úregister_optionflagr   ÚDocTestRunnerÚobjectr…   r.   r   r   ú<module>r—      s_  ððð ð* €€€Ø €€€Ø 	€	€	€	à !Ð !Ð !Ð !Ð !Ð !ð €gÔ˜Ñ!Ô!€ðð ð ð ð �GÔ)ñ ô ð ðð ð ð ð ˜WÔ2ñ ô ð ð8 'Ð &Ð &Ð &Ð &�”Ñ &Ô &Ð &ðKAð KAð KAð KAð KA�gÔ+ñ KAô KAð KAð\ #€wÔ" 6Ñ*Ô*€ðQð Qð Qð Qð Q�gÔ+¨Fñ Qô Qð Qð Qð Qr   