Current File : //proc/self/root/lib/python3/dist-packages/twisted/test/__pycache__/test_log.cpython-312.pyc
�

Ϫ�fq�����dZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
mZddlmZddlmZddlmZmZmZmZmZdd	lmZdd
lmZmZddlmZddl m!Z!Gd
�de"�Z#Gd�de!jH�Z%Gd�de!jH�Z&Gd�dee'�Z(e
jRe(�Gd�d�Z*Gd�d�Z+Gd�de*e+�Z,Gd�de�Z-Gd�d�Z.Gd�d e.e!jH�Z/Gd!�d"e.e!jH�Z0Gd#�d$e!jH�Z1Gd%�d&e!jH�Z2Gd'�d(e!jH�Z3Gd)�d*e!jH�Z4y)+z"
Tests for L{twisted.python.log}.
�)�annotationsN)�IOBase�StringIO)�Callable�List)�implementer)�Protocol)�ILogObserver�LogBeginner�LoggingFile�LogLevel�LogPublisher)�handlerAndBytesIO)�failure�log)r)�unittestc��eZdZdZy)�FakeWarningz
    A unique L{Warning} subclass used by tests for interactions of
    L{twisted.python.log} with the L{warnings} module.
    N)�__name__�
__module__�__qualname__�__doc__���7/usr/lib/python3/dist-packages/twisted/test/test_log.pyrr#s��rrc�@�eZdZdZd	d�Zd	d�Zd	d�Zd	d�Zd	d�Zd	d�Z	y)
�TextFromEventDictTestsz)
    Tests for L{textFromEventDict}.
    c�j�td��}tj|�}|j|d�y)zj
        The C{"message"} value, when specified, is concatenated to generate the
        message.
        )�a�b�c)�messageza b cN��dictr�textFromEventDict�assertEqual��self�	eventDict�texts   r�test_messagez#TextFromEventDictTests.test_message/s.��
��1�	��$�$�Y�/������w�'rc�p�tdddd��}tj|�}|j|d�y)zW
        The C{"format"} value, when specified, is used to format the message.
        rrzHello, %(foo)s!�dude)r"�isError�format�foozHello, dude!Nr#r's   r�test_formatz"TextFromEventDictTests.test_format8s5����Q�7H�f�U�	��$�$�Y�/������~�.rc�j�tdd��}tj|�}|j|�y)zb
        If C{"format"} is unspecified and C{"message"} is empty, return
        L{None}.
        rr�r"r.N)r$rr%�assertIsNoner's   r�test_noMessageNoFormatz-TextFromEventDictTests.test_noMessageNoFormat@s.��
��Q�/�	��$�$�Y�/�����$�rc���	t��#t$r]tddtj�d��}tj|�}|�J�|j|jd��YywxYw)zO
        The C{"why"} value, when specified, is first part of message.
        r�r0)r"r.r�whyNzfoo
�	�RuntimeError�
BaseExceptionr$r�Failurerr%�
assertTrue�
startswithr's   r�test_whySpecifiedz(TextFromEventDictTests.test_whySpecifiedIsk��	6��.� ���	6���A�w���/@�e��I��(�(��3�D��#�#�#��O�O�D�O�O�G�4�5�
	6�s�
�A#A2�1A2c���	t��#t$r\tddtj���}tj|�}|�J�|j|jd��YywxYw)zY
        The C{"why"} value, when unspecified, defaults to C{"Unhandled Error"}.
        rr7�r"r.rNzUnhandled Error
r9r's   r�test_whyDefaultz&TextFromEventDictTests.test_whyDefaultWsh��	B��.� ���	B��R��G�O�O�<M�N�I��(�(��3�D��#�#�#��O�O�D�O�O�,?�@�A�		B�s�
�A"A1�0A1c�~�tddt���}tj|�}|j	d|�y)zk
        If unable to obtain a traceback due to an exception, catch it and note
        the error.
        rr7rAz
(unable to obtain traceback)N)r$�objectrr%�assertInr's   r�test_noTracebackForYouz-TextFromEventDictTests.test_noTracebackForYoucs3����Q���A�	��$�$�Y�/���
�
�6��=rN��return�None)
rrrrr+r1r5r?rBrFrrrrr*s&���(�/� �6�
B�>rrc�T�eZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zy
)�LogTestsc���g|_|jj|_tj|j�|jtj|j�y�N)�catcher�append�observerr�addObserver�
addCleanup�removeObserver�r(s r�setUpzLogTests.setUposB��,.������+�+��
�����
�
�&�����*�*�D�M�M�:rc��|j}tjdd��|j�}|j	|ddd�|j|d�|j
d|�|j	t|�d�y)N�testT)�testShouldCatchr"rrX�time)rNr�msg�popr&r=rE�len�r(rN�is   r�testObservationzLogTests.testObservationusp���,�,�������-��K�K�M������9��a��&�1�����+�,�-��
�
�f�a� �����W��q�)rc�d�|j}tjdddd�tjdditjdd�	�|j	�}|j|dd�|j|d
d�|j|dd�|j|dd
d�y)Nznot the defaultrr!)�	subsystem�subsubsystem�otherrbr r0�d)rcrarcr"r)rNr�callWithContextrZr[r&r]s   r�testContextzLogTests.testContext~s����,�,�����+�S�3�O����
�S�!��G�G���
	
�
�K�K�M������>�*�C�0�����;��):�;�����7��S�)�����9��a��%�0rc�&�dt�tftjt��tffD]Z\}}t	j
|�|jj�}|j|dd�|j|��\y)N��hello worldrir.r7�
�KeyErrorrr<r:r�errrNr[r&�flushLoggedErrors�r(�e�igr^s    r�
testErrorszLogTests.testErrors�sx��*�
�Z��"�
�_�_�\�^�
,�l�;�
�	'�E�A�r�

�G�G�A�J���� � �"�A����Q�y�\�1�-��"�"�2�&�	'rc�R�dt�tftjt��tffD]p\}}t	j
|d�|jj�}|j|dd�|j|dd�|j|��ry)Nrh�foobarr.r7r8rjrns    r�testErrorsWithWhyzLogTests.testErrorsWithWhy�s���*�
�Z��"�
�_�_�\�^�
,�l�;�
�		'�E�A�r�

