Current File : //proc/self/root/usr/lib/python3/dist-packages/twisted/trial/__pycache__/_synctest.cpython-312.pyc
�

Ϫ�f���	�`�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Zddlm
Z
mZmZmZmZmZmZmZmZmZmZmZddlmZddlmZddlmZddlmZmZdd	l m!Z!m"Z"m#Z#dd
l$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*ddl+m,Z,dd
l-m.Z.m/Z/ed�Z0ed�Z1Gd�de2�Z3eGd�d��Z4dee5eeee6eee6fe5ffde4fd�Z7Gd�d�Z8d�Z9d�Z:Gd�de;�Z<Gd�d�Z=Gd�d �Z>Gd!�d"ej~�Z@Gd#�d$�ZAeA�ZBGd%�d&e@�ZCy)'zP
Things likely to be used by writers of unit tests.

Maintainer: Jonathan Lange
�N)�findlinestarts)�Any�Callable�	Coroutine�	Generator�Iterable�List�NoReturn�Optional�Tuple�Type�TypeVar�Union)�SkipTest)�frozen)�	ParamSpec)�Deferred�ensureDeferred)�failure�log�monkey)�DEPRECATION_WARNING_FORMAT�getDeprecationWarningString�getVersionString�warnAboutFunction)�fullyQualifiedName)�runWithWarningsSuppressed)�itrial�util�_P�Tc��eZdZdZy)�FailTestzA
    Raised to indicate the current test has failed to pass.
    N��__name__�
__module__�__qualname__�__doc__���9/usr/lib/python3/dist-packages/twisted/trial/_synctest.pyr#r#9s��r*r#c�N�eZdZUdZeed<dZeee	e
ed<defd�Zd�Zy)�Todoa�
    Internal object used to mark a L{TestCase} as 'todo'. Tests marked 'todo'
    are reported differently in Trial L{TestResult}s. If todo'd tests fail,
    they do not fail the suite and the errors are reported in a separate
    category. If todo'd tests succeed, Trial L{TestResult}s will report an
    unexpected success.

    @ivar reason: A string explaining why the test is marked 'todo'

    @ivar errors: An iterable of exception types that the test is expected to
        raise. If one of these errors is raised by the test, it will be
        trapped. Raising any other kind of error will fail the test.  If
        L{None} then all errors will be trapped.
    �reasonN�errors�returnc�<�d|j�d|j�d�S)Nz
<Todo reason=z errors=�>�r.r/��selfs r+�__repr__z
Todo.__repr__Ss���t�{�{�o�X�d�k�k�_�A�F�Fr*c�h�|j�y|jD]}|j|�s�yy)z�
        @param failure: A L{twisted.python.failure.Failure}.

        @return: C{True} if C{failure} is expected, C{False} otherwise.
        TF)r/�check)r5r�errors   r+�expectedz
Todo.expectedVs:���;�;����[�[�	�E��w�}�}�U�#��	�r*)
r%r&r'r(�str�__annotations__r/rrr
�
BaseExceptionr6r:r)r*r+r-r-?s:��
�
�K�6:�F�H�X�d�=�1�2�3�:�G�#�G�r*r-�valuer0c��t|t�rt|��St|t�r(|\}}t|t�r|g}n|}t||��Sy)a�
    Return a L{Todo} object built from C{value}.

    If C{value} is a string, return a Todo that expects any exception with
    C{value} as a reason. If C{value} is a tuple, the second element is used
    as the reason and the first element as the excepted error(s).

    @param value: A string or a tuple of C{(errors, reason)}, where C{errors}
    is either a single exception class or an iterable of exception classes.

    @return: A L{Todo} object.
    )r.r3N)�
isinstancer;r-�tuple�type)r>r/r.�iterableErrorss    r+�makeTodorDdsT��"�%����5�!�!��%��������f�d�#�=C�H�N�#�N��6�.�9�9�
 r*c��eZdZdZd�Zy)�_Warninga]
    A L{_Warning} instance represents one warning emitted through the Python
    warning system (L{warnings}).  This is used to insulate callers of
    L{_collectWarnings} from changes to the Python warnings system which might
    otherwise require changes to the warning objects that function passes to
    the observer object it accepts.

    @ivar message: The string which was passed as the message parameter to
        L{warnings.warn}.

    @ivar category: The L{Warning} subclass which was passed as the category
        parameter to L{warnings.warn}.

    @ivar filename: The name of the file containing the definition of the code
        object which was C{stacklevel} frames above the call to
        L{warnings.warn}, where C{stacklevel} is the value of the C{stacklevel}
        parameter passed to L{warnings.warn}.

    @ivar lineno: The source line associated with the active instruction of the
        code object object which was C{stacklevel} frames above the call to
        L{warnings.warn}, where C{stacklevel} is the value of the C{stacklevel}
        parameter passed to L{warnings.warn}.
    c�<�||_||_||_||_y�N��message�category�filename�lineno)r5rJrKrLrMs     r+�__init__z_Warning.__init__�s����� ��
� ��
���r*N)r%r&r'r(rNr)r*r+rFrF�s���0r*rFc�t�t|j��D]
}|��	d|_�y#t$rY�wxYw)z�
    Disable the per-module cache for every module found in C{modules}, typically
    C{sys.modules}.

    @param modules: Dictionary of modules, typically sys.module dict
    N)�list�values�__warningregistry__r=)�modules�vs  r+�_setWarningRegistryToNonerU�sG���'�.�.�"�
#����=�
�(,��%���!�
��	
�s�+�	7�7c�`��d�fd�	}ttj�tjdd}tj
}tjd�	|t_||i|��}|tjdd|t_|S#|tjdd|t_wxYw)aU
    Call C{f} with C{args} positional arguments and C{kwargs} keyword arguments
    and collect all warnings which are emitted as a result in a list.

    @param observeWarning: A callable which will be invoked with a L{_Warning}
        instance each time a warning is emitted.

    @return: The return value of C{f(*args, **kwargs)}.
    Nc�d��t|t�sJ��tt|�|||��yrH)r@�WarningrFr;)rJrKrLrM�file�line�observeWarnings      �r+�showWarningz%_collectWarnings.<locals>.showWarning�s*����'�7�+�+�+��x��G��h��&�I�Jr*�always)NN)rU�sysrS�warnings�filters�showwarning�simplefilter)r[�f�args�kwargsr\�origFilters�origShow�results`       r+�_collectWarningsri�s����K��c�k�k�*��"�"�1�%�K��#�#�H����(�#�(�*����D�#�F�#��)������'����M��*������'���s�B
