wL iltdZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl mZd ad Zd Zd Zy) aGlobal IPython app to support test running. We must start our own ipython object and heavily muck with it so that all the modifications IPython makes to system behavior don't send the doctest machinery into a fit. This code should be considered a gross hack, but it gets the job done. N)Path)tools)page)io)TerminalInteractiveShellctS)N) start_ipythona/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/IPython/testing/globalipapp.py get_ipythonrs ?r ct|j|ddjdtjtjj y)zFReplace the default system call with a capturing one for doctest. Fr)splitdepth)endfileN)print getoutputrstripsysstdoutflush)selfcmds r xsysr"s<  $..E. 3 : : <"3::VJJr clt|jj|tjy)zDPrint the traceback purely on stdout for doctest to capture it. )rN)r InteractiveTBstb2textrr)retypeevaluestbs r _showtracebackr$+s# $   % %c *.nopagejs# eT "99\2.5 e r )rrN) hasattrr r&r displayhook excepthookmodulesr,rdefault_configr simple_promptinstance tempfilesappendrHistoryManager hist_file builtin_trapactivatetypes MethodTypersystemr$r builtin_mod_ipipr pager_page orig_page) _displayhook _excepthook_mainr(shellrCr1s r r r 1s8 }./#'M ??L..K KKOOJ 'E ! ! #F48F##1 % - -V 0E  OO4 5 5 ? ?@A ! ##D%0EL ++NEBE $CKK "CO CN C//KKOKN)K __DNDO Jr )__doc__builtinsrBrr?pathlibrrr IPython.corer IPython.utilsr!IPython.terminal.interactiveshellrrrr$r r r r rQs9 F= Ar