�G�G�A�x� ���� � �"�A����Q�y�\�1�-����Q�u�X�x�0��"�"�2�&�		'rc�f�g}g}dd�}|j||jfD]7}tj|�|jtj|��9td�D]�}g|ddg|ddtjdg��|jt�}|jdd�=|jt|�d�|jt|�d�|jt|�d�|j|dd	d
�|j|dd	d
���y)a
        Exceptions raised by log observers are logged but the observer which
        raised the exception remains registered with the publisher.  These
        exceptions do not prevent the event from being sent to other observers
        registered with the publisher.
        c��ddzy�Nr7rr)�events r�brokenz-LogTests.test_erroneousErrors.<locals>.broken�s	��
��Fr�N�
Howdy, y'all.)�	log_tracer7�rr")r{�rx�
log.EventDictrHrI)rOrrQrRrS�rangerZrm�ZeroDivisionErrorrNr&r\)r(�L1�L2ryrPr^�excss       r�test_erroneousErrorszLogTests.test_erroneousErrors�s��#%��"$��	����F�B�I�I�6�	:�H��O�O�H�%��O�O�C�.�.��9�	:��q��	C�A��B�q�E��B�q�E�
�G�G�O�r�2��)�)�*;�<�D����Q�����S��Y��*�
���S��W�a�(����S��W�a�(�
���R��U�9�-�/A�B����R��U�9�-�/A�B�)	Crc�2�tj�}|j|j�|j	td�t
dd�|jj�}|j|d|zd�|j|jg�|j	td�t
ddt���|jj�}|j|d|zd�|j|jg�y)zy
        L{twisted.python.log.showwarning} emits the warning as a message
        to the Twisted logging system.
        zunique warning message�warning-filename.py�r/zQwarning-filename.py:27: twisted.test.test_log.FakeWarning: unique warning message)�lineN)
rrrQrP�showwarningrrNr[r&rD)r(�	publisherrxs   r�test_showwarningzLogTests.test_showwarning�s��
�$�$�&�	����d�m�m�,�����0�1��!��		
���� � �"������(�O�e�#�
%�	
�
	
������r�*�
	����0�1��!����	�	
���� � �"������(�O�e�#�
%�	
�
	
������r�*rc
��d}t}d}d}t�}tj|||||��|j	|j�t
j||||��d}t�}tj||||||��|j	|j�t
j|||||��y)z�
        L{twisted.python.log.showwarning} passes warnings with an explicit file
        target on to the underlying Python warning system.
        zanother unique messager����fileri)r�r�N)rrrr�r&�getvalue�warnings�
formatwarning)r(r"�category�filename�lineno�outputr�s       r�test_warningToFilezLogTests.test_warningToFile�s���
+����(������������8�V�&�I�����O�O���"�"�7�H�h��G�	
�����������8�V�&�t�T�����O�O���"�"�7�H�h���M�	
rc�b��g�d�fd�}dd�}tj�}|j|�|j|�|jd�|j	t|j�||h�|j	t��d�|j�dt�y)zk
        Log publisher does not use the global L{log.err} when reporting broken
        observers.
        c�f��|jd�r�j|dj�yy�Nr.r)�getrO�value)r)�errorss �r�logErrorzHLogTests.test_publisherReportsBrokenObserversPrivately.<locals>.logErrors+����}�}�Y�'��
�
�i�	�2�8�8�9�(rc��td��)N�*test_publisherLocalyReportsBrokenObservers)r:�r)s r�failzDLogTests.test_publisherReportsBrokenObserversPrivately.<locals>.fails���K�L�Lr�Hello!r7rN�r)rrHrI)
rrrQrZr&�set�	observersr\�assertIsInstancer:)r(r�r�r�r�s    @r�-test_publisherReportsBrokenObserversPrivatelyz6LogTests.test_publisherReportsBrokenObserversPrivatelys����
��	:�	M��$�$�&�	����h�'����d�#��
�
�h������Y�0�0�1�H�d�3C�D�����V��a�(����f�Q�i��6rNrG)rrrrUr_rfrqrtr�r�r�r�rrrrKrKns2��;�*�1� 	'�
'�%C�N&+�P
�<7rrKc��eZdZdd�Zdd�Zy)�FakeFilec�&�|j|�yrM�rO)r(�bytess  r�writezFakeFile.write+s�����E�rc��yrMrrTs r�flushzFakeFile.flush.s��rN)r�r�rHrIrG)rrrr�r�rrrr�r�*s���
rr�c��eZdZdd�Zy)�EvilStrc��tddz�Srw��strrTs r�__str__zEvilStr.__str__6����1��6�{�rN�rHr�)rrrr�rrrr�r�5s��rr�c��eZdZdd�Zdd�Zy)�EvilReprc��y)NzHappy Evil ReprrrTs rr�zEvilRepr.__str__;s�� rc��tddz�Srwr�rTs r�__repr__zEvilRepr.__repr__>r�rNr�)rrrr�r�rrrr�r�:s��!�rr�c��eZdZy)�EvilReprStrN)rrrrrrr�r�Bs��rr�c�0�eZdZUded<								dd�Zy)�_LogPublisherTestCaseMixinBaser��outc��yrMr)r(�instance�classOrTupler"s    rr�z/_LogPublisherTestCaseMixinBase.assertIsInstanceIs��	rN)r�rDr��typer"r�rHrI)rrr�__annotations__r�rrrr�r�Fs,��	�M����.2��=@��	
�rr�c��eZdZdd�Zdd�Zy)�LogPublisherTestCaseMixinc��t�|_tj�|_tj
|j�|_|jj|jj�y)z�
        Add a log observer which records log events in C{self.out}.  Also,
        make sure the default string encoding is ASCII so that
        L{testSingleUnicode} can test the behavior of logging unencodable
        unicode messages.
        N)	r�r�rr�lp�FileLogObserver�florQ�emitrTs rrUzLogPublisherTestCaseMixin.setUpPsM���:����"�"�$����&�&�t�x�x�0��������D�H�H�M�M�*rc�Z�|jD]}|j|t|�d���y)z�
        Verify that everything written to the fake file C{self.out} was a
        C{str}.  Also, restore the default string encoding to its previous
        setting, if it was modified by L{setUp}.
        z was not a stringN)r�r�r�)r(�chunks  r�tearDownz"LogPublisherTestCaseMixin.tearDown\s3���X�X�	M�E��!�!�%���	�9J�.K�L�	MrNrG)r(r�rHrI)rrrrUr�rrrr�r�Os
��
+�Mrr�c�$�eZdZdd�Zdd�Zdd�Zy)�LogPublisherTestsc��|jjd�|jt|j�d�y)N�
Hello, world.r7�r�rZr&r\r�rTs r�testSingleStringz"LogPublisherTests.testSingleStringgs*�������O�$�����T�X�X���*rc��|jjdd�|jt|j�d�y)NzHello, zworld.r7r�rTs r�testMultipleStringz$LogPublisherTests.testMultipleStringks.��	
�����I�x�(�����T�X�X���*rc���d}|jj|�|jt|j�d�|j||jd�y)z�
        L{log.LogPublisher.msg} does not accept non-ASCII Unicode on Python 2,
        logging an error instead.

        On Python 3, where Unicode is default message type, the message is
        logged normally.
        �Hello, ½ world.r7rN)r�rZr&r\r�rE)r(r"s  r�test_singleUnicodez$LogPublisherTests.test_singleUnicodersG��?�������G������T�X�X���*��
�
�g�t�x�x��{�+rNrG)rrrr�r�r�rrrr�r�fs��+�+�,rr�c���eZdZdZdZdZdZdZdZdZ	dZ
								d d	�Zd!d
�Zd!d�Z
d!d�Zd!d
�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Zd!d�Z y)"�FileObserverTestsz(
    Tests for L{log.FileObserver}.
    zInvalid format stringzUNFORMATTABLE OBJECTz<Invalid format string or unformattable object in log messagezPATHOLOGICAL ERRORzUnable to format eventz[UNFORMATTABLE]z)MESSAGE LOST: unformattable object loggedc���ttdd��tjd��tj
