§ |<ˆj²*ãóô—dZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZed¦«Zede dfd„¦«Zeddœde eeeefddfd„¦«Z ede defd ed!edefd"„¦«Z d+de e defd ed!ededeffd#„Z e d,ddœd$eee!eee!dffde eeeefdd%fd&„¦«Z"ed$eee!eee!dffde defd ed!edef d'„¦«Z"e!fddœd$eee!eee!dffd ede eeeefd!eded%eff d(„Z"Gd)„dej#¦«Z$eGd*„d%e$¦«¦«Z%dS)-z/Record warnings during test function execution.éN©Úpformat)Ú TracebackType)ÚAny)ÚCallable)Ú Generator)ÚIterator)ÚList)ÚOptional)ÚPattern)ÚTuple)ÚType)ÚTypeVar)ÚUnion)Úfinal)Úoverload)Úcheck_ispytest)ÚWARNS_NONE_ARG)Úfixture)ÚfailÚTÚreturn)ÚWarningsRecorderNNc#ó�K—td¬¦«}|5tjd¦«|V—ddd¦«dS#1swxYwYdS)zØReturn a :class:`WarningsRecorder` instance that records all warnings emitted by test functions. See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information on warning categories. T©Ú _ispytestÚdefaultN)rÚwarningsÚ simplefilter)Úwrecs úa/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib/python3.11/site-packages/_pytest/recwarn.pyÚrecwarnr"sœèè€õ  dÐ +Ñ +Ô +€DØ ððÝÔ˜iÑ(Ô(Ð(؈ ˆ ˆ ðððñôðððððððøøøððððððs •;»?Á?.©Úmatchr$rcó—dS©N©r#s r!Údeprecated_callr(*ó €ð€CóÚfuncÚargsÚkwargscó—dSr&r')r+r,r-s r!r(r(1r)r*cóN—d}|�|f|z}tttfg|¢Ri|¤ŽS)a�Assert that code produces a ``DeprecationWarning`` or ``PendingDeprecationWarning``. This function can be used as a context manager:: >>> import warnings >>> def api_call_v2(): ... warnings.warn('use v3 of this api', DeprecationWarning) ... return 200 >>> import pytest >>> with pytest.deprecated_call(): ... assert api_call_v2() == 200 It can also be used by passing a function and ``*args`` and ``**kwargs``, in which case it will ensure calling ``func(*args, **kwargs)`` produces one of the warnings types above. The return value is the return value of the function. In the context manager form you may use the keyword argument ``match`` to assert that the warning matches a text or regex. The context manager produces a list of :class:`warnings.WarningMessage` objects, one for each warning raised. T)ÚwarnsÚDeprecationWarningÚPendingDeprecationWarning)r+r,r-Ú__tracebackhide__s r!r(r(8s@€ð4ÐØ ÐØˆw˜‰~ˆÝ Õ$Õ&?Ð@Ð RÀ4Ð RÐ RÐ RÈ6Ð RÐ RÐRr*Úexpected_warningÚWarningsCheckercó—dSr&r')r4r$s r!r0r0Xs €ð €Cr*có—dSr&r')r4r+r,r-s r!r0r0as €ð€Cr*có„—d}|sI|r5d t|¦«¦«}td|›d�¦«‚t||d¬¦«S|d}t |¦«s"t|›dt |¦«›d�¦«‚t|d¬ ¦«5||d d …i|¤Žcd d d ¦«S#1swxYwYd S) aœAssert that code raises a particular class of warning. Specifically, the parameter ``expected_warning`` can be a warning class or sequence of warning classes, and the code inside the ``with`` block must issue at least one warning of that class or classes. This helper produces a list of :class:`warnings.WarningMessage` objects, one for each warning raised (regardless of whether it is an ``expected_warning`` or not). This function can be used as a context manager, which will capture all the raised warnings inside it:: >>> import pytest >>> with pytest.warns(RuntimeWarning): ... warnings.warn("my warning", RuntimeWarning) In the context manager form you may use the keyword argument ``match`` to assert that the warning matches a text or regex:: >>> with pytest.warns(UserWarning, match='must be 0 or None'): ... warnings.warn("value must be 0 or None", UserWarning) >>> with pytest.warns(UserWarning, match=r'must be \d+$'): ... warnings.warn("value must be 42", UserWarning) >>> with pytest.warns(UserWarning, match=r'must be \d+$'): ... warnings.warn("this is not here", UserWarning) Traceback (most recent call last): ... Failed: DID NOT WARN. No warnings of type ...UserWarning... were emitted... **Using with** ``pytest.mark.parametrize`` When using :ref:`pytest.mark.parametrize ref` it is possible to parametrize tests such that some runs raise a warning and others do not. This could be achieved in the same way as with exceptions, see :ref:`parametrizing_conditional_raising` for an example. Tz, z5Unexpected keyword arguments passed to pytest.warns: z" Use context-manager form instead?)Ú match_exprrrz object (type: z) must be callableréN)ÚjoinÚsortedÚ TypeErrorr5ÚcallableÚtype)r4r$r,r-r3Úargnamesr+s r!r0r0ksA€ð\ÐØ ð -Ø ð Ø—y’y¥¨¡¤Ñ0Ô0ˆHÝð6Èð6ð6ð6ñôð õÐ/¸EÈTÐRÑRÔRÐRà�AŒwˆÝ˜‰~Œ~ð VݘtÐTÐTµd¸4±j´jÐTÐTÐTÑUÔUÐ UÝ Ð-¸Ð >Ñ >Ô >ð -ð -Ø�4˜˜a˜b˜bœÐ, VÐ,Ð,ð -ð -ð -ð -ñ -ô -ð -ð -ð -ð -ð -ð -øøøð -ð -ð -ð -ð -ð -sÂB5Â5B9Â<B9có‡—eZdZdZddœdeddfˆfd„Zededfd „¦«Zd e ddfd „Z de dfd „Z de fd „Z efdeeddfd„Zdd„Zdˆfd„ Zdeeedeedeeddfˆfd„ ZˆxZS)raFA context manager to record raised warnings. Each recorded warning is an instance of :class:`warnings.WarningMessage`. Adapted from `warnings.catch_warnings`. .. note:: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are treated differently; see :ref:`ensuring_function_triggers`. FrrrNc󆕗t|¦«t¦« d¬¦«d|_g|_dS)NT)ÚrecordF)rÚsuperÚ__init__Ú_enteredÚ_list)ÚselfrÚ __class__s €r!rEzWarningsRecorder.__init__·s>ø€Ý�yÑ!Ô!Ð!å ‰Œ×Ò ÐÑ%Ô%Ð%؈Œ Ø46ˆŒ ˆ ˆ r*zwarnings.WarningMessagecó—|jS)zThe list of recorded warnings.©rG©rHs r!ÚlistzWarningsRecorder.list¾s €ðŒzÐr*Úicó—|j|S)z Get a recorded warning by index.rK)rHrNs r!Ú __getitem__zWarningsRecorder.__getitem__Ãs€àŒz˜!Œ}Ðr*có*—t|j¦«S)z&Iterate through the recorded warnings.)ÚiterrGrLs r!Ú__iter__zWarningsRecorder.__iter__Çs€å�D”JÑÔÐr*có*—t|j¦«S)z The number of recorded warnings.)ÚlenrGrLs r!Ú__len__zWarningsRecorder.__len__Ës€å�4”:‰ŒÐr*ÚclscóÀ—t|j¦«D]6\}}t|j|¦«r|j |¦«cSŒ7d}t |›d�¦«‚)z>Pop the first recorded warning, raise exception if not exists.Tz not found in warning list)Ú enumeraterGÚ issubclassÚcategoryÚpopÚAssertionError)rHrWrNÚwr3s r!r\zWarningsRecorder.popÏso€å˜dœjÑ)Ô)ð )ð )‰DˆAˆqݘ!œ* cÑ*Ô*ð )Ø”z—~’~ aÑ(Ô(Ð(Ð(Ð(ð )à ÐÝ ÐAÐAÐAÑBÔBÐBr*có—g|jdd…<dS)z$Clear the list of recorded warnings.NrKrLs r!ÚclearzWarningsRecorder.clear×s€àˆŒ �1�1�1‰ ˆ ˆ r*c󾕗|jrd}td|›d�¦«‚t¦« ¦«}|€J‚||_t jd¦«|S)NTz Cannot enter z twiceÚalways)rFÚ RuntimeErrorrDÚ __enter__rGrr)rHr3rGrIs €r!rdzWarningsRecorder.__enter__Ýskø€Ø Œ=ð ?Ø $Ð ÝÐ=¨tÐ=Ð=Ð=Ñ>Ô>Ð >Ý‘”×!Ò!Ñ#Ô#ˆàРРР؈Œ ÝÔ˜hÑ'Ô'Ð'؈ r*Úexc_typeÚexc_valÚexc_tbcó”•—|jsd}td|›d�¦«‚t¦« |||¦«d|_dS)NTz Cannot exit z without entering firstF)rFrcrDÚ__exit__)rHrerfrgr3rIs €r!rizWarningsRecorder.__exit__èsYø€ð Œ}ð OØ $Ð ÝÐM¨dÐMÐMÐMÑNÔNÐ Nå ‰Œ×Ò˜ 7¨FÑ3Ô3Ð3ðˆŒ ˆ ˆ r*)rN)rr)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚboolrEÚpropertyr rMÚintrPr rSrVÚWarningrr\r`rdr Ú BaseExceptionrriÚ __classcell__©rIs@r!rrªs²ø€€€€€ð ð ð-2ð7ð7ð7 Tð7°dð7ð7ð7ð7ð7ð7ðð�dÐ4Ô5ðððñ„Xðð˜SðÐ%>ððððð ˜(Ð#<Ô=ð ð ð ð ð˜ððððð(/ðCðC�t˜G”}ðCÐ3LðCðCðCðCððððð ð ð ð ð ð ðà˜4  Ô.Ô/ðð˜-Ô(ðð˜Ô'ð ð ð ðððððððððr*c óô‡—eZdZedfddœdeeeeeeedffdeeee efde ddfˆfd „Z d eee d ee d ee ddfˆfd „ ZˆxZS)r5NFrr4.r9rrcóÜ•—t|¦«t¦« d¬¦«d}|€tjt d¬¦«d}n‰t |t¦«r<|D]6}t|t¦«st|t|¦«z¦«‚Œ7|}n8t|t¦«r|f}nt|t|¦«z¦«‚||_ ||_ dS)NTrz/exceptions must be derived from Warning, not %sé)Ú stacklevel)rrDrErÚwarnrÚ isinstanceÚtuplerZrqr=r?r4r9)rHr4r9rÚmsgÚexpected_warning_tupÚexcrIs €r!rEzWarningsChecker.__init__ûsÿø€õ �yÑ!Ô!Ð!Ý ‰Œ×Ò 4ÐÑ(Ô(Ð(à?ˆØ Ð #Ý ŒM�.°QÐ 7Ñ 7Ô 7Ð 7Ø#'Ð Ð Ý Ð(­%Ñ 0Ô 0ð :Ø'ð 5ð 5�Ý! #¥wÑ/Ô/ð5Ý# C­$¨s©)¬)¡OÑ4Ô4Ð4ð5à#3Ð Ð Ý Ð(­'Ñ 2Ô 2ð :Ø$4Ð#6Ð Ð å˜C¥$Ð'7Ñ"8Ô"8Ñ8Ñ9Ô9Ð 9à 4ˆÔØ$ˆŒˆˆr*rerfrgc ó2•‡—t¦« |||¦«d}ˆfd„}|€à|€à|€à‰j�Ûtˆfd„‰D¦«¦«s'd}t d‰j›d|¦«›d�¦«dS‰j�”‰D]]}t |j‰j¦«rAtj ‰j¦«  t|j ¦«¦«rdSŒ^t d‰j›d‰j›d|¦«›�¦«dSdSdSdSdSdS) NTcó:•—td„‰D¦«d¬¦«S)Ncó—g|] }|j‘Œ Sr')Úmessage)Ú.0rCs r!ú z?WarningsChecker.__exit__..found_str..#s€Ð>Ð>Ð>¨v˜FœNÐ>Ð>Ð>r*é)ÚindentrrLs€r!Ú found_strz+WarningsChecker.__exit__..found_str"s%ø€ÝÐ>Ð>¸Ð>Ñ>Ô>ÀqÐIÑIÔIÐ Ir*c3óL•K—|]}t|j‰j¦«V—ŒdSr&)rZr[r4)rƒÚrrHs €r!ú z+WarningsChecker.__exit__..(s2øèè€ÐWÐWÈQ�: a¤j°$Ô2GÑHÔHÐWÐWÐWÐWÐWÐWr*z"DID NOT WARN. No warnings of type z0 were emitted. The list of emitted warnings is: ú.z* matching the regex were emitted. Regex: z Emitted warnings: ) rDrir4Úanyrr9rZr[ÚreÚcompileÚsearchÚstrr‚)rHrerfrgr3r‡r‰rIs` €r!rizWarningsChecker.__exit__s®øø€õ ‰Œ×Ò˜ 7¨FÑ3Ô3Ð3à Ðð Jð Jð Jð Jð Jð Ð   °F°NØÔ$Ð0ÝÐWÐWÐWÐWÐRVÐWÑWÔWÑWÔWðØ(,Ð%ÝðK¸TÔ=RðKðKØr™s­ðØ5Ð5Ø € € € Ø€€€ØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐà Ð Ð Ð Ð Ð Ø#Ð#Ð#Ð#Ð#Ð#Ø-Ð-Ð-Ð-Ð-Ð-Ø-Ð-Ð-Ð-Ð-Ð-Ø$Ð$Ð$Ð$Ð$Ð$Ø!Ð!Ð!Ð!Ð!Ð!ð €GˆC�L„L€ð ð �Ð9Ô:ð ð ð ñ „ð ð à36ðððØ�u˜S '¨#¤,Ð.Ô/Ô0ðàðððñ „ðð  ðØ �3˜�6Ô ðØ#&ðØ25ðàðððñ „ðð*.ðSðSØ �8˜C ˜HÔ%Ô &ðSØ69ðSØEHðSà Ð ˜sÐ "Ô#ðSðSðSðSð@ àHKðð14ðððؘD œM¨5°°g´ÀÐ1CÔ+DÐDÔEðð �E˜#˜w sœ|Ð+Ô,Ô -ððð ððñ „ðð ðؘD œM¨5°°g´ÀÐ1CÔ+DÐDÔEðà �3˜�6Ô ðð ððð ð ð ððñ „ððIPð<-ð15ð<-ð<-ð<-ؘD œM¨5°°g´ÀÐ1CÔ+DÐDÔEð<-à ð<-ð �E˜#˜w sœ|Ð+Ô,Ô -ð<-ðð <-ð  Ð ˜cÐ !Ô"ð <-ð<-ð<-ð<-ð~LðLðLðLðL�xÔ.ñLôLðLð^ð?ð?ð?ð?ð?Ð&ñ?ô?ñ„ð?ð?ð?r*