�
 B-c��eZdZdZy)�UnsupportedTrialFeaturez?A feature of twisted.trial was used that pyunit cannot support.Nr$r)r*r+rkrk�s��Ir*rkc�Z�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd�Zd�Z
d
�Zd�Zy
)�PyUnitResultAdapterz�
    Wrap a C{TestResult} from the standard library's C{unittest} so that it
    supports the extended result types from Trial, and also supports
    L{twisted.python.failure.Failure}s being passed to L{addError} and
    L{addFailure}.
    c��||_y)zM
        @param original: A C{TestResult} instance from C{unittest}.
        N)�original)r5ros  r+rNzPyUnitResultAdapter.__init__�s��!��
r*c�,�tj|�SrH)r�excInfoOrFailureToExcInfo)r5�errs  r+�	_exc_infozPyUnitResultAdapter._exc_info�s���-�-�c�2�2r*c�:�|jj|�yrH)ro�	startTest�r5�methods  r+ruzPyUnitResultAdapter.startTest�s���
�
����'r*c�:�|jj|�yrH)ro�stopTestrvs  r+ryzPyUnitResultAdapter.stopTest�s���
�
���v�&r*c�Z�|jj||j|��yrH)ro�
addFailurers)r5�test�fails   r+r{zPyUnitResultAdapter.addFailure�s���
�
� � ��t�~�~�d�';�<r*c�Z�|jj||j|��yrH)ro�addErrorrs�r5r|r9s   r+rzPyUnitResultAdapter.addError�s���
�
���t�T�^�^�E�%:�;r*c�^�|jj|tt||�df�yrH)ror{rk)r5r|�feature�infos    r+�_unsupportedz PyUnitResultAdapter._unsupported�s)���
�
� � ��
$�&=�g�t�&L�d�S�	
r*c�<�|jj||�y)z/
        Report the skip as a failure.
        N)ro�addSkip)r5r|r.s   r+r�zPyUnitResultAdapter.addSkip�s��	
�
�
���d�F�+r*Nc�*�|j|d|�y)z=
        Report the unexpected success as a failure.
        zunexpected successN�r�)r5r|�todos   r+�addUnexpectedSuccessz(PyUnitResultAdapter.addUnexpectedSuccess�s��	
���$� 4�d�;r*c�*�|j|d|�y)zG
        Report the expected failure (i.e. todo) as a failure.
        zexpected failureNr�r�s   r+�addExpectedFailurez&PyUnitResultAdapter.addExpectedFailures��	
���$� 2�E�:r*c�:�|jj|�yrH)ro�
addSuccess)r5r|s  r+r�zPyUnitResultAdapter.addSuccesss���
�
� � ��&r*c��yrHr))r5rwr9�warn�printStatuss     r+�upDownErrorzPyUnitResultAdapter.upDownErrors��r*rH)r%r&r'r(rNrsruryr{rr�r�r�r�r�r�r)r*r+rmrm�sC���!�3�(�'�=�<�
�,�<�;�'�
r*rmc�(�eZdZdZd�Zd�Zd�Zd�Zy)�_AssertRaisesContexta�
    A helper for implementing C{assertRaises}.  This is a context manager and a
    helper method to support the non-context manager version of
    C{assertRaises}.

    @ivar _testCase: See C{testCase} parameter of C{__init__}

    @ivar _expected: See C{expected} parameter of C{__init__}

    @ivar _returnValue: The value returned by the callable being tested (only
        when not being used as a context manager).

    @ivar _expectedName: A short string describing the expected exception
        (usually the name of the exception class).

    @ivar exception: The exception which was raised by the function being
        tested (if it raised one).
    c��||_||_d|_	|jj|_y#t
$rt
|j�|_YywxYw)z�
        @param testCase: The L{TestCase} instance which is used to raise a
            test-failing exception when that is necessary.

        @param expected: The exception type expected to be raised.
        N)�	_testCase�	_expected�_returnValuer%�
_expectedName�AttributeErrorr;)r5�testCaser:s   r+rNz_AssertRaisesContext.__init__&sQ��"���!��� ���	5�!%���!8�!8�D����	5�!$�T�^�^�!4�D��	5�s�3�#A�Ac�v�|5}|�|_ddd�|jS#1swYjSxYw)a,
        Call the given object using this object as a context manager.

        @param obj: The object to call and which is expected to raise some
            exception.
        @type obj: L{object}

        @return: Whatever exception is raised by C{obj()}.
        @rtype: L{BaseException}
        N)r��	exception)r5�obj�contexts   r+�_handlez_AssertRaisesContext._handle5s;���	&�W� #��D��	&�� � � �	&�� � � �s�
$�8c��|SrHr)r4s r+�	__enter__z_AssertRaisesContext.__enter__Ds���r*c���|�?|jjdj|j|j��t||�st|t�r||�}n||�}||_t||j�sdtj|||�}|jjdjt|�|j|j���y)zB
        Check exit exception against expected exception.
        z{} not raised ({} returned)z{} raised instead of {}:
 {}T)r�r}�formatr�r�r@rAr��
issubclassr�r�Failurer�getTraceback)r5�
exceptionType�exceptionValue�	tracebackr.s     r+�__exit__z_AssertRaisesContext.__exit__Gs���
� ��N�N���-�4�4��&�&��(9�(9��
��.�-�8�
�.�%�0�!.��!?��!.�~�!>��(����-����8��_�_�^�]�I�N�F��N�N���/�6�6�&�}�5��&�&��'�'�)��
�r*N)r%r&r'r(rNr�r�r�r)r*r+r�r�s���&
5�
!��%r*r�c���eZdZdZddeedefd�Zd�fd�	ZeZ	eZ
eZd�fd�	ZeZ
eZeZdd�ZeZd�fd�	ZeZeZeZdd	�ZeZeZdd
�ZeZeZdd�ZeZeZeZdd�Z e Z!dd
�Z"e"Z#dd�Z$e$Z%e$Z&e$Z'dd�Z(e(Z)e(Z*dd�Z+e+Z,dd�Z-e-Z.dd�Z/e/Z0d�Z1e1Z2dd�Z3e3Z4d�Z5e5Z6de7e8e9e:e;e:fe<e9e:e;e:fe9e:fde:fd�Z=d�Z>d�Z?�xZ@S)�_Assertionsz�
    Replaces many of the built-in TestCase assertions. In general, these
    assertions provide better error messages and are easier to use in
    callbacks.
    �msgr0c�$�|j|��)z�
        Absolutely fail the test.  Do not pass go, do not collect $200.

        @param msg: the message that will be displayed as the reason for the
        failure
        ��failureException)r5r�s  r+r}z_Assertions.failvs���#�#�C�(�(r*c�(��t�|�||�|S)z�
        Fail the test if C{condition} evaluates to True.

        @param condition: any object that defines __nonzero__
        )�super�assertFalse�r5�	conditionr��	__class__s   �r+r�z_Assertions.assertFalses���	���I�s�+��r*c�(��t�|�||�|S)z�
        Fail the test if C{condition} evaluates to False.

        @param condition: any object that defines __nonzero__
        )r��
assertTruer�s   �r+r�z_Assertions.assertTrue�s���	���9�c�*��r*c�T����t||�}��|S|j���fd��S)a�
        Fail the test unless calling the function C{f} with the given
        C{args} and C{kwargs} raises C{exception}. The failure will report
        the traceback and call stack of the unexpected exception.

        @param exception: exception type that is to be expected
        @param f: the function to call

        @return: If C{f} is L{None}, a context manager which will make an
            assertion about the exception raised from the suite it manages.  If
            C{f} is not L{None}, the exception raised by C{f}.

        @raise self.failureException: Raised if the function call does
            not raise an exception or if it raises an exception of a
            different type.
        c�����i���SrHr))rdrcres���r+�<lambda>z*_Assertions.assertRaises.<locals>.<lambda>�s���q�$�'9�&�'9�r*)r�r�)r5r�rcrdrer�s  ``` r+�assertRaisesz_Assertions.assertRaises�s+���"'�t�Y�7���9��N����9�:�:r*c�*��t�|�|||�|S)z�
        Fail the test if C{first} and C{second} are not equal.

        @param msg: A string describing the failure that's included in the
            exception.
        )r��assertEqual)r5�first�secondr�r�s    �r+r�z_Assertions.assertEqual�s���	���E�6�3�/��r*c�B�||ur|j|xs|�d|����|S)a
        Fail the test if C{first} is not C{second}.  This is an
        obect-identity-equality test, not an object equality
        (i.e. C{__eq__}) test.

        @param msg: if msg is None, then the failure message will be
        '%r is not %r' % (first, second)
        z is not r��r5r�r�r�s    r+�assertIsz_Assertions.assertIs�s2������'�'��(M�%��(�6�*�/M�N�N��r*c�B�||ur|j|xs|�d|����|S)a
        Fail the test if C{first} is C{second}.  This is an
        obect-identity-equality test, not an object equality
        (i.e. C{__eq__}) test.

        @param msg: if msg is None, then the failure message will be
        '%r is %r' % (first, second)
        z is r�r�s    r+�assertIsNotz_Assertions.assertIsNot�s1���F�?��'�'��(I�%��$�v�j�/I�J�J��r*c�D�||k7s|j|xs|�d|����|S)z�
        Fail the test if C{first} == C{second}.

        @param msg: if msg is None, then the failure message will be
        '%r == %r' % (first, second)
        � == r�r�s    r+�assertNotEqualz_Assertions.assertNotEqual�s1������'�'��(I�%��$�v�j�/I�J�J��r*c�B�||vr|j|xs|�d|����|S)a�
        Fail the test if C{containee} is not found in C{container}.

        @param containee: the value that should be in C{container}
        @param container: a sequence type, or in the case of a mapping type,
                          will follow semantics of 'if key in dict.keys()'
        @param msg: if msg is None, then the failure message will be
                    '%r not in %r' % (first, second)
        z not in r��r5�	containee�	containerr�s    r+�assertInz_Assertions.assertIn�s3���I�%��'�'��(T�)��h�y�m�/T�U�U��r*c�B�||vr|j|xs|�d|����|S)a�
        Fail the test if C{containee} is found in C{container}.

        @param containee: the value that should not be in C{container}
        @param container: a sequence type, or in the case of a mapping type,
                          will follow semantics of 'if key in dict.keys()'
        @param msg: if msg is None, then the failure message will be
                    '%r in %r' % (first, second)
        z in r�r�s    r+�assertNotInz_Assertions.assertNotIns3���	�!��'�'��(P�)��d�9�-�/P�Q�Q��r*c�f�t||z
|�dk(r|j|xs|�d|�d|�d���|S)a�
        Fail if the two objects are equal as determined by their
        difference rounded to the given number of decimal places
        (default 7) and comparing to zero.

        @note: decimal places (from zero) is usually not the same
               as significant digits (measured from the most
               significant digit).

        @note: included for compatibility with PyUnit test cases
        rr�� within � places��roundr��r5r�r��placesr��deltas      r+�assertNotAlmostEqualz _Assertions.assertNotAlmostEqual�L����%���(�A�-��'�'��J�%��$�v�j���
�'�J��
��r*c�f�t||z
|�dk7r|j|xs|�d|�d|�d���|S)a�
        Fail if the two objects are unequal as determined by their
        difference rounded to the given number of decimal places
        (default 7) and comparing to zero.

        @note: decimal places (from zero) is usually not the same
               as significant digits (measured from the most
               significant digit).

        @note: included for compatibility with PyUnit test cases
        rz != r�r�r�r�s      r+�assertAlmostEqualz_Assertions.assertAlmostEqual(r�r*c�\�t||z
�|kDr|j|xs|�d|����|S)z�
        Fail if C{first} - C{second} > C{tolerance}

        @param msg: if msg is None, then the failure message will be
                    '%r ~== %r' % (first, second)
        z ~== )�absr�)r5r�r��	tolerancer�s     r+�assertApproximatesz_Assertions.assertApproximates=s;���u�v�~���*��'�'��(F�%���f�X�/F�G�G��r*c�(�|j|||�S)zH
        Fail if C{substring} does not exist within C{astring}.
        )�failUnlessIn�r5�	substring�astringr�s    r+�assertSubstringz_Assertions.assertSubstringJs��� � ��G�S�9�9r*c�(�|j|||�S)z;
        Fail if C{astring} contains C{substring}.
        )�failIfInr�s    r+�assertNotSubstringz_Assertions.assertNotSubstringRs���}�}�Y���5�5r*c���g}t|j|g|��i|��}|s|jd�|d}	|ddD]E}
|
j|
jf|	j|	jfk7s�5|jd��G|j|	j|�|j
|	j|�|j|j|	j�d|	j�d|���|S)a�
        Fail if the given function doesn't generate the specified warning when
        called. It calls the function, checks the warning, and forwards the
        result of the function if everything is fine.

        @param category: the category of the warning to check.
        @param message: the output message of the warning to check.
        @param filename: the filename where the warning should come from.
        @param f: the function which is supposed to generate the warning.
        @type f: any callable.
        @param args: the arguments to C{f}.
        @param kwargs: the keywords arguments to C{f}.

        @return: the result of the original function C{f}.
        zNo warnings emittedr�NzCan't handle different warningszWarning in z, expected )
ri�appendr}rJrKr��assertIdenticalr��
startswithrL)r5rKrJrLrcrdre�
warningsShownrhr��others           r+�assertWarnsz_Assertions.assertWarnsZs��� �
�!�-�"6�"6��K�D�K�F�K����I�I�+�,��a� ��"�1�2�&�	=�E��
�
�u�~�~�.�5�=�=�%�.�.�2Q�Q��	�	�;�<�	=�	
�������0����U�^�^�X�6�	
���������/��%�.�.�+�;�x�l�C�	
��
r*c�b�t||�s#|�d}nd|z}|j|�d|�|���yy)a
        Fail if C{instance} is not an instance of the given class or of
        one of the given classes.

        @param instance: the object to test the type (first argument of the
            C{isinstance} call).
        @type instance: any.
        @param classOrTuple: the class or classes to test against (second
            argument of the C{isinstance} call).
        @type classOrTuple: class, type, or tuple.

        @param message: Custom text to include in the exception text if the
            assertion fails.
        N��: z is not an instance of �r@r})r5�instance�classOrTuplerJ�suffixs     r+�assertIsInstancez_Assertions.assertIsInstance�sB���(�L�1����������I�I���$;�L�>�&��R�S�2r*c�J�t||�r|j|�d|���yy)a�
        Fail if C{instance} is an instance of the given class or of one of the
        given classes.

        @param instance: the object to test the type (first argument of the
            C{isinstance} call).
        @type instance: any.
        @param classOrTuple: the class or classes to test against (second
            argument of the C{isinstance} call).
        @type classOrTuple: class, type, or tuple.
        z is an instance of Nr�)r5r�r�s   r+�assertNotIsInstancez_Assertions.assertNotIsInstance�s+���h��-��I�I���$7��~�F�G�.r*�deferredc�6�t|�}g}|j|j�|s |jdj	|��|d}t|tj�r/|jdj	||j���|S)a�
        Return the current success result of C{deferred} or raise
        C{self.failureException}.

        @param deferred: A L{Deferred<twisted.internet.defer.Deferred>} or
            I{coroutine} which has a success result.

            For a L{Deferred<twisted.internet.defer.Deferred>} this means
            L{Deferred.callback<twisted.internet.defer.Deferred.callback>} or
            L{Deferred.errback<twisted.internet.defer.Deferred.errback>} has
            been called on it and it has reached the end of its callback chain
            and the last callback or errback returned a
            non-L{failure.Failure}.

            For a I{coroutine} this means all awaited values have a success
            result.

        @raise SynchronousTestCase.failureException: If the
            L{Deferred<twisted.internet.defer.Deferred>} has no result or has a
            failure result.

        @return: The result of C{deferred}.
        z8Success result expected on {!r}, found no result insteadrzASuccess result expected on {!r}, found failure result instead:
{})	r�addBothr�r}r�r@rr�r�)r5r��resultsrhs    r+�successResultOfz_Assertions.successResultOf�s���>"�(�+��35��������(���I�I�J�Q�Q���
������f�g�o�o�.��I�I�4�4:�F��f�1�1�3�5�
��
r*c	�D�t|�}g}|j|j�|s |jdj	|��|d}t|tj�s!|jdj	||��|r�|j|�sdj|D�cgc])}dj|j|jf���+c}�}|jdj	|||j|j���|Scc}w)a�
        Return the current failure result of C{deferred} or raise
        C{self.failureException}.

        @param deferred: A L{Deferred<twisted.internet.defer.Deferred>} which
            has a failure result.  This means
            L{Deferred.callback<twisted.internet.defer.Deferred.callback>} or
            L{Deferred.errback<twisted.internet.defer.Deferred.errback>} has
            been called on it and it has reached the end of its callback chain
            and the last callback or errback raised an exception or returned a
            L{failure.Failure}.
        @type deferred: L{Deferred<twisted.internet.defer.Deferred>}

        @param expectedExceptionTypes: Exception types to expect - if
            provided, and the exception wrapped by the failure result is
            not one of the types provided, then this test will fail.

        @raise SynchronousTestCase.failureException: If the
            L{Deferred<twisted.internet.defer.Deferred>} has no result, has a
            success result, or has an unexpected failure result.

        @return: The failure result of C{deferred}.
        @rtype: L{failure.Failure}
        z8Failure result expected on {!r}, found no result insteadrzDFailure result expected on {!r}, found success result ({!r}) insteadz or �.zBFailure of type ({}) expected on {!r}, found type {!r} instead: {})rr�r�r}r�r@rr�r8�joinr&r%rBr�)r5r��expectedExceptionTypesrh�t�expectedStrings      r+�failureResultOfz_Assertions.failureResultOf�s��2"�(�+����������'���I�I�J�Q�Q���
������&�'�/�/�2��I�I�6�6<�f�X�v�6N�
�
"�,�&�,�,�8N�*O�#�[�[�?U�V�!����1�<�<����4�5�V��N�
�I�I�.�.4�f�"�H�f�k�k�6�;N�;N�;P�/�
��
��Ws�+.Dc���t|�}g��fd�}|j|��r7|jd��|jdj	|�d��yy)a�
        Assert that C{deferred} does not have a result at this point.

        If the assertion succeeds, then the result of C{deferred} is left
        unchanged. Otherwise, any L{failure.Failure} result is swallowed.

        @param deferred: A L{Deferred<twisted.internet.defer.Deferred>} without
            a result.  This means that neither
            L{Deferred.callback<twisted.internet.defer.Deferred.callback>} nor
            L{Deferred.errback<twisted.internet.defer.Deferred.errback>} has
            been called, or that the
            L{Deferred<twisted.internet.defer.Deferred>} is waiting on another
            L{Deferred<twisted.internet.defer.Deferred>} for a result.
        @type deferred: L{Deferred<twisted.internet.defer.Deferred>}

        @raise SynchronousTestCase.failureException: If the
            L{Deferred<twisted.internet.defer.Deferred>} has a result.
        c�*���j|�|SrH)r�)�resrhs �r+�cbz&_Assertions.assertNoResult.<locals>.cb4s����M�M�#���Jr*c��yrHr))�_s r+r�z,_Assertions.assertNoResult.<locals>.<lambda>=��r*z.No result expected on {!r}, found {!r} insteadrN)rr��
addErrbackr}r�)r5r�rrhs   @r+�assertNoResultz_Assertions.assertNoResultsd���&"�(�+����	�	������
����/��I�I�@�G�G��f�Q�i��
�	r*rH)�NN)Ar%r&r'r(r�objectr
r}r��	assertNot�failUnlessFalse�failIfr��assert_�failUnlessTrue�
failUnlessr��failUnlessRaisesr��failUnlessEqual�failUnlessEquals�assertEqualsr��failUnlessIdenticalr�r��failIfIdentical�assertNotIdenticalr��assertNotEquals�failIfEquals�failIfEqualr�r�r�r�r��assertNotAlmostEquals�failIfAlmostEqual�failIfAlmostEqualsr��assertAlmostEquals�failUnlessAlmostEqualr��failUnlessApproximatesr��failUnlessSubstringr��failIfSubstringr��failUnlessWarnsr��failUnlessIsInstancer��failIfIsInstancerrrr!rrrrr�
__classcell__�r�s@r+r�r�os�����)���(�)�H�)���I�!�O�
�F���G��N��J�;�4$���"�O�"���L��#���O��"�O�$��	�%�O�!�L� �K���L���H��$1��,��-���$+��-��	�0��:�*��6�)�O�(�T"�O�T�,,��
H�+��3���h�q�k�3��)�*��h�q�k�3��)�*��Q�K�
�
�3�
�3�j8�t$r*r�c�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�_LogObservera
    Observes the Twisted logs and catches any errors.

    @ivar _errors: A C{list} of L{Failure} instances which were received as
        error events from the Twisted logging system.

    @ivar _added: A C{int} giving the number of times C{_add} has been called
        less the number of times C{_remove} has been called; used to only add
        this observer to the Twisted logging since once, regardless of the
        number of calls to the add method.

    @ivar _ignored: A C{list} of exception types which will not be recorded.
    c�.�g|_d|_g|_y)Nr)�_errors�_added�_ignoredr4s r+rNz_LogObserver.__init__Ts����������
r*c��|jdk(rtj|j�|xjdz
c_y)Nrr�)r4r�addObserver�gotEventr4s r+�_addz_LogObserver._addYs,���;�;�!���O�O�D�M�M�*����q��r*c��|xjdzc_|jdk(r tj|j�yy)Nr�r)r4r�removeObserverr8r4s r+�_removez_LogObserver._remove^s3�����q����;�;�!�����t�}�}�-�r*c�:�|jj|�y)zF
        Do not store any errors with any of the given types.
        N)r5�extend�r5�
errorTypess  r+�
_ignoreErrorsz_LogObserver._ignoreErrorscs��	
�
�
���Z�(r*c��g|_y)zJ
        Stop ignoring any errors we might currently be ignoring.
        N)r5r4s r+�
_clearIgnoresz_LogObserver._clearIgnoresis����
r*c���|rPg}g}|jD]4}|j|�r|j|��$|j|��6||_|S|j}g|_|S)z�
        Flush errors from the list of caught errors. If no arguments are
        specified, remove all errors. If arguments are specified, only remove
        errors of those types from the stored list.
        )r3r8r�)r5r@�flushed�	remainderrcs     r+�flushErrorsz_LogObserver.flushErrorsoss����G��I��\�\�
(���1�7�7�J�'��N�N�1�%��$�$�Q�'�	
(�
%�D�L����l�l�G��D�L��r*c��|jS)zB
        Return a list of errors caught by this observer.
        )r3r4s r+�	getErrorsz_LogObserver.getErrors�s���|�|�r*c���|jdd�rXd|vrS|d}t|j�dk(s|j|j�s|jj|�yyyy)z�
        The actual observer method. Called whenever a message is logged.

        @param event: A dictionary containing the log message. Actual
        structure undocumented (see source for L{twisted.python.log}).
        �isErrorFrrN)�get�lenr5r8r3r�)r5�eventrcs   r+r8z_LogObserver.gotEvent�se���9�9�Y��&�9��+=��i� �A��4�=�=�!�Q�&�g�a�g�g�t�}�}�.E����#�#�A�&�/F�,>�&r*N)r%r&r'r(rNr9r<rArCrGrIr8r)r*r+r1r1Es/����
�
.�
)���(�
'r*r1c���eZdZdZeZd�fd�	Zdedefd�Z	d�Z
�fd�Zdeee
effd�Zd	�Zd
�Zd�Zdeeefd
ej*dej,ddfd�Zd�Zd�Zdd�Zdd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$�xZ%S) �SynchronousTestCasea

    A unit test. The atom of the unit testing universe.

    This class extends C{unittest.TestCase} from the standard library.  A number
    of convenient testing helpers are added, including logging and warning
    integration, monkey-patching support, and more.

    To write a unit test, subclass C{SynchronousTestCase} and define a method
    (say, 'test_foo') on the subclass. To run the test, instantiate your
    subclass with the name of the method, and call L{run} on the instance,
    passing a L{TestResult} object.

    The C{trial} script will automatically find any C{SynchronousTestCase}
    subclasses defined in modules beginning with 'test_' and construct test
    cases for all methods beginning with 'test'.

    If an error is logged during the test run, the test will fail with an
    error. See L{log.err}.

    @ivar failureException: An exception class, defaulting to C{FailTest}. If
    the test method raises this exception, it will be reported as a failure,
    rather than an exception. All of the assertion methods raise this if the
    assertion fails.

    @ivar skip: L{None} or a string explaining why this test is to be
    skipped. If defined, the test will not be run. Instead, it will be
    reported to the result object as 'skipped' (if the C{TestResult} supports
    skipping).

    @ivar todo: L{None}, a string or a tuple of C{(errors, reason)} where
    C{errors} is either an exception class or an iterable of exception
    classes, and C{reason} is a string. See L{Todo} or L{makeTodo} for more
    information.

    @ivar suppress: L{None} or a list of tuples of C{(args, kwargs)} to be
    passed to C{warnings.filterwarnings}. Use these to suppress warnings
    raised in a test. Useful for testing deprecated code. See also
    L{util.suppress}.
    c����t�|�|�d|_g|_||_t||�}||tjj|jj�g|_y)NF)r�rN�_passed�	_cleanups�_testMethodName�getattrr^rSrLr�r&�_parents)r5�
methodName�
testMethodr�s   �r+rNzSynchronousTestCase.__init__�sW���
����$�������)����T�:�.�
�#�T�3�;�;�?�?�4�>�>�;T�;T�+U�V��
r*r�r0c�6�t|t�r||uStS)a�
        Override the comparison defined by the base TestCase which considers
        instances of the same class with the same _testMethodName to be
        equal.  Since trial puts TestCase instances into a set, that
        definition of comparison makes it impossible to run the same test
        method twice.  Most likely, trial should stop using a set to hold
        tests, but until it does, this is necessary on Python 2.6. -exarkun
        )r@rP�NotImplemented)r5r�s  r+�__eq__zSynchronousTestCase.__eq__�s���e�0�1��5�=� �!�!r*c�D�t|j|jf�SrH)�hashr�rTr4s r+�__hash__zSynchronousTestCase.__hash__�s���T�^�^�T�%9�%9�:�;�;r*c�@��t�|��}|�|jS|SrH)r��shortDescriptionrT)r5�descr�s  �r+r`z$SynchronousTestCase.shortDescription�s&����w�'�)���<��'�'�'��r*c��tj|jdd�}|du}|�t|dd�}|r