j
dd�}	|tj
d<tj�d}tj|�}d}	tj|�}|j|jj|�|jj|�f||f�|�tj
d=n|tj
d<tj�y#t$r||k(r|}n�Y��wxYw#|�tj
d=n|tj
d<tj�wxYw)ay
        Verify that L{getTimezoneOffset} produces the expected offset for a
        certain timezone both when daylight saving time is in effect and when
        it is not.

        @param tzname: The name of a timezone to exercise.
        @type tzname: L{bytes}

        @param daylightOffset: The number of seconds west of UTC the timezone
            should be when daylight saving time is in effect.
        @type daylightOffset: L{int}

        @param standardOffset: The number of seconds west of UTC the timezone
            should be when daylight saving time is not in effect.
        @type standardOffset: L{int}
        �tzsetNzWPlatform cannot change timezone, cannot verify correct offsets in well-known timezones.�TZ)	i�r7r�rrrr}r�r)	i���rrr��r7)
�getattrrYr�SkipTest�os�environr�r��mktime�
OverflowErrorr&r��getTimezoneOffset)	r(�tzname�daylightOffset�standardOffset�originalTimezone�localStandardTuple�standard�localDaylightTuple�daylights	         r�_getTimezoneOffsetTestz(FileObserverTests._getTimezoneOffsetTest�sU��&�4��$�'�/��#�#�3��
�
�:�:�>�>�$��5��*	�%�B�J�J�t���J�J�L�"B���{�{�#5�6�H�"C��
��;�;�'9�:��
����H�H�.�.�x�8��H�H�.�.�x�8�� ��0�
� �'��J�J�t�$�#3��
�
�4� ��J�J�L��1!�

�"�^�3�'�H���

��( �'��J�J�t�$�#3��
�
�4� ��J�J�L�s2�AD:�	D"�AD:�"D7�4D:�6D7�7D:�:=E7c�*�|jddd�y)a!
        Attempt to verify that L{FileLogObserver.getTimezoneOffset} returns
        correct values for the current C{TZ} environment setting for at least
        some cases.  This test method exercises a timezone that is west of UTC
        (and should produce positive results).
        zAmerica/New_Yorki@8�PFN�r�rTs r�test_getTimezoneOffsetWestOfUTCz1FileObserverTests.test_getTimezoneOffsetWestOfUTC�s��	
�#�#�$6��u�Erc�*�|jddd�y)a!
        Attempt to verify that L{FileLogObserver.getTimezoneOffset} returns
        correct values for the current C{TZ} environment setting for at least
        some cases.  This test method exercises a timezone that is east of UTC
        (and should produce negative results).
        z
Europe/Berlin������Nr�rTs r�test_getTimezoneOffsetEastOfUTCz1FileObserverTests.test_getTimezoneOffsetEastOfUTC�s��	
�#�#�O�U�E�Brc�*�|jddd�y)af
        Attempt to verify that L{FileLogObserver.getTimezoneOffset} returns
        correct values for the current C{TZ} environment setting for at least
        some cases.  This test method exercises a timezone that does not use
        daylight saving time at all (so both summer and winter time test values
        should have the same offset).
        zAfrica/Johannesburgr�Nr�rTs r�/test_getTimezoneOffsetWithoutDaylightSavingTimezAFileObserverTests.test_getTimezoneOffsetWithoutDaylightSavingTime�s��	
�#�#�$9�5�%�Hrc��tjd�}d�|j_|j	|jj|�d�d�|j_|j	|jj|�d�d�|j_|j	|jj|�d�d�|j_|j	|jj|�d	�d
�|j_|j	|jj|�d�d�|j_|j	|jj|�d
�d�|j_|j	|jj|�d�d|j_|j	|jj|�d�y)zu
        Test the method of L{FileLogObserver} which turns a timestamp into a
        human-readable string.
        )	i�r}rzr��r���rc��y)Nr�r��whens r�<lambda>z7FileObserverTests.test_timeFormatting.<locals>.<lambda>���rz2001-02-02 23:05:06-0500c��y)Nr�rrs rrz7FileObserverTests.test_timeFormatting.<locals>.<lambda>r	rz2001-02-03 05:05:06+0100c��y)NiPe��rrs rrz7FileObserverTests.test_timeFormatting.<locals>.<lambda>r	rz2001-02-03 15:05:06+1100c��y)Nirrs rrz7FileObserverTests.test_timeFormatting.<locals>.<lambda>r	rz2001-02-03 02:35:06-0130c��y)Ni��rrs rrz7FileObserverTests.test_timeFormatting.<locals>.<lambda>r	rz2001-02-03 05:35:06+0130c��y)Nirrs rrz7FileObserverTests.test_timeFormatting.<locals>.<lambda>r	rz2001-02-03 03:35:06-0030c��y)Ni����rrs rrz7FileObserverTests.test_timeFormatting.<locals>.<lambda>r	rz2001-02-03 04:35:06+0030z%Y %mz2001 02N)�calendar�timegmr�r�r&�
formatTime�
timeFormat)r(rs  r�test_timeFormattingz%FileObserverTests.test_timeFormatting�s���
���=�>��&8����"�������,�,�T�2�4N�O�&8����"�������,�,�T�2�4N�O�&9����"�������,�,�T�2�4N�O�&7����"�������,�,�T�2�4N�O�&8����"�������,�,�T�2�4N�O�&7����"�������,�,�T�2�4N�O�&8����"�������,�,�T�2�4N�O�&�����������,�,�T�2�I�>rc�|�d|j_|jd|jjd��y)z�
        L{FileLogObserver.formatTime} supports a value of C{timeFormat} which
        includes C{"%f"}, a L{datetime}-only format specifier for microseconds.
        z%f�600000g�����m�@N)r�rr&rrTs r�#test_microsecondTimestampFormattingz5FileObserverTests.test_microsecondTimestampFormattings/��
#���������4�8�8�#6�#6�x�#@�Arc���|jjt��|jt	|j
�d�|j
|j|j
d�yrw)r�rZr�r&r\r��assertNotIn�ERROR_UNFORMATTABLE_OBJECTrTs r�%test_loggingAnObjectWithBroken__str__z7FileObserverTests.test_loggingAnObjectWithBroken__str__'sJ�������G�I������T�X�X���*�����8�8�$�(�(�1�+�Frc���|jjdt���|jt	|j
�d�|j
|j|j
d�y�Nz%(blat)s�r/�blatr7r)r�rZr�r&r\r�rE�ERROR_INVALID_FORMATrTs r�(test_formattingAnObjectWithBroken__str__z:FileObserverTests.test_formattingAnObjectWithBroken__str__.sL�������:�G�I��6�����T�X�X���*��
�
�d�/�/����!��=rc���|jjdt���|jt	|j
�d�|j
|j|j
d�y�N�huh)�systemr7r)r�rZr�r&r\r�rE�ERROR_FORMATrTs r�test_brokenSystem__str__z*FileObserverTests.test_brokenSystem__str__3sL�������E�'�)��,�����T�X�X���*��
�
�d�'�'����!��5rc���|jjdt�g��|jt	|j
�d�|j
|j|j
d�yr�r�rZr�r&r\r�rErrTs r�1test_formattingAnObjectWithBroken__repr__IndirectzCFileObserverTests.test_formattingAnObjectWithBroken__repr__Indirect8sN�������:�X�Z�L��9�����T�X�X���*��
�
�d�5�5�t�x�x��{�Crc���|jjdt�g��|jt	|j
�d�|j
|j|j
d�yr#r)rTs r�%test_systemWithBroker__repr__Indirectz7FileObserverTests.test_systemWithBroker__repr__Indirect=sN�������E�8�:�,��/�����T�X�X���*��
�
�d�5�5�t�x�x��{�Crc���|jjdd��|jt|j�d�|j|j|jd�y)Nz
hooj %s %sr7rr�r�rZr&r\r�rEr rTs r�test_simpleBrokenFormatz)FileObserverTests.test_simpleBrokenFormatBsJ�������<�a��0�����T�X�X���*��
�
�d�/�/����!��=rc���|jjdd��|jt|j�d�|j|j|jd�y)N�*r7rrr.rTs r�test_ridiculousFormatz'FileObserverTests.test_ridiculousFormatGsJ�������2�A��&�����T�X�X���*��
�
�d�/�/����!��=rc���|jjt�d��|jt	|j
�d�|j
|j|j
d�y)Nr7rr)r�rZr�r&r\r�rE�ERROR_PATHOLOGICALrTs r�!test_evilFormat__repr__And__str__z3FileObserverTests.test_evilFormat__repr__And__str__LsL�������;�=�q��1�����T�X�X���*��
�
�d�-�-�t�x�x��{�;rc��|jjdd��|jt|j�d�y)zP
        This kind of eventDict used to fail silently, so test it does.
        �Fr3rNr�rTs r�test_strangeEventDictz'FileObserverTests.test_strangeEventDictQs0��	
�����B���.�����T�X�X���*rc��|jtjj�|jtt
dt
j�|jtt
dt
j�y)zm
        Cleanup after a startLogging() call that mutates the hell out of some
        global state.
        �stdout�stderrN)rRr�theLogPublisher�_stopLogging�setattr�sysr:r;rTs r�_startLoggingCleanupz&FileObserverTests._startLoggingCleanupXsH��
	
����+�+�8�8�9������h��
�
�;������h��
�
�;rc���|j�t�}tj|�d�fd�}g�tj|�tdtj��|j�ddd�y)	zs
        startLogging()'s overridden sys.stderr should consider everything
        written to it an error.
        c�(���j|�yrMr�)rx�observeds �r�observez@FileObserverTests.test_printToStderrSetsIsError.<locals>.observejs����O�O�E�"rr�r�rr.r7Nr~)	r@rr�startLoggingrQ�printr?r;r&)r(�fakeFilerDrCs   @r�test_printToStderrSetsIsErrorz/FileObserverTests.test_printToStderrSetsIsErrorase���
	
