wL ii.FdZddlZddlZddlZddlmZej eZGddejZ GddejZ Gdd ejZ Gd d ejZej d ZGd dej$Zy)aNose 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_envceZdZfdZxZS) DocTestFinderct||||||}tt|ddr0|.|jD]}d|j t j<!|S)N__skip_doctest__FT)super _get_testboolgetattrexamplesoptionsdoctestSKIP) selfobjnamemoduleglobs source_linestestexample __class__s f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/IPython/testing/plugin/ipdoctest.pyr zDocTestFinder._get_test)s]w dFE<H /7 8T=M== 504 - 5 )__name__ __module__ __qualname__r __classcell__rs@rrr(s rrc:eZdZdZej dZdZy)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+ctjj||||}|s|jj |ry|S)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_research)rwantgot optionflagsrets rr$z#IPDoctestOutputChecker.check_output<s?##00tS1<>t~~,,T2 rN)rrr__doc__recompiler%r$rrr!r!3s  +,Irr!c eZdZy) IPExampleN)rrrr.rrr0r0Osrr0c(eZdZdZdZdZdZdZdZe jeeeeefze je jzZ e jeeeeefze je jzZe jdZdZd d Zdd Zd Zy )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 (?:^(?P [ ]*) (?P %s) .*) # PS1 line (?:\n [ ]* (?P %s) .*)*) # PS2 lines \n? # a newline # Want consists of any non-blank lines that do not start with PS1. (?P (?:(?![ ]*$) # 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+ctjj|}t|j dk(rtj |S|S)z/Convert input IPython source into valid Python.)_ipinput_transformer_managertransform_celllen splitlines prefilter)rsourceblocks rip2pyzIPDocTestParser.ip2pysB--<YY T8JK1*+KLF    # #F +(MMT((11&9: ooG,,55f=>EGE A MM& 2 3 fll4; ;F((D&? -VWdG M !D,,V4 gfdG-3-7AGGH)F)rrrr+_PS1_PY_PS2_PY_PS1_IP_PS2_IP_RE_TPLr,r- MULTILINEVERBOSErIrLrGr=r]rPrdr.rrr2r2RsGGGG G RZZGGGG+L!L!# !:rs* ! g!G))W228'&KAg++KA\#w""6*Qg++Qr