HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/_pytest/__pycache__/doctest.cpython-310.pyc
o

%we�h�@sUdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl*m,Z,ddl-m.Z.ddl-m/Z/ddl0m1Z1ddl0m2Z2dd l3m4Z4dd!l3m5Z5dd"l6m7Z7dd#l8m9Z9dd$l:m;Z;er�ddl<Z<d%Z=d&Z>d'Z?d(Z@d)ZAe=e>e?e@eAfZBdaCdaDeed*eEd+<d,e)d-dfd.d/�ZFdwd0d1�ZGd2e
d3e.d-eed4fd5d6�ZHd7e
d-eIfd8d9�ZJd:e'd7e
d3e.d-eIfd;d<�ZKd7e
d-eIfd=d>�ZLGd?d@�d@e!�ZMGdAdB�dBeN�ZOd-edCfdDdE�ZP				FdxdGed*dHeeIdIeQdJeId-dCf
dKdL�ZRGdMdN�dNe/�ZSd-eeTeQffdOdP�ZUdQdR�ZVdSdT�ZWGdUdV�dVe7�ZXdydYdZ�ZYd[eZd-eIfd\d]�Z[ed-ed^fd_d`��Z\Gdadb�dbe7�Z]dceSd-e,fddde�Z^d-ed*fdfdg�Z_dzdhdi�Z`d-eQfdjdk�Zad-eQfdldm�Zbd-eQfdndo�ZcdpeTd-eQfdqdr�Zde+dsdt�d-eeTeffdudv��ZedS){z4Discover and run doctests in modules and test files.�N)�contextmanager)�Path)�Any)�Callable)�Dict)�	Generator)�Iterable)�List)�Optional)�Pattern)�Sequence)�Tuple)�Type)�
TYPE_CHECKING)�Union)�outcomes)�
ExceptionInfo)�ReprFileLocation)�TerminalRepr)�TerminalWriter��safe_getattr)�Config)�Parser)�fixture)�FixtureRequest)�	Collector)�Item)�OutcomeException)�skip��
fnmatch_ex)�import_path)�Module)�approx)�
PytestWarning�none�cdiff�ndiff�udiff�only_first_failure�doctest.OutputChecker�
CHECKER_CLASS�parser�returncCs�|jddddgd�|jdddd	�|�d
�}|jddd
ddd�|jdtjddtdd�|jddgdddd�|jddd
ddd�|jddd
d d!d�dS)"N�doctest_optionflagszOption flags for doctests�args�ELLIPSIS)�type�default�doctest_encodingzEncoding used for doctest fileszutf-8)r3�collectz--doctest-modules�
store_trueFzRun doctests in all .py modules�doctestmodules)�actionr3�help�destz--doctest-reportr)z9Choose another output format for diffs on doctest failure�
doctestreport)r2r3r9�choicesr:z--doctest-glob�append�patz2Doctests file matching pattern, default: test*.txt�doctestglob)r8r3�metavarr9r:z--doctest-ignore-import-errorszIgnore doctest ImportErrors�doctest_ignore_import_errorsz--doctest-continue-on-failurez<For a given doctest, continue to run after the first failure�doctest_continue_on_failure)�addini�getgroup�	addoption�str�lower�DOCTEST_REPORT_CHOICES)r-�group�rJ�H/home/arjun/projects/env/lib/python3.10/site-packages/_pytest/doctest.py�pytest_addoptionFs^��
����
�rLcCsdadS�N)�RUNNER_CLASSrJrJrJrK�pytest_unconfigurexsrO�	file_path�parent)�
DoctestModule�DoctestTextfilecCsd|j}|jdkr!|jjrtt|�t|�f�stj||d�}|SdSt	|||�r0t
j||d�}|SdS)Nz.py��path)�config�suffix�optionr7�any�_is_setup_py�_is_main_pyrR�from_parent�_is_doctestrS)rPrQrV�mod�txtrJrJrK�pytest_collect_file~s