�!�!�#��:������"�	#�)+������ �
�o�C�J�J�/�����!��Y�/��3rc�V�tjtj}}|j�t	�}tj|�}|j|j�tjd�|jd|j��|jtjt�|jtjjt j"�t%|dd�}|stj&�}|jtjj(j+�|j+��|jtjt�|jtjjt j,�t%|dd�}|stj&�}|jtjj(j+�|j+��y)zj
        startLogging() installs FileLogObserver and overrides sys.stdout and
        sys.stderr.
        r��encodingN)r?r:r;r@rrrErR�stoprZrEr�r�rr&�level�NewLogLevel�infor��getdefaultencodingrJ�upper�error)r(�
origStdout�
origStderrrGrPrJs      r�test_startLoggingz#FileObserverTests.test_startLoggingsse��
"%���S�Z�Z�J�
��!�!�#��:���#�#�H�-������
�
�&�������
�
�h�� 1� 1� 3�4����c�j�j�+�6�������)�)�;�+;�+;�<��:�z�4�8����-�-�/�H�������,�,�2�2�4�h�n�n�6F�G����c�j�j�+�6�������)�)�;�+<�+<�=��:�z�4�8����-�-�/�H�������,�,�2�2�4�h�n�n�6F�Grc�&�|j�t�t_dd�}t	j
|�|j
tj|�t	jtj�}|j
|j�|jtjt�tj}t	jtj�}|jtj|�y)z�
        There are some obscure error conditions that can occur when logging is
        started twice. See http://twistedmatrix.com/trac/ticket/3289 for more
        information.
        c�p�|dr1tjj|dj��yyr�)r?�
__stdout__r��getTracebackr�s r�	showErrorz;FileObserverTests.test_startLoggingTwice.<locals>.showError�s/����#����$�$�Y�y�%9�%F�%F�%H�I�$rNr�)
r@rr?r:rrQrRrSrErKr�r�assertIs)r(rYrP�
fakeStdouts    r�test_startLoggingTwicez(FileObserverTests.test_startLoggingTwice�s���	
�!�!�#��Z��
�	J�	���	�"�����*�*�I�6��#�#�C�J�J�/������
�
�&����c�j�j�+�6��Z�Z�
��#�#�C�J�J�/���
�
�c�j�j�*�-rc
�l��|j�t�}Gd�d�}t||t|t	�|t
���}|j
td|�dt_t	�}ddi}g�tt�G�fd�d	��}||�|j|��tj|d
��|j|j�|j�g�tj d�|j#�}|j%d
|�y)z�
        startLogging() overrides global C{warnings.showwarning} such that
        warnings go to Twisted log observers.
        c�(�eZdZe�Ze�Zy)�FFileObserverTests.test_startLoggingOverridesWarning.<locals>.SysModuleN)rrrrDr:r;rrr�	SysModuler_�s���X�F��X�Frr`)�logBeginnerr<N�	pre-startrxc���eZdZd�fd�Zy)�MFileObserverTests.test_startLoggingOverridesWarning.<locals>.PreStartObserverc�N��d|j�vr�j|�yy)Nrb)�keysrO)r(r)�receiveds  �r�__call__zVFileObserverTests.test_startLoggingOverridesWarning.<locals>.PreStartObserver.__call__�s#����)�.�.�"2�2��O�O�I�.�3rNr�)rrrrh)rgs�r�PreStartObserverrd�s���
/rriF)�	setStdoutzhello!zUserWarning: hello!)r@�NewLogPublisherrrrr��patchr�_oldshowwarningrr
rQrErRr=r&�warnr�rE)	r(�newPublisherr`�tempLogPublisherrG�evtrir�rgs	        @r�!test_startLoggingOverridesWarningz3FileObserverTests.test_startLoggingOverridesWarning�s���
	
�!�!�#�&�(��	�	�(���#�L�(�*�i��R�
��	
�
�
�3�)�+;�<�#����:���G�$����	�\�	"�	/�	/�
#�	/�	�S��� � �!1�!3�4�����U�3����(�5�5�6�����2�&��
�
�h���"�"�$���
�
�+�V�4rc����t�}tj|��g�d��fd�}tj�}|j	|�|jd�|j
t��d��d}|j�}dj�j|d�|d��}|j|j|�|�d	|���y
)zk
        FileLogObserver.emit() will add a timestamp and system prefix to its
        file output.
        c�J���j|��j|�yrM)rOr�)rx�eventsr�s ��rrPz3FileObserverTests.test_emitPrefix.<locals>.observer�s����M�M�%� ��H�H�U�Orr�r7rz{time} [{system}] rYr%)rYr%z does not start with Nr~)
rrr�rrQrZr&r\r�r/rr=r>)	r(r�rPr�rx�result�prefixrur�s	       @@r�test_emitPrefixz!FileObserverTests.test_emitPrefix�s����
����!�!�&�)����	�
�$�$�&�	����h�'��
�
�h������V��a�(��q�	�����"��%�,�,�����f�
�.���?�-�
��
	
������f�%��j�-�f�Z�8�	
rc�2�t�}tj|�}tj�}|j	|j
�|j
d�|j�}d}|j|j|�|�d|���y)zR
        FileLogObserver.emit() will append a newline to its file output.
        r�zHello!
z does not end with N)
rrr�rrQr�rZr�r=�endswith)r(r�r�r�rv�suffixs      r�test_emitNewlinez"FileObserverTests.test_emitNewline�s������!�!�&�)���$�$�&�	����c�h�h�'��
�
�h�����"��������O�O�F�#��j�+�F�:�6�	
rN)r�r�r��intr�r}rHrIrG)!rrrrr rr&r4�ERROR_NO_FORMAT�ERROR_UNFORMATTABLE_SYSTEM�ERROR_MESSAGE_LOSTr�r�r�rrrrr!r'r*r,r/r2r5r8r@rHrTr\rrrxr|rrrr�r��s����3��!7��Q�L�-��.�O�!2��D��D��D�+.�D�@C�D�	
�D�LF�C�I�)?�VB�G�>�
6�
D�
D�
>�
>�
<�
+�<�4�$H�4.�435�j
�@
rr�c�@�eZdZdZd	d�Zd	d�Zd	d�Zd	d�Zd	d�Zd	d�Z	y)
�PythonLoggingObserverTestsz5
    Test the bridge with python logging module.
    c�����tjd���j���jtj��j