t|dd�}||fS)aN
        Return the skip reason set on this test, if any is set. Checks on the
        instance first, then the class, then the module, then packages. As
        soon as it finds something with a C{skip} attribute, returns that in
        a tuple (L{True}, L{str}).
        If the C{skip} attribute does not exist, look for C{__unittest_skip__}
        and C{__unittest_skip_why__} attributes which are set by the standard
        library L{unittest.skip} function.
        Returns (L{False}, L{None}) if it cannot find anything.
        See L{TestCase} docstring for more details.
        �skipN�__unittest_skip__F�__unittest_skip_why__r�)r�acquireAttributerVrU)r5�
skipReason�doSkips   r+�getSkipzSynchronousTestCase.getSkip�sX���*�*�4�=�=�&�$�G�
��4�'�����T�#6��>�F��$�T�+B�B�G�
��
�#�#r*c�`�tj|jdd�}|�yt|�S)aQ
        Return a L{Todo} object if the test is marked todo. Checks on the
        instance first, then the class, then the module, then packages. As
        soon as it finds something with a C{todo} attribute, returns that.
        Returns L{None} if it cannot find anything. See L{TestCase} docstring
        for more details.
        r�N)rrfrVrD)r5r�s  r+�getTodozSynchronousTestCase.getTodo�s.���$�$�T�]�]�F�D�A���<����~�r*c��y)z�
        If no C{methodName} argument is passed to the constructor, L{run} will
        treat this method as the thing with the actual test inside.
        Nr)r4s r+�runTestzSynchronousTestCase.runTestrr*c��tjd|j�z�tj|d�}|�t|�}n|}|j
