'L i@ndZddlmZddlZddlmZddlZddlZddlm Z ddlm Z ddlm Z ddl m Z dd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl m#Z#ddl$m%Z%ddl$m&Z&ddl$m'Z'ddl(m)Z)ddl*m+Z+e rddl,Z,e GddZ-GddZ.e ej^Gd d!Z0Gd"d#Z1d3d$Z2d4d%Z3d5d&Z4d6d'Z5d6d(Z6d7d)Z7d8d*Z8d9d+Z9d:d,Z:d;d-Z;ed./dd2Z>y)?z?Add backward compatibility support for the legacy py path type.) annotationsN)Path)Final)final) TYPE_CHECKING)SectionWrapper)Cache) LEGACY_PATH legacy_path)Config)hookimpl)PytestPluginManager)check_ispytest)fixture)FixtureRequest)Session) MonkeyPatch) Collector)Item)Node) HookRecorder)Pytester) RunResult)TerminalReporter)TempPathFactorycReZdZUdZdZej Zded<ejZded<ddd9dZ e d:dZ e d:d Z e d Z e d Zejd Ze d;d ZddZd:dZd:dZd:dZd?d=dZd:dZd:dZd?d:dZd@dZdZ dAdZ!d Z"d!Z#d"Z$d#dd$dBd%Z%dCd&Z&dCd'Z'dDd(Z(dDd)Z)dEd*Z*d+Z+dFd,Z,dGd-Z-e.j^e.j^efd.Z0ded/dCd0Z1dCd1Z2d2Z3dd3dCd4Z4dHdId5Z5dHdJd6Z6dKd7Z7dKd8Z8y)LTestdirz Similar to :class:`Pytester`, but this class works with legacy legacy_path objects instead. All methods just forward to an internal :class:`Pytester` instance, converting results to `legacy_path` objects as necessary. Fr CLOSE_STDINTimeoutExpired _ispytestc(t|||_yN)r _pytester)selfpytesterr"s X/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/_pytest/legacypath.py__init__zTestdir.__init__7sy!!c@t|jjS)z-Temporary directory where tests are executed.)r r%pathr&s r(tmpdirzTestdir.tmpdir;s4>>..//r*c@t|jjSr$)r r% _test_tmprootr-s r( test_tmprootzTestdir.test_tmproot@s4>>7788r*c.|jjSr$)r%_requestr-s r(requestzTestdir.requestDs~~&&&r*c.|jjSr$r%pluginsr-s r(r7zTestdir.pluginsHs~~%%%r*c&||j_yr$r6)r&r7s r(r7zTestdir.pluginsLs!(r*c.|jjSr$)r% _monkeypatchr-s r( monkeypatchzTestdir.monkeypatchPs~~***r*c8|jj|S)z(See :meth:`Pytester.make_hook_recorder`.)r%make_hook_recorder)r& pluginmanagers r(r=zTestdir.make_hook_recorderTs~~00??r*c6|jjS)zSee :meth:`Pytester.chdir`.)r%chdirr-s r(r@z Testdir.chdirXs~~##%%r*c6|jjSr$)r% _finalizer-s r(finalizezTestdir.finalize\s~~''))r*c|r|jdsd|z}t|jj|g|i|S)zSee :meth:`Pytester.makefile`..) startswithr r%makefile)r&extargskwargss r(rGzTestdir.makefile_sB s~~c*)C24>>223HHHIIr*cJt|jj|S)z"See :meth:`Pytester.makeconftest`.)r r% makeconftestr&sources r(rLzTestdir.makeconftestks4>>66v>??r*cJt|jj|S)zSee :meth:`Pytester.makeini`.)r r%makeinirMs r(rPzTestdir.makeinios4>>11&9::r*c8|jj|S)zSee :meth:`Pytester.getinicfg`.)r% getinicfgrMs r(rRzTestdir.getinicfgs~~''//r*cJt|jj|S)z'See :meth:`Pytester.makepyprojecttoml`.)r r%makepyprojecttomlrMs r(rUzTestdir.makepyprojecttomlws4>>;;FCDDr*cLt|jj|i|S)z See :meth:`Pytester.makepyfile`.)r r% makepyfiler&rIrJs r(rWzTestdir.makepyfile{s$44>>44dEfEFFr*cLt|jj|i|S)z!See :meth:`Pytester.maketxtfile`.)r r% maketxtfilerXs r(rZzTestdir.maketxtfiles$54>>55tFvFGGr*Nc8|jj|S)z#See :meth:`Pytester.syspathinsert`.)r% syspathinsertr&r,s r(r\zTestdir.syspathinserts~~++D11r*cJt|jj|S)zSee :meth:`Pytester.mkdir`.)r r%mkdirr&names r(r_z Testdir.mkdirs4>>//566r*cJt|jj|S)zSee :meth:`Pytester.mkpydir`.)r r%mkpydirr`s r(rczTestdir.mkpydirs4>>11$788r*cJt|jj|S)z"See :meth:`Pytester.copy_example`.)r r% copy_exampler`s r(rezTestdir.copy_examples4>>66t<==r*c:|jj||S)zSee :meth:`Pytester.getnode`.)r%getnode)r&configargs r(rgzTestdir.getnodes~~%%fc22r*c8|jj|S)z!See :meth:`Pytester.getpathnode`.)r% getpathnoder]s r(rkzTestdir.getpathnodes~~))$//r*c8|jj|S)zSee :meth:`Pytester.genitems`.)r%genitems)r&colitemss r(rmzTestdir.genitemss~~&&x00r*c8|jj|S)zSee :meth:`Pytester.runitem`.)r%runitemrMs r(rpzTestdir.runitems~~%%f--r*c<|jj|g|S)z&See :meth:`Pytester.inline_runsource`.)r%inline_runsource)r&rN cmdlineargss r(rrzTestdir.inline_runsources.t~~..vD DDr*c4|jj|S)z%See :meth:`Pytester.inline_genitems`.)r%inline_genitemsr&rIs r(ruzTestdir.inline_genitemss-t~~--t44r*r7no_reraise_ctrlcc<|jj|||dS)z See :meth:`Pytester.inline_run`.rx)r% inline_run)r&r7ryrIs r(r{zTestdir.inline_runs#(t~~(( 75E  r*c:|jj|i|S)z)See :meth:`Pytester.runpytest_inprocess`.)r%runpytest_inprocessrXs r(r}zTestdir.runpytest_inprocesss1t~~114B6BBr*c:|jj|i|S)zSee :meth:`Pytester.runpytest`.)r% runpytestrXs r(rzTestdir.runpytests't~~''888r*c4|jj|S)z!See :meth:`Pytester.parseconfig`.)r% parseconfigrvs r(rzTestdir.parseconfigs)t~~))400r*c4|jj|S)z$See :meth:`Pytester.parseconfigure`.)r%parseconfigurervs r(rzTestdir.parseconfigures,t~~,,d33r*c:|jj||S)zSee :meth:`Pytester.getitem`.)r%getitem)r&rNfuncnames r(rzTestdir.getitems~~%%fh77r*c8|jj|S)zSee :meth:`Pytester.getitems`.)r%getitemsrMs r(rzTestdir.getitemss~~&&v..r*c>|jj|||S)z"See :meth:`Pytester.getmodulecol`.) configargswithinit)r% getmodulecol)r&rNrrs r(rzTestdir.getmodulecols%~~** zH+  r*c:|jj||S)z%See :meth:`Pytester.collect_by_name`.)r%collect_by_name)r&modcolras r(rzTestdir.collect_by_names~~--fd;;r*c B|jj||||fi|S)zSee :meth:`Pytester.popen`.)r%popen)r&cmdargsstdoutstderrstdinkws r(rz Testdir.popens&$t~~##GVVUIbIIr*timeoutrc<|jj|||dS)zSee :meth:`Pytester.run`.r)r%run)r&rrrs r(rz Testdir.runs!t~~!!7G5IIr*c8|jj|S)zSee :meth:`Pytester.runpython`.)r% runpython)r&scripts r(rzTestdir.runpythonrSr*c8|jj|S)z!See :meth:`Pytester.runpython_c`.)r% runpython_c)r&commands r(rzTestdir.runpython_cs~~))'22r*)rc:|jj|d|iS)z*See :meth:`Pytester.runpytest_subprocess`.r)r%runpytest_subprocess)r&rrIs r(rzTestdir.runpytest_subprocesss2t~~22DJ'JJr*c<|jj||S)z"See :meth:`Pytester.spawn_pytest`.expect_timeout)r% spawn_pytest)r&stringrs r(rzTestdir.spawn_pytests~~**6.*QQr*c<|jj||S)zSee :meth:`Pytester.spawn`.r)r%spawn)r&cmdrs r(rz Testdir.spawns~~##C#GGr*c"d|jdS)Nz )r.r-s r(__repr__zTestdir.__repr__s4;;/++r*c,t|jSr$)strr.r-s r(__str__zTestdir.__str__s4;;r*)r'rr"boolreturnNonerr )rr)rr)rr)rNrrrr$)rhr rItem | Collector | None)rnzlist[Item | Collector]rz list[Item])ryr)rr)rr ) test_func)rwF)rrrarrr)g$@)rrrfloatr pexpect.spawn)rrrrrr)rr)9__name__ __module__ __qualname____doc____test__rr__annotations__r r)propertyr.r1r4r7setterr;r=r@rCrGrLrPrRrUrWrZr\r_rcrergrkrmrprrrur{r}rrrrrrr subprocessPIPErrrrrrrrrrwr*r(rr)sH!--K-$33NE3@E"0099''&& ^^))++@&* J@;0EGH279>301.E5)+U C9148/ < J%) J0337KRH, r*rc(eZdZeeddZy)LegacyTestdirPluginct|dS)z Identical to :fixture:`pytester`, and provides an instance whose methods return legacy ``LEGACY_PATH`` objects instead when applicable. New code should avoid using :fixture:`testdir` in favor of :fixture:`pytester`. Tr!)r)r's r(testdirzLegacyTestdirPlugin.testdirsx400r*N)r'rrr)rrr staticmethodrrrwr*r(rrs 1 1r*rcFeZdZUdZded<dd d dZd d dZd dZy )TempdirFactoryaBackward compatibility wrapper that implements ``py.path.local`` for :class:`TempPathFactory`. .. note:: These days, it is preferred to use ``tmp_path_factory``. :ref:`About the tmpdir and tmpdir_factory fixtures`. r_tmppath_factoryFr!c(t|||_yr$)rr)r&tmppath_factoryr"s r(r)zTempdirFactory.__init__s y! /r*cht|jj||jS)zOSame as :meth:`TempPathFactory.mktemp`, but returns a ``py.path.local`` object.)r rmktempresolve)r&basenamenumbereds r(rzTempdirFactory.mktemps)40077(KSSUVVr*cdt|jjjS)zTSame as :meth:`TempPathFactory.getbasetemp`, but returns a ``py.path.local`` object.)r r getbasetemprr-s r(rzTempdirFactory.getbasetemp#s%400<<>FFHIIr*N)rrr"rrr)T)rrrrrr r)rrrrrr)rrrwr*r(rr s?&%FK0.0>B0 0 WJr*rcReZdZeedddZeeddZy)LegacyTmpdirPluginsession)scopec.|jjS)zFReturn a :class:`pytest.TempdirFactory` instance for the test session.)rh_tmpdirhandler)r4s r(tmpdir_factoryz!LegacyTmpdirPlugin.tmpdir_factory)s ~~,,,r*ct|S)a=Return a temporary directory (as `legacy_path`_ object) which is unique to each test function invocation. The temporary directory is created as a subdirectory of the base temporary directory, with configurable retention, as discussed in :ref:`temporary directory location and retention`. .. note:: These days, it is preferred to use ``tmp_path``. :ref:`About the tmpdir and tmpdir_factory fixtures`. .. _legacy_path: https://py.readthedocs.io/en/latest/path.html r )tmp_paths r(r.zLegacyTmpdirPlugin.tmpdir0s 8$$r*N)r4rrr)rrrr )rrrrrrr.rwr*r(rr(s= 9--  % %r*rc6t|j|S)z{Return a directory path object with the given name. Same as :func:`mkdir`, but returns a legacy py path instance. )r r_r`s r( Cache_makedirrCs tzz$' ((r*c,t|jS)zO(deprecated) The file system path of the test module which collected this test.r r,r-s r(FixtureRequest_fspathrK tyy !!r*c,t|jS)zThe directory from which pytest was invoked. Prefer to use ``startpath`` which is a :class:`pathlib.Path`. :type: LEGACY_PATH r startpathr-s r(TerminalReporter_startdirrP t~~ &&r*cRtt|jjS)zThe directory from which pytest was invoked. Prefer to use :attr:`invocation_params.dir `, which is a :class:`pathlib.Path`. :type: LEGACY_PATH )r rinvocation_paramsdirr-s r(Config_invocation_dirrZs  s411556 77r*c>tt|jS)zThe path to the :ref:`rootdir `. Prefer to use :attr:`rootpath`, which is a :class:`pathlib.Path`. :type: LEGACY_PATH )r rrootpathr-s r(Config_rootdirres s4==) **r*cZ|jrtt|jSdS)zThe path to the :ref:`configfile `. Prefer to use :attr:`inipath`, which is a :class:`pathlib.Path`. :type: Optional[LEGACY_PATH] N)inipathr rr-s r(Config_inifileros#.2\\;s4<<( )CtCr*c,t|jS)zThe path from which pytest was invoked. Prefer to use ``startpath`` which is a :class:`pathlib.Path`. :type: LEGACY_PATH rr-s r(Session_startdirryrr*c |dk(rp|jJ|jj}t|trt j |n|}|Dcgc]}t t||z c}Std||cc}w)Npathlistzunknown configuration type: )rparent isinstancershlexsplitr ValueError)r&ratypevaluedp input_valuesxs r(Config__getini_unknown_typers{ z||''' \\ -7s-Cu{{5) 2>?Q CQK(??7v>FF@sBc,t|jS)z4(deprecated) returns a legacy_path copy of self.pathrr-s r( Node_fspathrrr*c$t||_yr$)rr,)r&rs r(Node_fspath_setrs U DIr*T)tryfirstct}|j|j|jtdt d|jt dttd|jtdttd|jtdttd|jtdttd|jtdttd|jtdtt d|jtd t"|jt$dtt&t(dy ) zLMonkeypatch legacy path attributes in several classes, as early as possible.makedirFraisingfspathstartdirinvocation_dirrootdirinifile_getini_unknown_typeN)r add_cleanupundosetattrr rrrrrrr rrrrrrrrr) early_configmps r(pytest_load_initial_conftestsrs BRWW%JJuiJ>JJ~x2G)HRWJXJJ*h/H&ISX JJv'2G)HRWJXJJvy(>":EJJJJvy(>":EJJJJw H-=$>JNJJv-/JKJJtXx _EuJUr*cB|jjdrut}|j|j |j }t |d}|j|d|d|jjtdyy#t$rY-wxYw) zKInstalls the LegacyTmpdirPlugin if the ``tmpdir`` plugin is also installed.r.Tr!rFrzlegacypath-tmpdirN) r> has_pluginrrr_tmp_path_factoryrrAttributeErrorregisterr)rhrtmp_path_factoryrs r(pytest_configurers&&x0 ]277#  P%77  ,,<MN JJv/J O%%&8:MN#1   s B BBc||jdu}|r-|jts|jtdyyy)Nr'zlegacypath-pytester) get_plugin is_registeredrr)pluginmanager is_pytesters r(pytest_plugin_registeredr#sDG..z::K7001DE,.CDF{r*)r&r rarrr )r&rrr )r&rrr )r&r rr )r&r rzLEGACY_PATH | None)r&rrr )rarrrrzstr | list[str])r&rrr )r&rrr rr)rr rr)rhr rr)r objectr!rrr)?r __future__r dataclassespathlibrrrtypingrrr iniconfigr_pytest.cacheproviderr _pytest.compatr r _pytest.configr rr_pytest.deprecatedr_pytest.fixturesrr _pytest.mainr_pytest.monkeypatchr _pytest.nodesrrr_pytest.pytesterrrr_pytest.terminalr_pytest.tmpdirrpexpectrr dataclassrrrrrrrrrrrrrrr#rwr*r(r7s:E"  $'&&!#.-$+ +#)%&-*P P P f 1 1 JJJ8%%6)" '8+D'G"  4VV> O O, E Er*