��r`rUcCs&|jdkrdS|��}d|vpd|vS)Nzsetup.pyFs
setuptoolss	distutils)�name�
read_bytes)rU�contentsrJrJrKrZ�s
rZrVcs@�jdvr
|j���r
dS|�d�pdg}t�fdd�|D��S)N)z.txtz.rstTr?z	test*.txtc3s�|]}t|��VqdSrMr )�.0�globrTrJrK�	<genexpr>�s�z_is_doctest.<locals>.<genexpr>)rW�session�
isinitpath�	getoptionrY)rVrUrQ�globsrJrTrKr]�sr]cCs
|jdkS)Nz__main__.py)rarTrJrJrKr[�s
r[c@s@eZdZdeeeeefddfdd�Zdeddfdd�Z	dS)	�ReprFailDoctest�reprlocation_linesr.NcCs
||_dSrM)rl)�selfrlrJrJrK�__init__�s
zReprFailDoctest.__init__�twcCs2|jD]\}}|D]}|�|�q	|�|�qdSrM)rl�line�
toterminal)rmro�reprlocation�linesrprJrJrKrq�s
�zReprFailDoctest.toterminal)
�__name__�
__module__�__qualname__rr
rrFrnrrqrJrJrJrKrk�s�
�rkcs*eZdZdedddf�fdd�Z�ZS)�MultipleDoctestFailures�failureszdoctest.DocTestFailurer.Ncst���||_dSrM)�superrnrx�rmrx��	__class__rJrKrn�s

z MultipleDoctestFailures.__init__)rtrurvrrn�
__classcell__rJrJr{rKrw�s"rw�doctest.DocTestRunnercs"ddl�G�fdd�d�j�}|S)Nrcs�eZdZdZ				ddeddeeded	ed
df
�fdd�
Zd
dddded
df�fdd�Z	d
dddde
eeee
jfd
df�fdd�Z�ZS)z/_init_runner_class.<locals>.PytestDoctestRunnerz�Runner to collect failures.

        Note that the out variable in this case is a list instead of a
        stdout-like object.
        NrT�checkerr+�verbose�optionflags�continue_on_failurer.cst�j|||d�||_dS)N)rr�r�)ryrnr�)rmrr�r�r�r{rJrKrn�s
z8_init_runner_class.<locals>.PytestDoctestRunner.__init__�test�doctest.DocTest�examplezdoctest.Example�gotcs&��|||�}|jr|�|�dS|�rM)�DocTestFailurer�r=)rm�outr�r�r��failure��doctestrJrK�report_failure�sz>_init_runner_class.<locals>.PytestDoctestRunner.report_failure�exc_infocsVt|dt�r|d�t|dtj�rt�d���|||�}|jr)|�|�dS|�)N�zQuitting debugger)	�
isinstancer�bdb�BdbQuitr�exit�UnexpectedExceptionr�r=)rmr�r�r�r�r�r�rJrK�report_unexpected_exception�s
zK_init_runner_class.<locals>.PytestDoctestRunner.report_unexpected_exception�NNrT)rtrurv�__doc__r
�bool�intrnrFr�r
r�
BaseException�types�
TracebackTyper�r}rJr�r{rK�PytestDoctestRunner�sF������
����
����r�)r��DebugRunner)r�rJr�rK�_init_runner_class�s/r�Trr�r�r�cCstdurt�at||||d�S)N�rr�r�r�)rNr�r�rJrJrK�_get_runner�s�r�cs�eZdZ		ddedddeddedd	df
�fd
d�
Zedddeddddf�fdd
��Zddd�Zddd�Z	ddd�Z
deed	e
eeff�fdd�Zd	ee
defeeeffdd�Z�ZS)�DoctestItemNrarQz%Union[DoctestTextfile, DoctestModule]�runnerr~�dtestr�r.cs*t��||�||_||_d|_d|_dSrM)ryrnr�r��obj�fixture_request)rmrarQr�r�r{rJrKrn�s

zDoctestItem.__init__cst�j||||d�S)zThe public named constructor.)rarQr�r�)ryr\)�clsrQrar�r�r{rJrKr\szDoctestItem.from_parentcCsZ|jdur+t|�|_t|jjd�}|j�d���D]\}}|||<q|jj�|�dSdS)N)�
getfixture�doctest_namespace)r��_setup_fixturesr��dict�getfixturevalue�itemsrj�update)rmrjra�valuerJrJrK�setups

�
�
�zDoctestItem.setupcCsT|jdusJ�|jdusJ�t|j�|��g}|jj|j|d�|r(t|��dS)N)r�)r�r��_check_all_skipped�$_disable_output_capturing_for_darwin�runrwrzrJrJrK�runtest"s
�zDoctestItem.runtestcCsZt��dkrdS|jj�d�}|r+|jdd�|��\}}tj�	|�tj
�	|�dSdS)zFDisable output capturing. Otherwise, stdout is lost to doctest (#985).�DarwinN�capturemanagerT)�in_)�platform�systemrV�
pluginmanager�	getplugin�suspend_global_capture�read_global_capture�sys�stdout�write�stderr)rm�capmanr��errrJrJrKr�.s�z0DoctestItem._disable_output_capturing_for_darwin�excinfocs�ddl}d}t|j|j|jf�r|jg}n
t|jt�r|jj}|dur)t��|�Sg}|D]�}|j	}|j
��j}�jdur@d}n�j|jd}t
|�j}	t|||	�}
t�}t|j�d��}|dur�|j
jdusjJ�|j
j�d�}
�jdusxJ��fdd�t|
�D�}
|
t|jdd�|jd�}
ndg}
d	}|j��D]}|
�d
|�d|���d}q�t||j�r�|
|�||j|��d
�7}
nt�|j�}|
dt |j�g7}
|
dd�t!j"|j�D�7}
|�|
|
f�q-t#|�S)Nrr�r;Fcs&g|]\}}d|�jd|f�qS)z%03d %sr�)�lineno)rd�i�x�r�rJrK�
<listcomp>`s�z,DoctestItem.repr_failure.<locals>.<listcomp>�	z?EXAMPLE LOCATION UNKNOWN, not showing all tests of that examplez>>>z??? � z...�
zUNEXPECTED EXCEPTION: %scSsg|]}|�d��qS)r�)�strip�rdr�rJrJrKr�ts
�)$r�r�r�r�r�rwrxry�repr_failurer�r��filenamer�r2rtr�_get_checker�_get_report_choicerVri�	docstring�
splitlines�	enumerate�max�sourcer=�output_differencer��splitr�
from_exc_infor��repr�	traceback�format_exceptionrk)rmr�r�rxrlr�r�r�r��messagerrr�
report_choicers�indentrp�
inner_excinfor{r�rKr�:sd��



� ���
�zDoctestItem.repr_failurezos.PathLike[str]cCs$|jdusJ�|j|jjd|jfS)Nz[doctest] %s)r�rUr�ra)rmrJrJrK�
reportinfozszDoctestItem.reportinfo)NN�r.N)rtrurvrFr
rn�classmethodr\r�r�r�rr�rrr�r
r�r�r}rJrJr{rKr��sB������
����



�
�,@r�cCs4ddl}t|j|j|j|j|j|jt�t	�t
�d�	S)Nr)	�DONT_ACCEPT_TRUE_FOR_1�DONT_ACCEPT_BLANKLINE�NORMALIZE_WHITESPACEr1�IGNORE_EXCEPTION_DETAIL�COMPARISON_FLAGS�
ALLOW_UNICODE�ALLOW_BYTES�NUMBER)r�r�r�r�r�r1r�r��_get_allow_unicode_flag�_get_allow_bytes_flag�_get_number_flagr�rJrJrK�_get_flag_lookups�r�cCs0|j�d�}t�}d}|D]}|||O}q
|S)Nr/r)rV�getinir�)rQ�optionflags_str�flag_lookup_table�flag_acc�flagrJrJrK�get_optionflags�sr�cCs |�d�}|r|�d�rd}|S)NrB�usepdbF)�getvalue)rVr�rJrJrK�_get_continue_on_failure�s


