§ v<ˆj+ãóЗddlmZddlmZddlmZmZmZmZm Z m Z m Z ddl Z ddlZddl Z ddlmZddlmZmZddlmZGd „d ej¦«ZGd „d e¦«Zd efd„ZdS)é)Ú defaultdict)Ú LogRecord)ÚListÚUnionÚTupleÚSequenceÚCallableÚAnyÚOptionalN)Úpformaté)ÚSequenceComparisonÚcompare)Úwrapcóž—eZdZUdZeeed<eeed<e ¦«Z dZ dZ e jZ d&d eeeefd ed ed ed eeeeegeffdedefd„Zed„¦«Zd„Zd„Zd„Zd„Zd„Zd'd efd„Zde jfd„Z d„Z!d„Z"ed„¦«Z#d„Z$defd„Z%d„Z&d „Z'dd!œd"efd#„Z(d$„Z)d%„Z*dS)(Ú LogCapturea These are used to capture entries logged to the Python logging framework and make assertions about what was logged. :param names: A string (or tuple of strings) containing the dotted name(s) of loggers to capture. By default, the root logger is captured. :param install: If `True`, the :class:`LogCapture` will be installed as part of its instantiation. :param propagate: If specified, any captured loggers will have their `propagate` attribute set to the supplied value. This can be used to prevent propagation from a child logger to a parent logger that has configured handlers. :param attributes: The sequence of attribute names to return for each record or a callable that extracts a row from a record. If a sequence of attribute names, those attributes will be taken from the :class:`~logging.LogRecord`. If an attribute is callable, the value used will be the result of calling it. If an attribute is missing, ``None`` will be used in its place. If a callable, it will be called with the :class:`~logging.LogRecord` and the value returned will be used as the row. :param recursive_check: If ``True``, log messages will be compared recursively by :meth:`LogCapture.check`. :param ensure_checks_above: The log level above which checks must be made for logged events. See :meth:`ensure_checked`. ÚrecordsÚensure_checks_aboveFNTr ©ÚnameÚ levelnameÚ getMessageÚnamesÚinstallÚlevelÚ propagateÚ attributesÚrecursive_checkcóp—tj |¦«t|t¦«s|f}||_||_||_||_||_ tt¦«|_ |€ |j |_n||_| ¦«|r| ¦«dSdS©N)ÚloggingÚHandlerÚ__init__Ú isinstanceÚtuplerrrrrrÚdictÚoldÚdefault_ensure_checks_aboverÚclearr)Úselfrrrrrrrs úi/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib/python3.11/site-packages/testfixtures/logcapture.pyr#zLogCapture.__init__As²€õ Œ× Ò  Ñ&Ô&Ð&ݘ%¥Ñ'Ô'ð Ø�IˆE؈Œ ؈Œ Ø"ˆŒØ$ˆŒØ.ˆÔÝ�tÑ$Ô$ˆŒØ Ð &Ø'+Ô'GˆDÔ $Ð $à':ˆDÔ $Ø � Š ‰ Œ ˆ Ø ð Ø �LŠL‰NŒNˆNˆNˆNð ð ócóŠ—|jr;tjdd d„|jD¦«¦«z¦«dSdS)NzFLogCapture instances not uninstalled by shutdown, loggers captured: %sú c3ó>K—|]}t|j¦«V—ŒdSr )Ústrr)Ú.0Úis r+ú z$LogCapture.atexit..ds*èè€Ð"GÐ"G°A¥3 q¤w¡<¤<Ð"GÐ"GÐ"GÐ"GÐ"GÐ"Gr,)Ú instancesÚwarningsÚwarnÚjoin)Úclss r+ÚatexitzLogCapture.atexit^s_€à Œ=ð Ý ŒMðàŸ š Ð"GÐ"G¸¼Ð"GÑ"GÔ"GÑHÔHñJñ ô ð ð ð ð ð r,có*—t|j¦«Sr )Úlenr©r*s r+Ú__len__zLogCapture.__len__gs€Ý�4”<Ñ Ô Ð r,cóB—| |j|¦«Sr )Ú _actual_rowr)r*Úindexs r+Ú __getitem__zLogCapture.__getitem__js€Ø×Ò ¤ ¨UÔ 3Ñ4Ô4Ð4r,cóf—t|¦«D] \}}||krd|j|_dSŒ!dS)NT)Ú enumeraterÚchecked)r*Úwhatr2Úitems r+Ú __contains__zLogCapture.__contains__msH€Ý  ‘”ð ð ‰GˆAˆtØ�tŠ|ˆ|Ø*.�” ˜Q”Ô'Ø�t�tðð ð r,có—g|_dS)z*Clear any entries that have been captured.N)rr<s r+r)zLogCapture.clearss €àˆŒ ˆ ˆ r,có(—|jD] }d|_Œ dS)z¶ Mark all captured events as checked. This should be called if you have made assertions about logging other than through :class:`LogCapture` methods. TN)rrD©r*Úrecords r+Úmark_all_checkedzLogCapture.mark_all_checkedws(€ð ”lð "ð "ˆFØ!ˆFŒNˆNð "ð "r,có —|€|j}|tjkrdSg}|jD]<}|j|kr/|js(| | |¦«¦«Œ=|rtdt|¦«z¦«‚dS)zï Ensure every entry logged above the specified `level` has been checked. Raises an :class:`AssertionError` if this is not the case. :param level: the logging level, defaults to :attr:`ensure_checks_above`. NzNot asserted ERROR log(s): %s) rr!ÚNOTSETrÚlevelnorDÚappendr?ÚAssertionErrorr )r*rÚ un_checkedrKs r+Úensure_checkedzLogCapture.ensure_checked€s§€ð ˆ=ØÔ,ˆEØ •G”NÒ "Ð "Ø ˆF؈ Ø”lð <ð <ˆFØŒ~ Ò&Ð&¨v¬~Ð&Ø×!Ò! $×"2Ò"2°6Ñ":Ô":Ñ;Ô;Ð;øØ ð +Ý Ø3ݘZÑ(Ô(ñ"*ñ+ô+ð +ð +ð +r,rKcóH—d|_|j |¦«dS)z9 Record the :class:`~logging.LogRecord`. FN)rDrrPrJs r+ÚemitzLogCapture.emit”s'€ðˆŒØ Œ ×Ò˜FÑ#Ô#Ð#Ð#Ð#r,có4—|jD]Â}tj|¦«}|j|jd|<|j|jd|<|j|jd|<|j|jd|<|j|jd|<|  |j¦«g|_|g|_d|_|j� |j|_ŒÃ|j   |¦«|j j s'tj|j¦«d|j _ dSdS) a) Install this :class:`LogCapture` into the Python logging framework for the named loggers. This will remove any existing handlers for those loggers and drop their level to that specified on this :class:`LogCapture` in order to capture all logging. ÚlevelsÚfiltersÚhandlersÚdisabledrFNT)rr!Ú getLoggerrr'rXrYrZrÚsetLevelr4ÚaddÚ __class__Ú atexit_setupr9Úregister©r*rÚloggers r+rzLogCapture.install›s€ð”Jð 2ð 2ˆDÝÔ& tÑ,Ô,ˆFØ'-¤|ˆDŒH�XÔ ˜tÑ $Ø(.¬ˆDŒH�YÔ  Ñ %Ø)/¬ˆDŒH�ZÔ  Ñ &Ø)/¬ˆDŒH�ZÔ  Ñ &Ø*0Ô*:ˆDŒH�[Ô ! $Ñ 'Ø �OŠO˜DœJÑ 'Ô 'Ð '؈FŒNØ#˜fˆFŒOØ#ˆFŒOØŒ~Ð)Ø#'¤>�Ô øØ Œ×Ò˜4Ñ Ô Ð ØŒ~Ô*ð /Ý ŒO˜DœKÑ (Ô (Ð (Ø*.ˆDŒNÔ 'Ð 'Ð 'ð /ð /r,có˜—||jvrÀ|jD]œ}tj|¦«}| |jd|¦«|jd||_|jd||_|jd||_|jd||_ Œ�|j  |¦«dSdS)a& Un-install this :class:`LogCapture` from the Python logging framework for the named loggers. This will re-instate any existing handlers for those loggers that were removed during installation and restore their level that prior to installation. rWrXrYrZrN) r4rr!r[r\r'rXrYrZrÚremoveras r+Ú uninstallzLogCapture.uninstall¶sÄ€ð �4”>Ð !Ð !Øœ ð ?ð ?�Ý Ô*¨4Ñ0Ô0�Ø—’ ¤¨Ô 2°4Ô 8Ñ9Ô9Ð9Ø!%¤¨)Ô!4°TÔ!:�”Ø"&¤(¨:Ô"6°tÔ"<�”Ø"&¤(¨:Ô"6°tÔ"<�”Ø#'¤8¨KÔ#8¸Ô#>�Ô Ð Ø ŒN× !Ò ! $Ñ 'Ô 'Ð 'Ð 'Ð 'ð "Ð !r,có\—t|j¦«D]}| ¦«ŒdS)z=This will uninstall all existing :class:`LogCapture` objects.N)r%r4re)r8r2s r+Ú uninstall_allzLogCapture.uninstall_allÉs6€õ�s”}Ñ%Ô%ð ð ˆAØ �KŠK‰MŒMˆMˆMð ð r,có>—t|j¦«r| |¦«Sg}|jD]A}t||d¦«}t|¦«r |¦«}| |¦«ŒBt |¦«dkr|dSt |¦«S)Nr r)ÚcallablerÚgetattrrPr;r%)r*rKÚvaluesÚaÚvalues r+r?zLogCapture._actual_rowÏs¤€õ �D”OÑ $Ô $ð %Ø—?’? 6Ñ*Ô*Ð *àˆFØ”_ð %ð %�Ý ¨¨4Ñ0Ô0�ݘE‘?”?ð$Ø!˜E™GœG�EØ— ’ ˜eÑ$Ô$Ð$Ð$Ý�6‰{Œ{˜aÒÐØ˜a”yÐ å˜V‘}”}Ð$r,Úreturncón—g}|jD]*}| | |¦«¦«Œ+|S)a€ The sequence of actual records logged, having had their attributes extracted as specified by the ``attributes`` parameter to the :class:`LogCapture` constructor. This can be useful for making more complex assertions about logged records. The actual records logged can also be inspected by using the :attr:`records` attribute. )rrPr?)r*ÚactualÚrs r+rpzLogCapture.actualásB€ðˆØ”ð /ð /ˆAØ �MŠM˜$×*Ò*¨1Ñ-Ô-Ñ .Ô .Ð .Ð .؈ r,cóv—|jsdSd d„| ¦«D¦«¦«S)NzNo logging capturedr.có—g|]}d|z‘ŒS)z %s %s %s©)r1rqs r+ú z&LogCapture.__str__..ós€ÐCÐCÐC°˜-¨!Ñ+ÐCÐCÐCr,)rr7rpr<s r+Ú__str__zLogCapture.__str__ðs;€ØŒ|ð )Ø(Ð(Ø�yŠyÐCÐC°T·[²[±]´]ÐCÑCÔCÑDÔDÐDr,có€—t|| ¦«|j¬¦«| ¦«dS)a7 This will compare the captured entries with the expected entries provided and raise an :class:`AssertionError` if they do not match. :param expected: A sequence of entries of the structure specified by the ``attributes`` passed to the constructor. )rpÚ recursiveN)rrprrL)r*Úexpecteds r+ÚcheckzLogCapture.checkõsI€õ Ø Ø—;’;‘=”=ØÔ*ð ñ ô ð ð ×ÒÑÔÐÐÐr,)Ú order_mattersr{cóÀ—| ¦«}t||d|jdœŽ}||krt|j¦«‚|jD]}d|j|_ŒdS)as This will check if the captured entries contain all of the expected entries provided and raise an :class:`AssertionError` if not. This will ignore entries that have been captured but that do not match those in ``expected``. :param expected: A sequence of entries of the structure specified by the ``attributes`` passed to the constructor. :param order_matters: A keyword-only parameter that controls whether the order of the captured entries is required to match those of the expected entries. Defaults to ``True``. T)ÚorderedÚpartialrxN)rprrrQÚfailedÚchecked_indicesrrD)r*r{ryrpr@s r+Ú check_presentzLogCapture.check_presents|€ð$—’‘”ˆÝ%Ø ˜}°dÀdÔFZð ð ð ˆð �vÒ Ð Ý  ¤Ñ1Ô1Ð 1ØÔ-ð /ð /ˆEØ*.ˆDŒL˜Ô Ô 'Ð 'ð /ð /r,có—|Sr rtr<s r+Ú __enter__zLogCapture.__enter__"s€Øˆ r,cóV—| ¦«| ¦«dSr )rerS)r*ÚtypermÚ tracebacks r+Ú__exit__zLogCapture.__exit__%s*€Ø �ŠÑÔÐØ ×ÒÑÔÐÐÐr,)NTr NrFNr )+Ú__name__Ú __module__Ú __qualname__Ú__doc__rrÚ__annotations__r ÚintÚsetr4r_Ú installedr!rNr(rr0rÚboolrr r r#Ú classmethodr9r=rArGr)rLrSrUrrergr?rprvrzr�rƒr‡rtr,r+rr sq€€€€€€ð'ð'ðT�)Œ_ÐÐÑà! #œÐ&Ð&Ñ&à�‘”€IØ€LØ€IØ")¤.Ðð-1Ø ØØ"ðLð%*Ø'+ððà˜˜e Cœj˜Ô)ððððð ð ð ð ˜h sœm¨X°y°kÀ3Ð6FÔ-GÐGÔHð ð"ðð"%ððððð:ððñ„[ðð!ð!ð!ð5ð5ð5ðððð ððð"ð"ð"ð+ð+ Cð+ð+ð+ð+ð($˜7Ô,ð$ð$ð$ð$ð/ð/ð/ð6(ð(ð(ð&ððñ„[ðð %ð%ð%ð$ ˜ð ð ð ð ðEðEðEð  ð ð ð$>Bð/ð/ð/°dð/ð/ð/ð/ð6ðððððððr,rcó—eZdZd„ZdS)ÚLogCaptureForDecoratorcób—t |¦«| ¦«|Sr )rrr)r<s r+rzLogCaptureForDecorator.install,s(€Ý×Ò˜4Ñ Ô Ð Ø � Š ‰ Œ ˆ ؈ r,N)rˆr‰rŠrrtr,r+r“r“*s#€€€€€ðððððr,r“rcóX—t|pdfddi|¤Ž}t|j|j¦«S)a­ A decorator for making a :class:`LogCapture` installed and available for the duration of a test function. :param names: An optional sequence of names specifying the loggers to be captured. If not specified, the root logger will be captured. Keyword parameters other than ``install`` may also be supplied and will be passed on to the :class:`LogCapture` constructor. NrF)r“rrre)rÚkwÚls r+Ú log_capturer˜2s6€õ ˜u˜}¨ÐBÐB°eÐB¸rÐBÐB€AÝ �” ˜1œ;Ñ 'Ô 'Ð'r,)Ú collectionsrr!rÚtypingrrrrr r r r9r5Úpprintr Ú comparisonrrÚutilsrr"rr“r0r˜rtr,r+úržs:ðØ#Ð#Ð#Ð#Ð#Ð#ØÐÐÐÐÐØHÐHÐHÐHÐHÐHÐHÐHÐHÐHÐHÐHÐHÐHÐHÐHÐHÐHØ € € € Ø€€€Ø€€€ØÐÐÐÐÐà3Ð3Ð3Ð3Ð3Ð3Ð3Ð3ØÐÐÐÐÐðZðZðZðZðZ�”ñZôZðZðzðððð˜Zñôðð (˜ð (ð (ð (ð (ð (ð (r,