|�|j�\}}|r$|j||�|j|�yd|_
g|_|j�t|jj|j|�|j!�D]}	t#j$di|���|j|�y#t&$r'|j)|t+j,��Y�\wxYw)a�
        Run the test case, storing the results in C{result}.

        First runs C{setUp} on self, then runs the test method (defined in the
        constructor), then runs C{tearDown}.  As with the standard library
        L{unittest.TestCase}, the return value of these methods is disregarded.
        In particular, returning a L{Deferred<twisted.internet.defer.Deferred>}
        has no special additional consequences.

        @param result: A L{TestResult} object.
        z
--> %s <--NFr))rr��idr�	IReporterrmrurir�ryrR�	_warnings�_installObserverrir��_runFixturesAndTest�
flushWarningsr_�
warn_explicitr=rrr�)r5rh�
new_resultrhrg�ws      r+�runzSynchronousTestCase.run
s��	�������	�*�+��%�%�f�d�3�
���(��0�F��F������#�|�|�~������N�N�4��,��O�O�D�!������������	����.�.��0H�0H�&�Q��#�#�%�	9�A�
9��&�&�+��+�	9�	������!�
9�����g�o�o�&7�8�
9�s�4D�-E
�E
rcrdreNc�@�|jj|||f�y)as
        Add the given function to a list of functions to be called after the
        test has run, but before C{tearDown}.

        Functions will be run in reverse order of being added. This helps
        ensure that tear down complements set up.

        As with all aspects of L{SynchronousTestCase}, Deferreds are not
        supported in cleanup functions.
        N)rSr�)r5rcrdres    r+�
addCleanupzSynchronousTestCase.addCleanup7s��	
�����q�$��/�0r*c��tj|||f�}|j�|j|j�|S)a
        Monkey patch an object for the duration of the test.

        The monkey patch will be reverted at the end of the test using the
        L{addCleanup} mechanism.

        The L{monkey.MonkeyPatcher} is returned so that users can restore and
        re-apply the monkey patch within their tests.

        @param obj: The object to monkey patch.
        @param attribute: The name of the attribute to change.
        @param value: The value to set the attribute to.
        @return: A L{monkey.MonkeyPatcher} object.
        )r�
MonkeyPatcher�patchrz�restore)r5r��	attributer>�monkeyPatchs     r+r}zSynchronousTestCase.patchFs?���*�*�C��E�+B�C����������+�+�,��r*c�4�|jj|�S)a�
        Remove stored errors received from the log.

        C{TestCase} stores each error logged during the run of the test and
        reports them as errors during the cleanup phase (after C{tearDown}).

        @param errorTypes: If unspecified, flush all errors. Otherwise, only
        flush errors that match the given types.

        @return: A list of failures that have been removed.
        )�	_observerrGr?s  r+�flushLoggedErrorsz%SynchronousTestCase.flushLoggedErrorsZs��*�t�~�~�)�)�:�6�6r*c�Z�|� |jdd}g|jdd�nBg}|jD�]}|D]�}t|tjtjf�st|�d���tj|j}tj|�}|tjj|j�k7r��t|j �D��cgc]	\}}|�|��}	}}t#|	�|j$cxkrt'|	�ksn��|j)|�����
t+t-|jj.|��|D�
cgc]1}
|
j0|
j2|
j|
j$d���3c}
Scc}}wcc}
w)a�
        Remove stored warnings from the list of captured warnings and return
        them.

        @param offendingFunctions: If L{None}, all warnings issued during the
            currently running test will be flushed.  Otherwise, only warnings
            which I{point} to a function included in this list will be flushed.
            All warnings include a filename and source line number; if these
            parts of a warning point to a source line which is part of a
            function, then the warning I{points} to that function.
        @type offendingFunctions: L{None} or L{list} of functions or methods.

        @raise ValueError: If C{offendingFunctions} is not L{None} and includes
            an object which is not a L{types.FunctionType} or
            L{types.MethodType} instance.

        @return: A C{list}, each element of which is a C{dict} giving
            information about one warning which was flushed by this call.  The
            keys of each C{dict} are:

                - C{'message'}: The string which was passed as the I{message}
                  parameter to L{warnings.warn}.

                - C{'category'}: The warning subclass which was passed as the
                  I{category} parameter to L{warnings.warn}.

                - C{'filename'}: The name of the file containing the definition
                  of the code object which was C{stacklevel} frames above the
                  call to L{warnings.warn}, where C{stacklevel} is the value of
                  the C{stacklevel} parameter passed to L{warnings.warn}.

                - C{'lineno'}: The source line associated with the active
                  instruction of the code object object which was C{stacklevel}
                  frames above the call to L{warnings.warn}, where
                  C{stacklevel} is the value of the C{stacklevel} parameter
                  passed to L{warnings.warn}.
        Nz is not a function or methodrI)rqr@�types�FunctionType�
MethodType�
ValueErrorr^rSr&�inspect�
getabsfile�os�path�normcaserL�_findlinestarts�__code__�minrM�maxr�rP�map�removerJrK)r5�offendingFunctions�toFlush�aWarning�	aFunction�aModulerLr
�
lineNumber�lineNumbersrws           r+rtz!SynchronousTestCase.flushWarningshs���L�%��n�n�Q�'�G� "�D�N�N�1���G� �N�N�#
��!3�"�I�%�!�E�$6�$6��8H�8H�#I��)�I�=�8T�)U�V�V�"�k�k�)�*>�*>�?�G�&�1�1�'�:�H��2�7�7�#3�#3�H�4E�4E�#F�F� �.=�Y�=O�=O�-P�#�)�A�z�%�1�#�#�K�#�
 ��,����S�3�{�CS�S� ��N�N�8�,��E"�#
�J
��T�^�^�*�*�G�4�5��
���9�9��J�J��J�J��(�(�	
�
�	
��#��
s�)F"
�)6F(c�l�|dz|z}tj|}t||�}|j|jg�}t|�dk(r|j
|�d��|dd}	t|t|�d�z}
|�|
dz|z}
|j|	j|
�d|	�d|
���|S)	a�
        Retrieve a module attribute which should have been deprecated,
        and assert that we saw the appropriate deprecation warning.

        @type moduleName: C{str}
        @param moduleName: Fully-qualified Python name of the module containing
            the deprecated attribute; if called from the same module as the
            attributes are being deprecated in, using the C{__name__} global can
            be helpful

        @type name: C{str}
        @param name: Attribute name which we expect to be deprecated

        @param version: The first L{version<twisted.python.versions.Version>} that
            the module attribute was deprecated.

        @type message: C{str}
        @param message: (optional) The expected deprecation message for the module attribute

        @return: The given attribute from the named module

        @raise FailTest: if no warnings were emitted on getattr, or if the
            L{DeprecationWarning} emitted did not produce the canonical
            please-use-something-else message that is standard for Twisted
            deprecations according to the given version and replacement.

        @since: Twisted 21.2.0
        rr� is not deprecated.rJ)�fqpn�versionr�z	Expected z to start with )r^rSrUrt�getDeprecatedModuleAttributerMr}rrrr�)r5�
moduleName�namer�rJr��module�attrr��observedWarning�expectedWarnings           r+r�z0SynchronousTestCase.getDeprecatedModuleAttribute�s���:�C��$�&�����Z�(���v�t�$���*�*�D�,M�,M�+N�O�
��}���"��I�I���1�2�3�'��*�9�5��4��'��0�8
�
����-��4�w�>�O�����&�&��7���*�/�/�9L�M�	
�
�r*c�*�||i|��}|j|jg�}	t|�}|\}}	t	|�dk(r|j|�d��|dd}
t
|||	��}|j||
�|S#t$r|}d}	Y�[wxYw)aM
        Call a function that should have been deprecated at a specific version
        and in favor of a specific alternative, and assert that it was thusly
        deprecated.

        @param version: A 2-sequence of (since, replacement), where C{since} is
            a the first L{version<incremental.Version>} that C{f}
            should have been deprecated since, and C{replacement} is a suggested
            replacement for the deprecated functionality, as described by
            L{twisted.python.deprecate.deprecated}.  If there is no suggested
            replacement, this parameter may also be simply a
            L{version<incremental.Version>} by itself.

        @param f: The deprecated function to call.

        @param args: The arguments to pass to C{f}.

        @param kwargs: The keyword arguments to pass to C{f}.

        @return: Whatever C{f} returns.

        @raise Exception: Whatever C{f} raises.  If any exception is
            raised by C{f}, though, no assertions will be made about emitted
            deprecations.

        @raise FailTest: if no warnings were emitted by C{f}, or if the
            L{DeprecationWarning} emitted did not produce the canonical
            please-use-something-else message that is standard for Twisted
            deprecations according to the given version and replacement.
        Nrr�rJ)�replacement)rt�callDeprecatedrP�	TypeErrorrMr}rr�)r5r�rcrdrerhr�r��sincer�r�r�s            r+r�z"SynchronousTestCase.callDeprecated�s���>�D�#�F�#���*�*�D�,?�,?�+@�A�
�	(���=�D�
$(� �U�K��}���"��I�I���0�1�2�'��*�9�5��5�a��K�X������/�:��
���	��E��K�	�s�B�
B�Bc���d}tjj|jjd||jj
d||jd|�}tjj|�stj|�tjjtjdd|��}tjj|d�S)a
        Create a new path name which can be used for a new file or directory.

        The result is a relative path that is guaranteed to be unique within the
        current working directory.  The parent of the path will exist, but the
        path will not.

        For a temporary directory call os.mkdir on the path.  For a temporary
        file just create the file (e.g. by opening the path for writing and then
        closing it).

        @return: The newly created path
        @rtype: C{str}
        � Nr��temp)r�r�rr�r&r%rT�exists�makedirs�relpath�tempfile�mkdtemp)r5�MAX_FILENAME�base�dirnames    r+�mktempzSynchronousTestCase.mktemp(s������w�w�|�|��N�N�%�%�m�|�4��N�N�#�#�M�\�2�� � ��,�/�
��
�w�w�~�~�d�#��K�K���
�'�'�/�/�(�"2�"2�2�r�4�"@�A���w�w�|�|�G�V�,�,r*c�D�tj|jdg�S)ax
        Returns any warning suppressions set for this test. Checks on the
        instance first, then the class, then the module, then packages. As
        soon as it finds something with a C{suppress} attribute, returns that.
        Returns any empty list (i.e. suppress no warnings) if it cannot find
        anything. See L{TestCase} docstring for more details.
        �suppress)rrfrVr4s r+�_getSuppressz SynchronousTestCase._getSuppressFs���$�$�T�]�]�J��C�Cr*c�l�t|j�dkDr|jdSt|d�|S)z�
        Return the reason to use for skipping a test method.

        @param method: The method which produced the skip.
        @param skip: A L{unittest.SkipTest} instance raised by C{method}.
        rzSDo not raise unittest.SkipTest with no arguments! Give a reason for skipping tests!)rMrdr)r5rwrcs   r+�_getSkipReasonz"SynchronousTestCase._getSkipReasonPs9���t�y�y�>�A���9�9�Q�<����
"�	
�
�r*c�>�tj|�r@tdj|��}|j	|tj|��y	t||�y#t$r,}|j||j||��Yd}~yd}~wt$r|tj�}|�|j|�s?|j|j�r
|j}n|j}|||�Yy|j!|||�YywxYw)a�
        Run a single method, either a test method or fixture.

        @param suppress: Any warnings to suppress, as defined by the C{suppress}
            attribute on this method, test case, or the module it is defined in.

        @param todo: Any expected failure or failures, as defined by the C{todo}
            attribute on this method, test case, or the module it is defined in.

        @param method: The method to run.

        @param result: The TestResult instance to which to report results.

        @return: C{True} if the method fails and no further method/fixture calls
            should be made, C{False} otherwise.
        z9{!r} is a generator function and therefore will never runTFN)r��isgeneratorfunctionr�r�rrr�rrr�r�r=r:r8r�r{r�)	r5r�r�rwrh�exc�er.�	addResults	         r+�_runzSynchronousTestCase._runas��"�&�&�v�.��K�R�R����C�

�O�O�D�'�/�/�#�"6�7��	�%�h��7����	A��N�N�4��!4�!4�V�Q�!?�@�@����		>��_�_�&�F��|�4�=�=��#8��<�<�� 5� 5�6� &� 1� 1�I� &���I��$��'�
��)�)�$���=��		>�s%�A$�$	D�-"B�A0D�D�Dc��|j�}	|j|d|j|�r	|j|�y|j	�}t||j�}|j||||�}|j|�|r|s|j||�|j|d|j|�rd}|jj�D]}|j||�d}�|jj�|j�|s|s|j|�yyy#|j|�wxYw)z�
        Run C{setUp}, a test method, test cleanups, and C{tearDown}.

        @param result: The TestResult instance to which to report results.
        NT)r�r��setUp�_runCleanupsrkrUrTr��tearDownr�rIrrG�_removeObserverr�)r5rhr�r�rw�failedr9s       r+rsz'SynchronousTestCase._runFixturesAndTest�s*���$�$�&��	&��y�y��4����V�<��
���f�%�	�<�<�>�D��T�4�#7�#7�8�F��Y�Y�x��v�v�>�F����f�%����'�'��d�3��9�9�X�t�T�]�]�F�;��F��^�^�-�-�/�	�E��O�O�D�%�(��F�	�	
���"�"�$������$����d�#����
���f�%�s�D9�:D9�9Ec� �t|j�dkDrA|jj�\}}}	||i|��t|j�dkDr�@yy#t$r)t	j
�}|j
||�Y�LwxYw)zG
        Synchronously run any cleanups which have been added.
        rN)rMrS�popr=rr�r)r5rhrcrdres     r+r�z SynchronousTestCase._runCleanups�s}���$�.�.�!�A�%�"�n�n�0�0�2�O�A�t�V�
)��4�"�6�"��$�.�.�!�A�%��!�
)��O�O�%������a�(�
)�s�A�/B
�B
c�N�t|_|jj�yrH)�_logObserverr�r9r4s r+rrz$SynchronousTestCase._installObserver�s��%��������r*c�8�|jj�yrH)r�r<r4s r+r�z#SynchronousTestCase._removeObserver�s������� r*)rmrH)&r%r&r'r(r#r�rNr�boolr[r^r`rrr;rirkrmrxrr rdrerzr}r�rtr�r�r�r�r�r�rsr�rrr�r.r/s@r+rPrP�s����&�P ��W�"�F�"�t�"�<��$��t�X�c�]�2�3�$�(��)�Z
1��"�f�*�%�
1�.0�g�g�
1�AC���
1�	
�
1��(7�Z
�x0�d0�d-�<D��")�V$�@
)��!r*rP)Dr(r�r�r^r�r��unittest�pyunitr_�disrr��typingrrrrrr	r
rrr
rrr�attrsrr�twisted.internet.deferrr�twisted.pythonrrr�twisted.python.deprecaterrrr�twisted.python.reflectr�twisted.python.utilr�
twisted.trialrrr r!�AssertionErrorr#r-r;r=rDrFrUri�	Exceptionrkrmr��TestCaser�r1r�rPr)r*r+�<module>r�sS��
��	�
�����1�
�
�
�
� ���;�/�/���6�9�&��t�_���C�L���~���!�!��!�H:���U�5��m�,�h�t�M�7J�.K�K�L�c�Q�
R�R��:�
�	:�8��@�$�@J�i�J�9
�9
�xZ�Z�zS�&�/�/�S�lN'�N'�b�~��d!�+�d!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!