r�c@s"eZdZdZdeefdd�ZdS)rSNr.ccs��ddl}|j�d�}|j�|�}t|j�}|jj}ddi}t|�}td|t	�t
|j�d�}|��}	|	�||||d�}
|
j
rKtj||
j||
d�VdSdS)Nrr4rt�__main__F�r�r�rr��rar�r�)r�rVr�rU�	read_textrFrar�r�r�r��
DocTestParser�get_doctest�examplesr�r\)rmr��encoding�textr�rarjr�r�r-r�rJrJrKr5�s*�
�
��zDoctestTextfile.collect)rtrurvr�rr�r5rJrJrJrKrS�srSr�r�cs4ddl�t�fdd�|jD��}|rtd�dSdS)zVRaise pytest.skip() if all examples in the given DocTest have the SKIP
    option set.rNc3s �|]}|j��jd�VqdS)FN)�options�get�SKIPr�r�rJrKrf�s�z%_check_all_skipped.<locals>.<genexpr>z!all tests skipped by +SKIP option)r��allr�r)r��all_skippedrJr�rKr��s
�r�r�cCst|dd�duS)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�rJrJrK�
_is_mocked�s
��r	)NNNc#s`�tj�dd�dtdtfdtttgtfdtf�fdd�}|t_z	dVW�t_dS�t_w)	z�Context manager which replaces ``inspect.unwrap`` with a version
    that's aware of mock objects and doesn't recurse into them.N��stop�func.rr.c