d��fd��}t
�\�_�_�j�j��j
d��fd��}tj��_tj��_�jj�jj �y)Nr7c�(���j��yrM)�setLevel)�
originalLevel�
rootLoggers��r�restoreLevelz6PythonLoggingObserverTests.setUp.<locals>.restoreLevels������
�.rc�p���j�j��jj�yrM)�
removeHandler�hdlr�close)r�r(s��r�removeLoggerz6PythonLoggingObserverTests.setUp.<locals>.removeLogger"s#����$�$�T�Y�Y�/��I�I�O�O�rrG)�logging�	getLogger�getEffectiveLevelr��DEBUGrRrr�r��
addHandlerrrr��PythonLoggingObserver�obsrQr�)r(r�r�r�r�s`  @@rrUz PythonLoggingObserverTests.setUps�����&�&�r�*�
�"�4�4�6�
����G�M�M�*�	
���	/�
�	/�0�1���	�4�8����d�i�i�(�	
���	�
�	��"�"�$����,�,�.��������D�H�H�M�M�*rc���|jjd�|jd|jj	��|jd|jj	��y)z<
        Test simple output, and default log level.
        r�s
Hello, world.sINFON�r�rZrEr�r�rTs r�test_singleStringz,PythonLoggingObserverTests.test_singleString+sK��	
�����O�$��
�
�&����(9�(9�(;�<��
�
�g�t�x�x�0�0�2�3rc��tjtd��}|jj	|d��d}|j
j
�}|j|j|�d|�d|���y)z$
        Test error output.
        zThat is bad.T)rr.s	CRITICAL:zDoes not start with z: N)	rr<�
ValueErrorr�rZr�r�r=r>)r(�frwr�s    r�test_errorStringz+PythonLoggingObserverTests.test_errorString3sl��
�O�O�J�~�6�7�������A�t��,������"�"�$��������f�%�"�6�*�B�v�j�9�	
rc��|jjddd��|jd|jj	��y)z-
        Test logging with a format.
        z%(bar)s oo %(foo)s�Hello�world)r/�barr0sHello oo worldNr�rTs r�test_formatStringz,PythonLoggingObserverTests.test_formatString@s7��	
�����/�W�'��J��
�
�'����):�):�)<�=rc�l�|jjdtj��|j	d|j
j
��|j	d|j
j
��|j
jdd�|j
j�|jjdtj��|j	d|j
j
��|j	d|j
j
��y	)
zG
        Test the logLevel keyword for customizing level used.
        z	Spam egg.)�logLevels	Spam egg.sERRORrzFoo bar.sFoo bar.sWARNINGN)
r�rZr��ERRORrEr�r��seek�truncate�WARNINGrTs r�test_customLevelz+PythonLoggingObserverTests.test_customLevelGs���	
�����K�'�-�-��8��
�
�l�D�H�H�$5�$5�$7�8��
�
�h���� 1� 1� 3�4����
�
�a��������������J�����9��
�
�k�4�8�8�#4�#4�#6�7��
�
�j�$�(�(�"3�"3�"5�6rc��|jjdd��|j|jj	�d�y)zx
        Verify that an event dictionary which is not an error and has an empty
        message isn't recorded.
        r7Fr3rN)r�rZr&r�r�rTs rr8z0PythonLoggingObserverTests.test_strangeEventDictTs5��
	
�����B���.�������*�*�,�c�2rNrG)
rrrrrUr�r�r�r�r8rrrr�r�s%���+�*4�
�>�7�3rr�c� �eZdZdZdd�Zdd�Zy)�PythonLoggingIntegrationTestsz4
    Test integration of python logging bridge.
    c���tj}tj}g}	|jt_|jt_tj
�}|j
�|j|d|j�|j�|jt|�d�|t_|t_y#|t_|t_wxYw)z~
        Test that start and stop methods of the observer actually register
        and unregister to the log system.
        rN)rrQrSrO�remover��startr&r�rKr\)r(�oldAddObserver�oldRemoveObserver�lr�s     r�test_startStopObserverz4PythonLoggingIntegrationTests.test_startStopObserverbs���
�����.�.��35��
	3��h�h�C�O�!"���C���+�+�-�C��I�I�K����Q�q�T�3�8�8�,��H�H�J����S��V�Q�'�,�C�O�!2�C���-�C�O�!2�C��s�BC�C+c�j�Gd�dtj�}|�}g}tjj}	|jtj_|jddi�|j	|ddig�|tj_y#|tj_wxYw)z�
        Test that we can inherit L{log.PythonLoggingObserver} and use super:
        that's basically a validation that L{log.PythonLoggingObserver} is
        new-style class.
        c� ��eZdZd�fd�Z�xZS)�BPythonLoggingIntegrationTests.test_inheritance.<locals>.MyObserverc�$��t�|�|�yrM)�superr�)r(r)�	__class__s  �rr�zGPythonLoggingIntegrationTests.test_inheritance.<locals>.MyObserver.emit~s������Y�'rr�)rrrr��
__classcell__)r�s@r�
MyObserverr�}s
���
(�
(rr�r0r�N)rr�r�rOr&)r(r�r�r��oldEmits     r�test_inheritancez.PythonLoggingIntegrationTests.test_inheritancevs���	(��2�2�	(��l��!#���+�+�0�0��	5�-.�X�X�C�%�%�*��H�H�e�U�^�$����Q�%��� 0�1�-4�C�%�%�*��W�C�%�%�*�s�AB�B2NrG)rrrrr�r�rrrr�r�]s���3�(5rr�c� �eZdZdZdd�Zdd�Zy)�DefaultObserverTestsz$
    Test the default observer.
    c�`�g|_|jj|_tj|j�|jtj|j�tj�}t�|_	|j�|j|j�d}tjt�|�|j�}|j||jj!��|j#t%|�d�y)zu
        The reason argument passed to log.err() appears in the report
        generated by DefaultObserver.
        zThe reason.r7N)rNrOrPrrQrRrS�DefaultObserverrr;r�rKrl�	ExceptionrmrEr�r&r\)r(r��reasonr�s    r�test_failureLoggerz'DefaultObserverTests.test_failureLogger�s���
-/������+�+��
�����
�
�&�����*�*�D�M�M�:��!�!�#���Z��
��	�	��������!������	��V�$��'�'�)���
�
�f�c�j�j�1�1�3�4�����V��a�(rc�6�Gd�d�}d|�f}t|d��}tj�}t�5}||_|j|�|j
|j�jd��ddd�y#1swYyxYw)z�
        DefaultObserver.emit() does not raise when it observes an error event
        with a message that causes L{repr} to raise.
        c��eZdZdd�Zy)�?DefaultObserverTests.test_emitEventWithBrokenRepr.<locals>.Ouchc��tddz�Srwr�rTs rr�zHDefaultObserverTests.test_emitEventWithBrokenRepr.<locals>.Ouch.__repr__�s���1�q�5�z�!rNr�)rrrr�rrr�Ouchr��s��
"rr�r0r7r3zfoo <Ouch instanceN)	r$rr�rr;r�r=r�r>)r(r�r"rxrPr�s      r�test_emitEventWithBrokenReprz1DefaultObserverTests.test_emitEventWithBrokenRepr�s���	"�	"��$�&�/���W�a�0���&�&�(��
�Z�	P�6�$�H�O��M�M�%� ��O�O�F�O�O�-�8�8�9M�N�O�	P�	P�	P�s�AB�BNrG)rrrrr�r�rrrr�r��s���)�,Prr�c�X�eZdZdZdd�Zdd�Zd
d�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zy)�StdioOnnaStickTestszF
    StdioOnnaStick should act like the normal sys.stdout object.
    c�d�g|_tj|jj�yrM)�
resultLogsrrQrOrTs rrUzStdioOnnaStickTests.setUp�s��/1���������.�.�/rc�V�tj|jj�yrM)rrSr�rOrTs rr�zStdioOnnaStickTests.tearDown�s�����4�?�?�1�1�2rc�d�|jD�cgc]}dj|d���c}Scc}w)Nr7r")r��join)r(rds  r�getLogMessagesz"StdioOnnaStickTests.getLogMessages�s'��/3���?�!�����)��%�?�?��?s�-c��tj�}|jd�|j|j	�dg�|jd�|j|j	�ddg�y)z�
        Writing to a StdioOnnaStick instance results in Twisted log messages.

        Log messages are generated every time a '\n' is encountered.
        zHello there
This is a testzHello therez!
zThis is a test!N)r�StdioOnnaStickr�r&r��r(�stdios  r�
test_writezStdioOnnaStickTests.test_write�se���"�"�$��
���1�2�����,�,�.���@�
���E������,�,�.��@Q�0R�Src���tj�}|jd�|j|jdd�|j|jdd�y)z{
        The log messages written by StdioOnnaStick have printed=1 keyword, and
        by default are not errors.
        zhello
rr.�printedN)rr�r��assertFalser�r=r�s  r�
test_metadataz!StdioOnnaStickTests.test_metadata�sT��
�"�"�$��
���I���������+�I�6�7��������*�9�5�6rc��tj�}|jddg�|j|j	�ddg�y)zT
        Writing lines to a StdioOnnaStick results in Twisted log messages.
        zlog 1zlog 2N)rr��
writelinesr&r�r�s  r�test_writeLinesz#StdioOnnaStickTests.test_writeLines�sC���"�"�$��
���'�7�+�,�����,�,�.��'�0B�Crc��tj}tj�t_|j	t
td|�t
dd��t
d�|j|j�dg�y)zW
        When StdioOnnaStick is set as sys.stdout, prints become log messages.
        r:�This� )�endz	is a testzThis is a testN)	r?r:rr�rRr>rFr&r�)r(�	oldStdouts  r�
test_printzStdioOnnaStickTests.test_print�s^���J�J�	��'�'�)��
������h�	�:�
�f�#��
�k������,�,�.�1A�0B�Crc��tjd��}|jd�|j|jdd�y)zR
        StdioOnnaStick created with isError=True log messages as errors.
        T)r.zlog 1
rr.N)rr�r�r=r�r�s  r�
test_errorzStdioOnnaStickTests.test_error�s:���"�"�4�0��
���I���������*�9�5�6rc��d}tjd��}|j|jd�|j	|dz�|jd|zg�tj}|t_|jttd|�t|�|j|j�|d|z|g�y)z�
        StdioOnnaStick converts unicode prints to byte strings on Python 2, in
        order to be compatible with the normal stdout/stderr objects.

        On Python 3, the prints are left unmodified.
        r�zutf-8)rJ�
zAlso, r:N)rr�r&rJr�r�r?r:rRr>rFr�)r(�
unicodeStringr�r�s    r�test_unicodez StdioOnnaStickTests.test_unicode�s���E�
��"�"�G�4���������1�
���M�D�(�)�
���(�]�2�3�4��J�J�	���
������h�	�:�
�m��������!�
�H�}�4�m�D�	
rNrG)rHz	list[str])
rrrrrUr�r�r�r�r�r�r�r�rrrr�r��s8���0�3�@�
T�7�D�	D�7�
rr�)5r�
__future__rrr�r�r?rYr��iorr�typingrr�zope.interfacerr	�twisted.loggerr
rrr
rMrrk�twisted.logger.test.test_stdlibr�twisted.pythonrr�twisted.python.log�
twisted.trialr�Warningr�SynchronousTestCaserrKr�r��registerr�r�r�r�r�r�r�r�r�r�r�rrr�<module>r�sS���#���	�
����!�&����>�'�+�"��'��A>�X�9�9�A>�Hy7�x�+�+�y7�x
�t�E�{�
���������
��	�'�8�	��X��M�M�.,�1�8�3O�3O�,�4N
�1�8�3O�3O�N
�bI3��!=�!=�I3�X,5�H�$@�$@�,5�^,P�8�7�7�,P�^T
�(�6�6�T
r
¿Qué es la limpieza dental de perros? - Clínica veterinaria


Es la eliminación del sarro y la placa adherida a la superficie de los dientes mediante un equipo de ultrasonidos que garantiza la integridad de las piezas dentales a la vez que elimina en profundidad cualquier resto de suciedad.

A continuación se procede al pulido de los dientes mediante una fresa especial que elimina la placa bacteriana y devuelve a los dientes el aspecto sano que deben tener.

Una vez terminado todo el proceso, se mantiene al perro en observación hasta que se despierta de la anestesia, bajo la atenta supervisión de un veterinario.

¿Cada cuánto tiempo tengo que hacerle una limpieza dental a mi perro?

A partir de cierta edad, los perros pueden necesitar una limpieza dental anual o bianual. Depende de cada caso. En líneas generales, puede decirse que los perros de razas pequeñas suelen acumular más sarro y suelen necesitar una atención mayor en cuanto a higiene dental.


Riesgos de una mala higiene


Los riesgos más evidentes de una mala higiene dental en los perros son los siguientes:

  • Cuando la acumulación de sarro no se trata, se puede producir una inflamación y retracción de las encías que puede descalzar el diente y provocar caídas.
  • Mal aliento (halitosis).
  • Sarro perros
  • Puede ir a más
  • Las bacterias de la placa pueden trasladarse a través del torrente circulatorio a órganos vitales como el corazón ocasionando problemas de endocarditis en las válvulas. Las bacterias pueden incluso acantonarse en huesos (La osteomielitis es la infección ósea, tanto cortical como medular) provocando mucho dolor y una artritis séptica).

¿Cómo se forma el sarro?

El sarro es la calcificación de la placa dental. Los restos de alimentos, junto con las bacterias presentes en la boca, van a formar la placa bacteriana o placa dental. Si la placa no se retira, al mezclarse con la saliva y los minerales presentes en ella, reaccionará formando una costra. La placa se calcifica y se forma el sarro.

El sarro, cuando se forma, es de color blanquecino pero a medida que pasa el tiempo se va poniendo amarillo y luego marrón.

Síntomas de una pobre higiene dental
La señal más obvia de una mala salud dental canina es el mal aliento.

Sin embargo, a veces no es tan fácil de detectar
Y hay perros que no se dejan abrir la boca por su dueño. Por ejemplo…

Recientemente nos trajeron a la clínica a un perro que parpadeaba de un ojo y decía su dueño que le picaba un lado de la cara. Tenía molestias y dificultad para comer, lo que había llevado a sus dueños a comprarle comida blanda (que suele ser un poco más cara y llevar más contenido en grasa) durante medio año. Después de una exploración oftalmológica, nos dimos cuenta de que el ojo tenía una úlcera en la córnea probablemente de rascarse . Además, el canto lateral del ojo estaba inflamado. Tenía lo que en humanos llamamos flemón pero como era un perro de pelo largo, no se le notaba a simple vista. Al abrirle la boca nos llamó la atención el ver una muela llena de sarro. Le realizamos una radiografía y encontramos una fístula que llegaba hasta la parte inferior del ojo.

Le tuvimos que extraer la muela. Tras esto, el ojo se curó completamente con unos colirios y una lentilla protectora de úlcera. Afortunadamente, la úlcera no profundizó y no perforó el ojo. Ahora el perro come perfectamente a pesar de haber perdido una muela.

¿Cómo mantener la higiene dental de tu perro?
Hay varias maneras de prevenir problemas derivados de la salud dental de tu perro.

Limpiezas de dientes en casa
Es recomendable limpiar los dientes de tu perro semanal o diariamente si se puede. Existe una gran variedad de productos que se pueden utilizar:

Pastas de dientes.
Cepillos de dientes o dedales para el dedo índice, que hacen más fácil la limpieza.
Colutorios para echar en agua de bebida o directamente sobre el diente en líquido o en spray.

En la Clínica Tus Veterinarios enseñamos a nuestros clientes a tomar el hábito de limpiar los dientes de sus perros desde que son cachorros. Esto responde a nuestro compromiso con la prevención de enfermedades caninas.

Hoy en día tenemos muchos clientes que limpian los dientes todos los días a su mascota, y como resultado, se ahorran el dinero de hacer limpiezas dentales profesionales y consiguen una mejor salud de su perro.


Limpiezas dentales profesionales de perros y gatos

Recomendamos hacer una limpieza dental especializada anualmente. La realizamos con un aparato de ultrasonidos que utiliza agua para quitar el sarro. Después, procedemos a pulir los dientes con un cepillo de alta velocidad y una pasta especial. Hacemos esto para proteger el esmalte.

La frecuencia de limpiezas dentales necesaria varía mucho entre razas. En general, las razas grandes tienen buena calidad de esmalte, por lo que no necesitan hacerlo tan a menudo e incluso pueden pasarse la vida sin requerir una limpieza. Sin embargo, razas pequeñas como el Yorkshire o el Maltés, deben hacérselas todos los años desde cachorros si se quiere conservar sus piezas dentales.

Otro factor fundamental es la calidad del pienso. Algunas marcas han diseñado croquetas que limpian la superficie del diente y de la muela al masticarse.

Ultrasonido para perros

¿Se necesita anestesia para las limpiezas dentales de perros y gatos?

La limpieza dental en perros no es una técnica que pueda practicarse sin anestesia general , aunque hay veces que los propietarios no quieren anestesiar y si tiene poco sarro y el perro es muy bueno se puede intentar…… , pero no se va a poder pulir ni acceder a todas la zona de la boca …. Además los limpiadores dentales van a irrigar agua y hay riesgo de aspiración a vías respiratorias si no se realiza una anestesia correcta con intubación traqueal . En resumen , sin anestesia no se va hacer una correcta limpieza dental.

Tampoco sirve la sedación ya que necesitamos que el animal esté totalmente quieto, y el veterinario tenga un acceso completo a todas sus piezas dentales y encías.

Alimentos para la limpieza dental

Hay que tener cierto cuidado a la hora de comprar determinados alimentos porque no todos son saludables. Algunos tienen demasiado contenido graso, que en exceso puede causar problemas cardiovasculares y obesidad.

Los mejores alimentos para los dientes son aquellos que están elaborados por empresas farmacéuticas y llevan componentes químicos con tratamientos específicos para el diente del perro. Esto implica no solo limpieza a través de la acción mecánica de morder sino también un tratamiento antibacteriano para prevenir el sarro.

Conclusión

Si eres como la mayoría de dueños, por falta de tiempo , es probable que no estés prestando la suficiente atención a la limpieza dental de tu perro. Por eso te animamos a que comiences a limpiar los dientes de tu perro y consideres atender a su higiene bucal con frecuencia.

Estas simples medidas pueden conllevar a que tu perro tenga una vida más larga y mucho más saludable.

Si te resulta imposible introducir un cepillo de dientes a tu perro en la boca, pásate con él por clínica Tus Veterinarios y te explicamos cómo hacerlo.

Necesitas hacer una limpieza dental profesional a tu mascota?
Llámanos al 622575274 o contacta con nosotros

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

¡Hola!