K i34UdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddl mZddl mZej dddk(Z ddlZeedd Zejd k(xsej,d vZeed <e e e ge fed <e e ge fed<e e ge fed<e e ge fed<e e ge fed<e e ge fed<e e ge fed<erej4Zej6Zej8j:Zej8j6Zej8j@Z ej8jBZ!ej8jDZ"ddl#m$Z$nVGddZ%d/dZGddZ&Gdde'Z(Gdde'Z)Gdde'Z*Gd d!e'Z$d"Zd#Zd$Zd%Z d&Z!d'Z"ejVd(d)d*d+Z,d,Z-ejVd-Z.d.Z/y#e$rd ZYwxYw)0z$py.test hacks to support XFAIL/XPASSN)AnyCallable)SymPyDeprecationWarning)ignore_warningsCItrue_running_pytestF emscripten)wasm32wasm64IS_WASMraisesXFAILskipSKIPslowtooslow nocache_fail)FailedceZdZdZdZy) ExceptionInfoc||_yN)value)selfrs Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/testing/pytest.py__init__zExceptionInfo.__init__7s DJc8dj|jS)Nz)formatrrs r__repr__zExceptionInfo.__repr__:s)00< >> from sympy.testing.pytest import raises >>> raises(ZeroDivisionError, lambda: 1/0) >>> raises(ZeroDivisionError, lambda: 1/2) Traceback (most recent call last): ... Failed: DID NOT RAISE >>> with raises(ZeroDivisionError): ... n = 1/0 >>> with raises(ZeroDivisionError): ... n = 1/2 Traceback (most recent call last): ... Failed: DID NOT RAISE Note that you cannot test multiple statements via ``with raises``: >>> with raises(ZeroDivisionError): ... n = 1/0 # will execute and raise, aborting the ``with`` ... n = 9999/0 # never executed This is just what ``with`` is supposed to do: abort the contained statement sequence at the first exception and let the context manager deal with the exception. To test multiple statements, you'll need a separate ``with`` for each: >>> with raises(ZeroDivisionError): ... n = 1/0 # will execute and raise >>> with raises(ZeroDivisionError): ... n = 9999/0 # will also execute and raise N DID NOT RAISEz'raises(xxx, "code")' has been phased out; change 'raises(xxx, "expression")' to 'raises(xxx, lambda: expression)', 'raises(xxx, "statement")' to 'with raises(xxx): statement'z1raises() expects a callable for the 2nd argument.) RaisesContextcallablerr isinstancestr TypeError)expectedExceptioncodees rrr>sl < !23 3 d^ () ) c "56 6CE E% ($Q'' (sAA, A'!A,'A,ceZdZdZdZdZy)r)c||_yr)r.)rr.s rrzRaisesContext.__init__s %6D "rcyrr&r!s r __enter__zRaisesContext.__enter__srcH| tdt||jS)Nr()r issubclassr.)rexc_type exc_value tracebacks r__exit__zRaisesContext.__exit__s&_--h(>(>? ?rN)r#r$r%rr4r:r&rrr)r)s 7  @rr)c eZdZy)XFailNr#r$r%r&rrr<r< rr<c eZdZy)XPassNr=r&rrr@r@r>rr@c eZdZy)SkippedNr=r&rrrBrBr>rrBc eZdZy)rNr=r&rrrrr>rrc>fd}tj|}|S)Nc t j#t$r5}t|}|dk7rtjt dd}~wwxYw)NTimeout) Exceptionr,r<r#rBr@)r0messagefuncs rwrapperzXFAIL..wrappers[ - & &  -a&i' ..!),,  -s A0AA functoolsupdate_wrapper)rIrJs` rrrs! '**7D9rct|rrB)r,s rrrs clrcfd}|S)z0Similar to ``skip()``, but this is a decorator. c>fd}tj||}|S)NctrrO)reasonsr func_wrapperz+SKIP..wrapper..func_wrappers fo%rrK)rIrTrSs rrJzSKIP..wrappers" &%33L$GL rr&)rSrJs` rrrs rcZd_fd}tj|}|_|S)NTcyrr&rIsrrTzslow..func_wrappers Fr)_slowrLrM __wrapped__rIrTs` rrrs1  !// dC #'  rcbd|_d|_d}tj||}||_|S)NTctdy)NzToo slow)rr&rrrTztooslow..func_wrappers  r)rX_tooslowrLrMrYrZs rrrs7   !// dC #'  rc|S)zBDummy decorator for marking tests that fail when cache is disabledr&rWs rrrs rT)matchtest_stacklevelc#xKtjd5}tjdtjd|dddt fdDs,dd |Dcgc]}|j c}d }t ||D]|}t|jsJtj|tjjt|j rbt d jd |d |rtj D]J}|j"}t$j&j)|d}|j+drn|dk(sJyt-d|D]L}|j"|k7sd|j"d|j.d|d j1dd}t |t2k(rt5j6t8} | j:j:j:dz dz dz dz } | j=syg} |D]'}| j?|j j@)t5j6| jCd} | D]} d| d| vs t d| d | d!yy#1swY_xYwcc}ww)"a Like raises but tests that warnings are emitted. >>> from sympy.testing.pytest import warns >>> import warnings >>> with warns(UserWarning): ... warnings.warn('deprecated', UserWarning, stacklevel=2) >>> with warns(UserWarning): ... pass Traceback (most recent call last): ... Failed: DID NOT WARN. No warnings of type UserWarning was emitted. The list of emitted warnings is: []. ``test_stacklevel`` makes it check that the ``stacklevel`` parameter to ``warn()`` is set so that the warning shows the user line of code (the code under the warns() context manager). Set this to False if this is ambiguous or if the context manager does not test the direct user code that emits the warning. If the warning is a ``SymPyDeprecationWarning``, this additionally tests that the ``active_deprecations_target`` is a real target in the ``active-deprecations.md`` file. T)recorderroralways)categoryNc3JK|]}t|jywr)r6rf).0w warningclss r zwarns..sCaz!**j1Cs #z*Failed: DID NOT WARN. No warnings of type z/ was emitted. The list of emitted warnings is: .z?Failed: WRONG MESSAGE. A warning with of the correct category (z:) was issued, but it did not match the given match regex ()test_z doctest.pyzDCould not find the file for the given warning to test the stacklevelzFailed: Warning has the wrong stacklevel. The warning stacklevel needs to be set so that the line of code shown in the warning message is user code that calls the deprecated code (the current stacklevel is showing code from z (line z ), expected   docsrc explanationzactive-deprecations.mdzutf-8)encoding(z)=zThe active deprecations target zJ does not appear to be a valid target in the active-deprecations.md file (z).)"warningscatch_warnings simplefilterfilterwarningsanyrHrr6rfrecompile IGNORECASEr`r,r#inspectstackfilenameospathsplit startswith RuntimeErrorlinenoreplacerpathlibPath__file__parentexistsappendactive_deprecations_target read_text)rjr`rawarnrecrimsgfthisfilefile this_fileactive_deprecations_filetargetstexttargets` rwarnsrs<   -g&:>  C7C CG Sk v!**j111zz%/55c!))nEZ[e[n[nZopjkpjsstuv v v  gAzzH77==*1-Dw'% gef f "AzzX% GAHH:\(1 89@c8J  Sk! ",,LL* $-$4$4$;$;$B$BU$J$)%*,9%:$<%= (..0  AA NN199?? @ A||45???Q qF6("~T)>vjISTlSmmopqq q-[!=sCJ:1J( $J:/J5 A4J:7A.func_wrap<sL    F     F      s3?<A)sympy.core.parametersrrLrM)rIrrJrs` @r _both_exp_powr1s&2 &&y$7G Nrc#\Ktt5ddddy#1swYyxYww)a: Shorthand for ``warns(SymPyDeprecationWarning)`` This is the recommended way to test that ``SymPyDeprecationWarning`` is emitted for deprecated features in SymPy. To test for other warnings use ``warns``. To suppress warnings without asserting that they are emitted use ``ignore_warnings``. .. note:: ``warns_deprecated_sympy()`` is only intended for internal use in the SymPy test suite to test that a deprecation warning triggers properly. All other code in the SymPy codebase, including documentation examples, should not use deprecated behavior. If you are a user of SymPy and you want to disable SymPyDeprecationWarnings, use ``warnings`` filters (see :ref:`silencing-sympy-deprecation-warnings`). >>> from sympy.testing.pytest import warns_deprecated_sympy >>> from sympy.utilities.exceptions import sympy_deprecation_warning >>> with warns_deprecated_sympy(): ... sympy_deprecation_warning("Don't use", ... deprecated_since_version="1.0", ... active_deprecations_target="active-deprecations") >>> with warns_deprecated_sympy(): ... pass Traceback (most recent call last): ... Failed: DID NOT WARN. No warnings of type SymPyDeprecationWarning was emitted. The list of emitted warnings is: []. .. note:: Sometimes the stacklevel test will fail because the same warning is emitted multiple times. In this case, you can use :func:`sympy.utilities.exceptions.ignore_warnings` in the code to prevent the ``SymPyDeprecationWarning`` from being emitted again recursively. In rare cases it is impossible to have a consistent ``stacklevel`` for deprecation warnings because different ways of calling a function will produce different call stacks.. In those cases, use ``warns(SymPyDeprecationWarning)`` instead. See Also ======== sympy.utilities.exceptions.SymPyDeprecationWarning sympy.utilities.exceptions.sympy_deprecation_warning sympy.utilities.decorator.deprecated N)rrr&rrwarns_deprecated_sympyrFs)j & ' s,  ,),cfd}|S)z7Decorator to skip a test if running under Pyodide/WASM.cFtjfd}|S)Nc4tr tSr)r r)rH test_funcsr test_wrapperz;skip_under_pyodide..decorator..test_wrappersW ; r)rLwraps)rrrHs` r decoratorz%skip_under_pyodide..decorators&  #  $ rr&)rHrs` rskip_under_pyodiders rr)0__doc__platformsysr|rLr contextlibrwrrtypingrrsympy.utilities.exceptionsrrgetenvON_CIpytestgetattr USE_PYTEST ImportErrormachiner bool__annotations__rrmarkxfailrrrrr_pytest.outcomesrrr)rGr<r@rBcontextmanagerrrrrr&rrrs2*   >7 $'/7J ,Z0@0@0@0BFZ0ZZ#sS!!s uczuczucz 3%* ucz"" ]]F ;;D KK  E ;;  D ;;  Dkk!!G;;++L'==GER @ @     )       !4YqYqv* 55p M JsG,,G76G7