sjz|dus	|tur��td�WS|�����fdd�d�WSty4}zt�d|�ft��d}~ww)Nr
cst|�p���SrM)r	r��_stoprrJrK�<lambda>�szF_patch_unwrap_mock_aware.<locals>._mock_aware_unwrap.<locals>.<lambda>z�Got %r when unwrapping %r.  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%)rr�e��real_unwrapr
rK�_mock_aware_unwrap�s����z4_patch_unwrap_mock_aware.<locals>._mock_aware_unwrap)�inspect�unwraprrr
)rrJrrK�_patch_unwrap_mock_aware�s��
���rc@seZdZdeefdd�ZdS)rRr.ccs��ddl}Gdd�d|j�}|jjdkr&|jjj|j|j�d�|jjd�}n)zt	|j|jj|j�d�d�}Wnt
yN|j�d�rKtd	|j�n�Ynw|�}t
|�}td
|t�t|j�d�}|�||j�D]}|jrytj||j||d�VqidS)
NrcsReZdZdZ�fdd�Z		d�fdd�Zejdkr$�fd	d
�Z�Z	S	�Z	S)z5DoctestModule.collect.<locals>.MockAwareDocTestFinderz�A hackish doctest finder that overrides stdlib internals to fix a stdlib bug.

            https://github.com/pytest-dev/pytest/issues/3456
            https://bugs.python.org/issue25532
            cs8t|t�rt|d|�}t|d�rt�|�}t��||�S)a3Doctest 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��property�getattr�hasattrrrry�_find_lineno)rmr��source_linesr{rJrKr�s


�zBDoctestModule.collect.<locals>.MockAwareDocTestFinder._find_linenor.Nc
sPt|�rdSt��t��|||||||�Wd�dS1s!wYdSrM)r	rry�_find)rm�testsr�ra�moduler rj�seenr{rJrKr!s�"�z;DoctestModule.collect.<locals>.MockAwareDocTestFinder._find)��
cs*ttd�rt|tj�r|j}t��||�S)a>`cached_property` objects are never considered a part
                    of the 'current module'. As such they are skipped by doctest.
                    Here we override `_from_module` to check the underlying
                    function instead. https://github.com/python/cpython/issues/107995
                    �cached_property)r�	functoolsr�r'rry�_from_module)rmr#�objectr{rJrKr)s
�zBDoctestModule.collect.<locals>.MockAwareDocTestFinder._from_moduler�)
rtrurvr�rr!r��version_infor)r}rJrJr{rK�MockAwareDocTestFinder�s�

r,zconftest.py�
importmode)�rootpath)�root�moderAzunable to import module %rFr�r�)r��
DocTestFinderrUrarVr��_importconftestrir.r"�ImportErrorr�rr�r�r�r��findrtr�r�r\)rmr�r,r#�finderr�r�r�rJrJrKr5�sH�9
�

����
���zDoctestModule.collectN)rtrurvrr�r5rJrJrJrKrR�srR�doctest_itemcCsDd	dd�}i|_|jj}|j||ddd�|_t|dd�}|��|S)
zEUsed by DoctestTextfile and DoctestItem to setup fixture information.r.NcSsdSrMrJrJrJrJrKrUsz_setup_fixtures.<locals>.funcF)�noderr��funcargsT)�	_ispytestr�)r8rg�_fixturemanager�getfixtureinfo�_fixtureinfor�
_fillfixtures)r6r�fmr�rJrJrKr�Rs
�r�cs*ddl}ddl�G�fdd�d|j�}|S)NrcspeZdZ��d�j�Z��d�j�Z��d�j�Zde	de	de
def��fdd	�Zde	de	de	fd
d�Z
�ZS)z2_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�r.cs�t��|||�r
dS|t�@}|t�@}|t�@}|s!|s!|s!dSdttdtdtf�fdd�}|r>||j|�}||j|�}|rL||j|�}||j|�}|rT|�	||�}t��|||�S)NTF�regexr_r.cs��|d|�S)Nz\1\2)�sub)r@r_��rerJrK�remove_prefixes�szX_init_checker_class.<locals>.LiteralsOutputChecker.check_output.<locals>.remove_prefixes)
ry�check_outputr�r�r�rrF�_unicode_literal_re�_bytes_literal_re�_remove_unwanted_precision)rmr?r�r��
allow_unicode�allow_bytes�allow_numberrD)r|rCrJrKrE�s"


z?_init_checker_class.<locals>.LiteralsOutputChecker.check_outputcSst|j�|��}t|j�|��}t|�t|�kr|Sd}t||�D]h\}}|�d�}|�d�}	|	dur8|�d�}	|dur>dnt|�}
|	durL|
t|	�8}
t|���tt|���d|
d�kr�|d|�	�|�|��||�
�|d�}||�
�|�	�|�
�|�	�7}q!|S)Nr�fraction�	exponent1�	exponent2�
)�abs)�list�
_number_re�finditer�len�ziprIr��floatr$�start�end)rmr?r��wants�gots�offset�w�grL�exponent�	precisionrJrJrKrH�s&


&.�$�zM_init_checker_class.<locals>.LiteralsOutputChecker._remove_unwanted_precision)rtrurv�compile�UNICODErFrG�VERBOSErRrFr�r�rErHr}rJrBr{rK�LiteralsOutputCheckerfs� rc)r�rC�
OutputChecker)r�rcrJrBrK�_init_checker_classbsQrecCstdurt�at�S)a�Return a doctest.OutputChecker 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
      doctest should run in Python 2 and Python 3.

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

    An inner class is used to avoid importing "doctest" at the module
    level.
    N)r,rerJrJrJrKr��sr�cC�ddl}|�d�S)z+Register and return the ALLOW_UNICODE flag.rNr��r��register_optionflagr�rJrJrKr���
r�cCrf)z)Register and return the ALLOW_BYTES flag.rNr�rgr�rJrJrKr��rir�cCrf)z$Register and return the NUMBER flag.rNr�rgr�rJrJrKr��rir��keyc
Cs,ddl}t|jt|jt|jt|jt	di|S)z�Return the actual `doctest` module flag value.

    We want to do it as late as possible to avoid importing `doctest` and all
    its dependencies when parsing options, as it adds overhead and breaks tests.
    rN)
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)rjr�rJrJrKr��s��r�rg)�scopecCst�S)a�Fixture that returns a :py:class:`dict` that will be injected into the
    namespace of doctests.

    Usually this fixture is used in conjunction with another ``autouse`` fixture:

    .. code-block:: python

        @pytest.fixture(autouse=True)
        def add_np(doctest_namespace):
            doctest_namespace["np"] = numpy

    For more details: :ref:`doctest_namespace`.
    )r�rJrJrJrKr��sr�r�r�)r�r�r.N)r.r+)fr�r�r(r�osr�r�r�r�r�
contextlibr�pathlibr�typingrrrrrr	r
rrr
rrr�_pytestr�_pytest._code.coderrr�_pytest._ior�_pytest.compatr�_pytest.configr�_pytest.config.argparsingr�_pytest.fixturesrr�
_pytest.nodesrr�_pytest.outcomesrr�_pytest.pathlibr!r"�_pytest.pythonr#�_pytest.python_apir$�_pytest.warning_typesr%r�rsrmrorkrqrHrNr,�__annotations__rLrOr`r�rZr]r[rkrrwr�r�r�r�rFr�r�r�rSr�r*r	rrRr�rer�r�r�r�r�r�rJrJrJrK�<module>s��	
2��

�
6�����
�	


	`
X