%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/trial/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/trial/__pycache__/reporter.cpython-312.pyc

�

Ϫ�f��	���UdZddlmZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZmZmZmZmZmZddlmZddl
mZdd	lmZmZdd
lmZddlmZddlmZdd
l m!Z!m"Z"erddl#m$Z$	ddl%m&Z&eee(e(efZ)de*d<ee)edfZ+ee+efZ,d8d�Z-Gd�de.�Z/Gd�d�Z0ee!jb�Gd�dejd��Z2ee!jb�Gd�dee!jbd���Z3ee!jb�Gd�de3��Z4ee!jb�Gd �d!e3��Z5Gd"�d#e3�Z6ee!jb�Gd$�d%e2��Z7Gd&�d'e7�Z8Gd(�d)e7�Z9Gd*�d+e7�Z:Gd,�d-e:�Z;Gd.�d/�Z<Gd0�d1�Z=Gd2�d3�Z>ee!jb�Gd4�d5��Z?Gd6�d7e7�Z@y#e'$rdZ&Y��wxYw)9z3
Defines classes that handle the results of tests.
�)�annotationsN)�OrderedDict)�
TracebackType)�
TYPE_CHECKING�List�Optional�Tuple�Type�Union)�implementer)�	TypeAlias)�log�reflect)�proxyForInterface)�Failure)�untilConcludes)�itrial�util�)�Todo)�TestProtocolClientr
�ExcInfo)NNNc��ddlm}||�S)ad
    Return a L{Todo} object built from C{value}.

    This is a synonym for L{twisted.trial.unittest.makeTodo}, but imported
    locally to avoid circular imports.

    @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)�makeTodo)�twisted.trial.unittestr)�valuers  �8/usr/lib/python3/dist-packages/twisted/trial/reporter.py�	_makeTodor,s��0��E�?��c��eZdZdZy)�BrokenTestCaseWarningzT
    Emitted as a warning when an exception occurs in one of setUp or tearDown.
    N��__name__�
__module__�__qualname__�__doc__�rrr!r!=s��rr!c�"�eZdZdZd�Zd�Zd�Zy)�
SafeStreamz�
    Wraps a stream object so that all C{write} calls are wrapped in
    L{untilConcludes<twisted.python.util.untilConcludes>}.
    c��||_y�N)�original)�selfr,s  r�__init__zSafeStream.__init__Is	�� ��
rc�.�t|j|�Sr+)�getattrr,)r-�names  r�__getattr__zSafeStream.__getattr__Ls���t�}�}�d�+�+rc�H�t|jjg|��i|��Sr+)rr,�write)r-�a�kws   rr4zSafeStream.writeOs!���d�m�m�1�1�<�A�<��<�<rN)r#r$r%r&r.r2r4r'rrr)r)Cs���
!�,�=rr)c���eZdZUdZdZded<ded<ded<ded	<d
ed<d
ed<�fd
�Zdd�Zd�Zd�Z	�fd�Z
�fd�Zd�Zd�Z
d�Zdd�Zdd�Zd�Zd�Zd�Z�xZS)�
TestResulta�
    Accumulates the results of several L{twisted.trial.unittest.TestCase}s.

    @ivar successes: count the number of successes achieved by the test run.
    @type successes: C{int}

    @ivar _startTime: The time when the current test was started. It defaults to
    L{None}, which means that the test was skipped.
    @ivar _lastTime: The duration of the current test run. It defaults to
    L{None}, which means that the test was skipped.
    zTest expected to failz"List[Tuple[itrial.ITestCase, str]]�skipsz*List[Tuple[itrial.ITestCase, str, 'Todo']]�expectedFailures�unexpectedSuccesses�int�	successesz
Optional[int]�_testStarted�	_lastTimec���t�|��g|_g|_g|_d|_g|_d|_d|_y)Nr)	�superr.r9r:r;r=�_timingsr>r?)r-�	__class__s �rr.zTestResult.__init__lsB���
������
� "���#%�� ������
� �����rc
�&�dtj|j�|jt	|j
�t	|j�t	|j�t	|j�t	|j�fzS)Nz<<%s run=%d errors=%d failures=%d todos=%d dones=%d skips=%d>)
r�qualrC�testsRun�len�errors�failuresr:r9r;�r-s r�__repr__zTestResult.__repr__vsk��M��L�L����(��M�M��������
�
����%�%�&���
�
�O���(�(�)�Q
�
�	
rc�*�tj�Sr+)�timerJs r�_getTimezTestResult._getTime�s���y�y�{�rc��t|t�xrt|�dk(}|rt|d|d|d�St|t�r|St	d|�d���)zX
        Convert a C{sys.exc_info()}-style tuple to a L{Failure}, if necessary.
        �rr�zCannot convert z
 to a Failure)�
isinstance�tuplerGr�	TypeError)r-�error�is_exc_info_tuples   r�_getFailurezTestResult._getFailure�s_��'�u�e�4�H��U��q�����5��8�U�1�X�u�Q�x�8�8�
��w�
'��L��/�%��
�>�?�?rc�N��t�|�|�|j�|_y)zq
        This must be called before the given test is commenced.

        @type test: L{pyunit.TestCase}
        N)rA�	startTestrNr>�r-�testrCs  �rrYzTestResult.startTest�s ���	���$�� �M�M�O��rc���t�|�|�|j�#|j�|jz
|_yy)zp
        This must be called after the given test is completed.

        @type test: L{pyunit.TestCase}
        N)rA�stopTestr>rNr?rZs  �rr]zTestResult.stopTest�s;���	��������(�!�]�]�_�t�/@�/@�@�D�N�)rc�\�|jj||j|�f�y)z�
        Report a failed assertion for the given test.

        @type test: L{pyunit.TestCase}
        @type fail: L{Failure} or L{tuple}
        N)rI�appendrW)r-r[�fails   r�
addFailurezTestResult.addFailure�s&��	
�
�
���d�D�$4�$4�T�$:�;�<rc�\�|jj||j|�f�y)z�
        Report an error that occurred while running the given test.

        @type test: L{pyunit.TestCase}
        @type error: L{Failure} or L{tuple}
        N)rHr_rW�r-r[rUs   r�addErrorzTestResult.addError�s&��	
�����D�$�"2�"2�5�"9�:�;rc�>�|jj||f�y)a5
        Report that the given test was skipped.

        In Trial, tests can be 'skipped'. Tests are skipped mostly because
        there is some platform or configuration issue that prevents them from
        being run correctly.

        @type test: L{pyunit.TestCase}
        @type reason: L{str}
        N)r9r_)r-r[�reasons   r�addSkipzTestResult.addSkip�s��	
�
�
���4��.�)rc�l�|�t|j�}|jj||f�y)a�
        Report that the given test succeeded against expectations.

        In Trial, tests can be marked 'todo'. That is, they are expected to
        fail.  When a test that is expected to fail instead succeeds, it should
        call this method to report the unexpected success.

        @type test: L{pyunit.TestCase}
        @type todo: L{unittest.Todo}, or L{None}, in which case a default todo
            message is provided.
        N)r�
_DEFAULT_TODOr;r_�r-r[�todos   r�addUnexpectedSuccesszTestResult.addUnexpectedSuccess�s1���<��T�/�/�0�D�� � �'�'��t��5rc�n�|�t|j�}|jj|||f�y)ab
        Report that the given test failed, and was expected to do so.

        In Trial, tests can be marked 'todo'. That is, they are expected to
        fail.

        @type test: L{pyunit.TestCase}
        @type error: L{Failure}
        @type todo: L{unittest.Todo}, or L{None}, in which case a default todo
            message is provided.
        N)rrir:r_)r-r[rUrks    r�addExpectedFailurezTestResult.addExpectedFailure�s4���<��T�/�/�0�D����$�$�d�E�4�%8�9rc�.�|xjdz
c_y)z_
        Report that the given test succeeded.

        @type test: L{pyunit.TestCase}
        rN)r=�r-r[s  r�
addSuccesszTestResult.addSuccess�s��	
���!��rc�n�t|j�t|j�cxk(xrdk(ScS)a�
        Report whether or not this test suite was successful or not.

        The behaviour of this method changed in L{pyunit} in Python 3.4 to
        fail if there are any errors, failures, or unexpected successes.
        Previous to 3.4, it was only if there were errors or failures. This
        method implements the old behaviour for backwards compatibility reasons,
        checking just for errors and failures.

        @rtype: L{bool}
        r)rGrIrHrJs r�
wasSuccessfulzTestResult.wasSuccessful�s,���4�=�=�!�S����%5�:��:�:�:�:rc��y)z6
        The test suite has finished running.
        Nr'rJs r�donezTestResult.done���r)�return�strr+)r#r$r%r&ri�__annotations__r.rKrNrWrYr]rardrgrlrnrqrsru�
__classcell__�rCs@rr8r8Ssz���
�,�M�-�-�@�@�;�;��N������	
��	@�,�A�=�<�*�6� :� �;�rr8c��eZdZdZy)�TestResultDecoratorz�
    Base class for TestResult decorators.

    @ivar _originalReporter: The wrapped instance of reporter.
    @type _originalReporter: A provider of L{itrial.IReporter}
    Nr"r'rrr}r}�s��rr}�_originalReporterc��eZdZdZd�Zy)�UncleanWarningsReporterWrapperze
    A wrapper for a reporter that converts L{util.DirtyReactorAggregateError}s
    to warnings.
    c���t|t�rC|jtj�r$tj|j��y|jj||�y)z�
        If the error is a L{util.DirtyReactorAggregateError}, instead of
        reporting it as a normal error, throw a warning.
        N)
rRr�checkr�DirtyReactorAggregateError�warnings�warn�getErrorMessager~rdrcs   rrdz'UncleanWarningsReporterWrapper.addErrorsJ���e�W�%�%�+�+�d�6U�6U�*V��M�M�%�/�/�1�2��"�"�+�+�D�%�8rN)r#r$r%r&rdr'rrr�r�	s���
	9rr�c��eZdZdZd�Zd�Zy)�_ExitWrapperza
    A wrapper for a reporter that causes the reporter to stop after
    unsuccessful tests.
    c�H�d|_|jj|i|��S�NT)�
shouldStopr~rd�r-�args�kwargss   rrdz_ExitWrapper.addError#s'�����.�t�%�%�.�.��?��?�?rc�H�d|_|jj|i|��Sr�)r�r~rar�s   rraz_ExitWrapper.addFailure's'�����0�t�%�%�0�0�$�A�&�A�ArN)r#r$r%r&rdrar'rrr�r�s���
@�Brr�c�D�eZdZdZd�Zd�Zdd�Zd�Zd�Zdd�Z	d	�Z
d
�Zy)�_AdaptedReporterz�
    TestResult decorator that makes sure that addError only gets tests that
    have been adapted with a particular test adapter.
    c�>�tj||�||_y)z�
        Construct an L{_AdaptedReporter}.

        @param original: An {itrial.IReporter}.
        @param testAdapter: A callable that returns an L{itrial.ITestCase}.
        N)r}r.�testAdapter)r-r,r�s   rr.z_AdaptedReporter.__init__2s��	�$�$�T�8�4�&��rc�\�|j|�}|jj||�S�z*
        See L{itrial.IReporter}.
        )r�r~rdrcs   rrdz_AdaptedReporter.addError<s-������%���%�%�.�.�t�U�;�;rNc�Z�|jj|j|�||�S)at
        See L{itrial.IReporter}.

        @type test: A L{pyunit.TestCase}.
        @type failure: A L{failure.Failure} or L{AssertionError}
        @type todo: A L{unittest.Todo} or None

        When C{todo} is L{None} a generic C{unittest.Todo} is built.

        L{pyunit.TestCase}'s C{run()} calls this with 3 positional arguments
        (without C{todo}).
        )r~rnr�)r-r[�failurerks    rrnz#_AdaptedReporter.addExpectedFailureCs/���%�%�8�8����T�"�G�T�
�	
rc�\�|j|�}|jj||�Sr�)r�r~ra)r-r[r�s   rraz_AdaptedReporter.addFailureTs-������%���%�%�0�0��w�?�?rc�\�|j|�}|jj||�Sr�)r�r~rg)r-r[�skips   rrgz_AdaptedReporter.addSkip[s-������%���%�%�-�-�d�D�9�9rc�\�|j|�}|jj||�S)a3
        See L{itrial.IReporter}.

        @type test: A L{pyunit.TestCase}.
        @type todo: A L{unittest.Todo} or None

        When C{todo} is L{None} a generic C{unittest.Todo} is built.

        L{pyunit.TestCase}'s C{run()} calls this with 2 positional arguments
        (without C{todo}).
        )r�r~rlrjs   rrlz%_AdaptedReporter.addUnexpectedSuccessbs-������%���%�%�:�:�4��F�Frc�V�|jj|j|��Sr�)r~rYr�rps  rrYz_AdaptedReporter.startTestqs&���%�%�/�/��0@�0@��0F�G�Grc�V�|jj|j|��Sr�)r~r]r�rps  rr]z_AdaptedReporter.stopTestws&���%�%�.�.�t�/?�/?��/E�F�Frr+)r#r$r%r&r.rdrnrargrlrYr]r'rrr�r�,s3���
'�<�
�"@�:�
G�H�Grr�c����eZdZdZdZdZejdddf�fd�	Zd�Z	�fd	�Z
�fd
�Z�fd�Zd�Z
d
�Zd�fd�	Z�fd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�Reportera�
    A basic L{TestResult} with support for writing to a stream.

    @ivar _startTime: The time when the first test was started. It defaults to
        L{None}, which means that no test was actually launched.
    @type _startTime: C{float} or L{None}

    @ivar _warningCache: A C{set} of tuples of warning message (file, line,
        text, category) which have already been written to the output stream
        during the currently executing test.  This is used to avoid writing
        duplicates of the same warning to the output stream.
    @type _warningCache: C{set}

    @ivar _publisher: The log publisher which will be observed for warning
        events.
    @type _publisher: L{twisted.python.log.LogPublisher}
    zO-------------------------------------------------------------------------------zO===============================================================================�defaultFNc����t�|��t|�|_||_||_d|_t�|_||_	|�|j|j�yyr+)rAr.r)�_stream�tbformat�realtime�
_startTime�set�
_warningCache�
_publisher�addObserver�_observeWarnings)r-�streamr�r��	publisherrCs     �rr.zReporter.__init__�sc���	����!�&�)��� ��
� ��
���� �U���$���� ��!�!�$�"7�"7�8�!rc��d|vrv|d|d|djd�dt|d�f}||jvr:|jj|�|jjd|z�yyy)	a|
        Observe warning events and write them to C{self._stream}.

        This method is a log observer which will be registered with
        C{self._publisher.addObserver}.

        @param event: A C{dict} from the logging system.  If it has a
            C{'warning'} key, a logged warning will be extracted from it and
            possibly written to C{self.stream}.
        �warning�filename�lineno�category�.���z%s:%s: %s: %s
N)�splitrxr��addr�r4)r-�event�keys   rr�zReporter._observeWarnings�s�������j�!��h���j�!�'�'��,�R�0��E�)�$�%�	�C��$�,�,�,��"�"�&�&�s�+����"�"�#4�s�#:�;�-�rc���t�|�|�|j�|j�|_t	�|_y)z�
        Called when a test begins to run. Records the time when it was first
        called and resets the warning cache.

        @param test: L{ITestCase}
        N)rArYr�rNr�r�rZs  �rrYzReporter.startTest�s3���	���$���?�?�"�"�m�m�o�D�O� �U��rc���t�|�||�|jr3|jdd}|j	|j|��yy)z�
        Called when a test fails. If C{realtime} is set, then it prints the
        error to the stream.

        @param test: L{ITestCase} that failed.
        @param fail: L{failure.Failure} containing the error.
        r�rN)rArar�rI�_write�_formatFailureTraceback)r-r[r`rCs   �rrazReporter.addFailure�sJ���	���4��&��=�=��=�=��$�Q�'�D��K�K��4�4�T�:�;�rc����|j|�}t�|�	||�|jr3|jdd}|j|j
|��yy)z�
        Called when a test raises an error. If C{realtime} is set, then it
        prints the error to the stream.

        @param test: L{ITestCase} that raised the error.
        @param error: L{failure.Failure} containing the error.
        r�rN)rWrArdr�rHr�r�)r-r[rUrCs   �rrdzReporter.addError�sY���� � ��'��
����u�%��=�=��K�K��O�A�&�E��K�K��4�4�U�;�<�rc���t|�}t|t�sJ�|r|jj||z�n|jj|�t	|jj
�y)z�
        Safely write to the reporter's stream.

        @param format: A format string to write.
        @param args: The arguments for the format string.
        N)rxrRr�r4r�flush)r-�formatr��ss    rr�zReporter._write�sZ��
��K���!�S�!�!�!���L�L���q�4�x�(��L�L���q�!��t�|�|�)�)�*rc�L�|j|g|���|jd�y)z�
        Safely write a line to the reporter's stream. Newline is appended to
        the format string.

        @param format: A format string to write.
        @param args: The arguments for the format string.
        �
N)r�)r-r�r�s   r�_writelnzReporter._writeln�s#��	����F�"�T�"����D�rc����t�|�||||�|rU|j|�}tj|�dj||�}t
j|td��yy)Nz3caught exception in {}, your TestCase is broken

{}rQ)�
stacklevel)	rA�upDownErrorr�r�msgr�r�r�r!)r-�methodrUr��printStatus�tbStrr�rCs       �rr�zReporter.upDownError�sb���
���F�E�4��=���0�0��7�E��G�G�E�N�I�P�P����C�
�M�M�#�4��C�rc���t�|�|�tjd�d|j	|���t
�y)Nz&REACTOR UNCLEAN! traceback(s) follow: r�)rA�
cleanupErrorsr�r�r�r!�r-�errsrCs  �rr�zReporter.cleanupErrorss9���
���d�#��
�
�9��,�,�T�2�
�

"�
	
rc��t|�}t|�dkr|S|dd}tjj	tjj|dd��d}|dd}tjj	tjj|dd��d}d}d}||f||ff}	|D]s}
tjj	tjj|
d��d}|dk(s�K|
ddk(s�T|j
|j|
���u|	|k(r|dd}n|	|k(r|d	d}n||fd
k(r|dd}|s|S|d}|djd�rJtjj	tjj|d��dd
k(r|dd}|S)a)
        Trim frames to remove internal paths.

        When a C{SynchronousTestCase} method fails synchronously, the stack
        looks like this:
         - [0]: C{SynchronousTestCase._run}
         - [1]: C{util.runWithWarningsSuppressed}
         - [2:-2]: code in the test method which failed
         - [-1]: C{_synctest.fail}

        When a C{TestCase} method fails synchronously, the stack looks like
        this:
         - [0]: C{defer.maybeDeferred}
         - [1]: C{utils.runWithWarningsSuppressed}
         - [2]: C{utils.runWithWarningsSuppressed}
         - [3:-2]: code in the test method which failed
         - [-1]: C{_synctest.fail}

        When a method fails inside a C{Deferred} (i.e., when the test method
        returns a C{Deferred}, and that C{Deferred}'s errback fires), the stack
        captured inside the resulting C{Failure} looks like this:
         - [0]: C{defer.Deferred._runCallbacks}
         - [1:-2]: code in the testmethod which failed
         - [-1]: C{_synctest.fail}

        As a result, we want to trim either [maybeDeferred, runWWS, runWWS] or
        [Deferred._runCallbacks] or [SynchronousTestCase._run, runWWS] from the
        front, and trim the [unittest.fail] from the end.

        There is also another case, when the test method is badly defined and
        contains extra arguments.

        If it doesn't recognize one of these cases, it just returns the
        original frames.

        @param frames: The C{list} of frames from the test failure.

        @return: The C{list} of frames to display.
        rQrr))�_run�	_synctest)�runWithWarningsSuppressedr))�
maybeDeferred�defer)r��utils�compat�reraiseNrP)�
_runCallbacksr�r�r`r�)	�listrG�os�path�splitext�basename�pop�index�
startswith)
r-�frames�	newFrames�firstMethod�	firstFile�secondMethod�
secondFile�syncCase�	asyncCase�	twoFrames�frame�	frameFile�lasts
             r�_trimFrameszReporter._trimFramess���P��L�	��v�;��?�����l�1�o���G�G�$�$�R�W�W�%5�%5�i��l�1�o�%F�G��J�	� ��|�A����W�W�%�%�b�g�g�&6�&6�y��|�A��&G�H��K�
�Q��X�	�!�9�-��j�/I�J�	��	6�E����(�(����)9�)9�%��(�)C�D�Q�G�I��H�$��q��Y�)>��
�
�i�o�o�e�4�5�		6��� �!�!�"�
�I�
�)�
#�!�!�"�
�I��9�
%�)C�
C�!�!�"�
�I������}����G���v�&���� � ����!1�!1�$�q�'�!:�;�A�>�+�M�!�#�2��I��rc���t|t�r|j�dzS|j|j�|jc|_}|j|jd��}||_|S)Nr�T)�detail�elideFrameworkCode)rRrx�rstripr�r��getTracebackr�)r-r`r��results    rr�z Reporter._formatFailureTracebackesc���d�C� ��;�;�=�4�'�'�"�.�.�t�{�{�;�T�[�[����V��"�"�$�-�-�D�"�Q������
rc��t�}|D]2}|d}|dd}||�}|j|g�j|��4t|j	��S)a
        Group tests together based on their results.

        @param results: An iterable of tuples of two or more elements.  The
            first element of each tuple is a test case.  The remaining
            elements describe the outcome of that test case.

        @param formatter: A callable which turns a test case result into a
            string.  The elements after the first of the tuples in
            C{results} will be passed as positional arguments to
            C{formatter}.

        @return: A C{list} of two-tuples.  The first element of each tuple
            is a unique string describing one result from at least one of
            the test cases in C{results}.  The second element is a list of
            the test cases which had that result.
        rrN)r�
setdefaultr_r��items)r-�results�	formatter�groups�content�case�outcomer�s        r�
_groupResultszReporter._groupResultsmsf��$����	4�G��1�:�D��a�b�k�G��W�%�C����c�2�&�-�-�d�3�		4�
�F�L�L�N�#�#rc� �|j||�D]y\}}|j|j�|j|�|j|�|jd�|D]!}|j|j	���#�{y)a<
        Print a group of errors to the stream.

        @param flavor: A string indicating the kind of error (e.g. 'TODO').
        @param errors: A list of errors, often L{failure.Failure}s, but
            sometimes 'todo' errors.
        @param formatter: A callable that knows how to format the errors.
        �N)r�r��_doubleSeparatorr��id)r-�flavorrHr�rf�casesr�s       r�
_printResultszReporter._printResults�s{��"�/�/��	�B�	)�M�F�E��M�M�$�/�/�0��M�M�&�!��K�K����M�M�"���
)���
�
�d�g�g�i�(�
)�	)rc�X�dj|j|j|��S)NzReason: {!r}
{})r�rfr�)r-rUrks   r�_printExpectedFailurezReporter._printExpectedFailure�s)��!�(�(��K�K��5�5�e�<�
�	
rc��d|j�d�}|jr-|djdj|j��z
}|S)NzReason: r�zExpected errors: {}
�, )rfrHr��join)r-rk�rets   r�_printUnexpectedSuccessz Reporter._printUnexpectedSuccess�sC�������r�*���;�;��*�1�1�$�)�)�D�K�K�2H�I�I�C��
rc��|jd�|jd|jd��|jd|j|j�|jd|j
|j�|jd|j|j�|jd|j|j�y)	zM
        Print all of the non-success results to the stream in full.
        r��	[SKIPPED]c��d|zS)N�%s
r')�xs r�<lambda>z'Reporter._printErrors.<locals>.<lambda>�s
��f�q�j�r�[TODO]�[FAIL]�[ERROR]�[SUCCESS!?!]N)
r�rr9r:rrIr�rHr;rrJs r�_printErrorszReporter._printErrors�s���	
���D�����;��
�
�4H�I����8�T�%:�%:�D�<V�<V�W����8�T�]�]�D�4P�4P�Q����9�d�k�k�4�3O�3O�P�����D�4�4�d�6R�6R�	
rc��g}dD]0}tt||��}|s�|jd||fz��2|jr|jd|jfz�|xrddj	|�zdzxsd}|S)zC
        Return a formatted count of tests status results.
        )r9r:rIrHr;z%s=%dzsuccesses=%dz (r�)r�)rGr0r_r=r	)r-�	summaries�stat�num�summarys     r�_getSummaryzReporter._getSummary�s����	�
�		8�D��g�d�D�)�*�C��� � ��D�#�;�!6�7�		8��>�>����^�t�~�~�.?�?�@��B���	�	�)�(<�!<�s�!B�I�r���rc�t�|j�}|j�rd}nd}|jd||�y)zJ
        Print a line summarising the test results to the stream.
        �PASSED�FAILEDz%s%s
N)rrsr�)r-r�statuss   r�
_printSummaryzReporter._printSummary�s8���"�"�$�������F��F����H�f�g�.rc��|j�%|jj|j�|j�|j	|j
�|j�<|j	d|jtj�|jz
�|jd�|j�y)a�
        Summarize the result of the test run.

        The summary includes a report of all of the errors, todos, skips and
        so forth that occurred during the run. It also includes the number of
        tests that were run and how long it took to run them (not including
        load time).

        Expects that C{_printErrors}, C{_writeln}, C{_write}, C{_printSummary}
        and C{_separator} are all implemented.
        NzRan %d tests in %.3fsr�)r��removeObserverr�rr��
_separatorr�rFrMr�r"rJs rruz
Reporter.done�s����?�?�&��O�O�*�*�4�+@�+@�A������
�
�d�o�o�&��?�?�&��M�M�'�����	�	��d�o�o�8U�
�	
���D�����r)TT)r#r$r%r&r%r�sys�stdoutr.r�rYrardr�r�r�r�r�r�r�rrrrrr"rurzr{s@rr�r�~s�����$�J����Z�Z�)�e�t�
9�<�,
#�<�=�
+�	�	D�	
�R�h�$�4)�"
�
�
��(	/�rr�c��eZdZdZd�Zd�Zy)�MinimalReporterz�
    A minimalist reporter that prints only a summary of the test result, in
    the form of (timeTaken, #tests, #tests, #errors, #failures, #skips).
    c��y)zb
        Don't print a detailed summary of errors. We only care about the
        counts.
        Nr'rJs rrzMinimalReporter._printErrors�rvrc�R�|j}|j�|j�|jz
}nd}|||t|j�t|j
�t|j�f}|jdjtt|���y)z�
        Print out a one-line summary of the form:
        '%(runtime) %(number_of_tests) %(number_of_tests) %(num_errors)
        %(num_failures) %(num_skips)'
        Nr� )rFr�rNrGrHrIr9r�r	�maprx)r-�numTests�timing�ts    rr"zMinimalReporter._printSummary�s����=�=���?�?�&��]�]�_�t���6�F��F�����������
�
����
�
�O�

��	
�
�
�c�h�h�s�3��{�+�,rN)r#r$r%r&rr"r'rrr)r)�s���
�-rr)c�T��eZdZdZ�fd�Z�fd�Z�fd�Z�fd�Z�fd�Z�fd�Z	�xZ
S)�TextReporterz�
    Simple reporter that prints a single character for each test as it runs,
    along with the standard Trial summary text.
    c�F��t�|�|�|jd�y)Nr��rArqr�rZs  �rrqzTextReporter.addSuccesss���
���4� ����C�rc�@��t�|�|�|jd�y)N�E�rArdr��r-r�rCs  �rrdzTextReporter.addErrors���
���$�����C�rc�@��t�|�|�|jd�y)N�F�rArar�r8s  �rrazTextReporter.addFailures���
���D�!����C�rc�@��t�|�|�|jd�y)N�S�rArgr�r8s  �rrgzTextReporter.addSkips���
��������C�rc�@��t�|�|�|jd�y)N�T�rArnr�r8s  �rrnzTextReporter.addExpectedFailures���
��"�D�)����C�rc�@��t�|�|�|jd�y)N�!�rArlr�r8s  �rrlz!TextReporter.addUnexpectedSuccess#s���
��$�d�+����C�r)r#r$r%r&rqrdrargrnrlrzr{s@rr2r2	s+����
������rr2c�h��eZdZdZ�fd�Z�fd�Z�fd�Z�fd�Z�fd�Z�fd�Z	�fd�Z
�fd	�Z�xZS)
�VerboseTextReporterz�
    A verbose reporter that prints the name of each test as it is running.

    Each line is printed with the name of the test, followed by the result of
    that test.
    c�d��|jd|j��t�|�
|�y)Nz%s ... )r�rrArY)r-�tmrCs  �rrYzVerboseTextReporter.startTest2s$������I�r�u�u�w�'�
���"�rc�F��t�|�|�|jd�y�Nz[OK]r4rZs  �rrqzVerboseTextReporter.addSuccess6s���
���4� ����F�rc�@��t�|�|�|jd�y�Nrr7r8s  �rrdzVerboseTextReporter.addError:s���
���$�����I�rc�@��t�|�|�|jd�y)Nz	[FAILURE]r;r8s  �rrazVerboseTextReporter.addFailure>s���
���D�!����K� rc�@��t�|�|�|jd�y�Nr
r>r8s  �rrgzVerboseTextReporter.addSkipBs���
��������K� rc�@��t�|�|�|jd�y�NrrAr8s  �rrnz&VerboseTextReporter.addExpectedFailureFs���
��"�D�)����H�rc�@��t�|�|�|jd�y�NrrDr8s  �rrlz(VerboseTextReporter.addUnexpectedSuccessJs���
��$�d�+����N�#rc�F��t�|�|�|jd�y)Nr�)rAr]r�rZs  �rr]zVerboseTextReporter.stopTestNs���
��������D�r)
r#r$r%r&rYrqrdrargrnrlr]rzr{s@rrFrF(s5�������!�!��$��rrFc�"��eZdZdZ�fd�Z�xZS)�TimingTextReporterze
    Prints out each test as it is running, followed by the time taken for each
    test to run.
    c�`��t�|�|�|jd|jz�y)zm
        Mark the test as stopped, and write the time it took to run the test
        to the stream.
        z
(%.03f secs)
N)rAr]r�r?)r-r�rCs  �rr]zTimingTextReporter.stopTestYs(���
	���� ����$�t�~�~�5�6r)r#r$r%r&r]rzr{s@rrVrVSs����
7�7rrVc
�d�eZdZdZedddddddd	�
�Zd�Zeejfd��Z
d
�Zy)�_AnsiColorizerz�
    A colorizer is an object that loosely wraps around a stream, allowing
    callers to write text to the stream in a particular color.

    Colorizer classes must implement C{supported()} and C{write(text, color)}.
    ��� �!�"�#�$�%)�black�red�green�yellow�blue�magenta�cyan�whitec��||_yr+�r��r-r�s  rr.z_AnsiColorizer.__init__n�	����rc��|j�sy	ddl}		|jd�dkDS#|j$r'|j	�|jd�dkDcYSwxYw#t
$rYywxYw#t$rYywxYw)z�
        A class method that returns True if the current platform supports
        coloring terminal output using this method. Returns False otherwise.
        FrN�colorsrQ)�isatty�curses�tigetnumrU�	setupterm�
BaseException�ImportError)�clsr�rqs   r�	supportedz_AnsiColorizer.supportedqs����}�}���
	��
�9�!�?�?�8�4�q�8�8���|�|�9��$�$�&�!�?�?�8�4�q�8�8�9��!�
��
���	��	�s8�A5�-�3A#� A&�"A#�#A&�&	A2�1A2�5	B�Bc�f�|j|}|jjd|�d|�d��y)z�
        Write the given text to the stream in the given color.

        @param text: Text to be written to the stream.

        @param color: A string label for a color. e.g. 'red', 'white'.
        z;1mzN)�_colorsr�r4�r-�text�colors   rr4z_AnsiColorizer.write�s3�����U�#�������E�%���D�6��9�:rN)r#r$r%r&�dictryr.�classmethodr&r'rwr4r'rrrYrYbsJ�����b��2�B���SU��G���!�j�j����,	;rrYc�D�eZdZdZd�Zeejfd��Zd�Z	y)�_Win32Colorizer�'
    See _AnsiColorizer docstring.
    c	���ddlm}m}m}m}m}m}||||f\}}	}
}||_||�|_||	z|
z||z|	|z|
|z||	z|z||
z|z|	|
z|z||	z|
z|zd�|_	y)Nr)�FOREGROUND_BLUE�FOREGROUND_GREEN�FOREGROUND_INTENSITY�FOREGROUND_RED�STD_OUTPUT_HANDLE�GetStdHandle)�normalrcrdrfrergrhri)
�win32consoler�r�r�r�r�r�r��screenBufferry)r-r�r�r�r�r�r�r�rcrdrf�bolds            rr.z_Win32Colorizer.__init__�s���	
�	
�
��� �	"
���U�D�$����(�):�;����E�k�D�(���:��T�\��4�K��E�k�D�(��T�z�D�(��D�L�4�'��5�[�4�'�$�.�	
��rc��	ddl}|j|j�}ddl}	|j|j|jz|jz�y#t$rYywxYw#|j$rYywxYw)NrFT)
r�r�r�ru�
pywintypes�SetConsoleTextAttributer�r�r�rU)rvr�r�r�r�s     rrwz_Win32Colorizer.supported�s���	��'�4�4�\�5S�5S�T�L�	�		��0�0��+�+��/�/�0��.�.�/�
����	��	�����	��	�s"�A�5A+�	A(�'A(�+A=�<A=c���|j|}|jj|�|jj	|�|jj|jd�y)Nr�)ryr�r�r�r4rzs   rr4z_Win32Colorizer.write�sS�����U�#�����1�1�%�8������$�����1�1�$�,�,�x�2H�IrN�
r#r$r%r&r.r~r&r'rwr4r'rrr�r��s-���
�:�!�j�j����(Jrr�c�D�eZdZdZd�Zeejfd��Zd�Z	y)�_NullColorizerr�c��||_yr+rkrls  rr.z_NullColorizer.__init__�rmrc��yr�r')rvr�s  rrwz_NullColorizer.supported�s��rc�:�|jj|�yr+)r�r4rzs   rr4z_NullColorizer.write�s�������$�rNr�r'rrr�r��s,�����!�j�j���� rr�c��eZdZdZdZejdddfd�Zd�Ze	d��Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zdd�Zdd�Zy)�SubunitReporterz�
    Reports test output via Subunit.

    @ivar _subunit: The subunit protocol client that we are wrapping.

    @ivar _successful: An internal variable, used to track whether we have
        received only successful results.

    @since: 10.0
    Nr�Fc�T�t�td��t|�|_d|_y)aI
        Construct a L{SubunitReporter}.

        @param stream: A file-like object representing the stream to print
            output to. Defaults to stdout.
        @param tbformat: The format for tracebacks. Ignored, since subunit
            always uses Python's standard format.
        @param realtime: Whether or not to print exceptions in the middle
            of the test results. Ignored, since subunit always does this.
        @param publisher: The log publisher which will be preserved for
            reporting events. Ignored, as it's not relevant to subunit.
        NzSubunit not availableT)r�	Exception�_subunit�_successful)r-r�r�r�r�s     rr.zSubunitReporter.__init__�s*���%��3�4�4�*�6�2��
���rc��y)z�
        Record that the entire test suite run is finished.

        We do nothing, since a summary clause is irrelevant to the subunit
        protocol.
        Nr'rJs rruzSubunitReporter.dones��	
rc�.�|jjS)zK
        Whether or not the test runner should stop running tests.
        )r�r�rJs rr�zSubunitReporter.shouldStops��
�}�}�'�'�'rc�6�|jj�S)zH
        Signal that the test runner should stop running tests.
        )r��stoprJs rr�zSubunitReporter.stops���}�}�!�!�#�#rc��|jS)z�
        Has the test run been successful so far?

        @return: C{True} if we have received no reports of errors or failures,
            C{False} otherwise.
        )r�rJs rrszSubunitReporter.wasSuccessfuls�����rc�8�|jj|�S)z2
        Record that C{test} has started.
        )r�rYrps  rrYzSubunitReporter.startTest's���}�}�&�&�t�,�,rc�8�|jj|�S)z4
        Record that C{test} has completed.
        )r�r]rps  rr]zSubunitReporter.stopTest-s���}�}�%�%�d�+�+rc�8�|jj|�S)z5
        Record that C{test} was successful.
        )r�rqrps  rrqzSubunitReporter.addSuccess3s���}�}�'�'��-�-rc��t|jdd�}|�|j|�y|jj||�y)a�
        Record that C{test} was skipped for C{reason}.

        Some versions of subunit don't have support for addSkip. In those
        cases, the skip is reported as a success.

        @param test: A unittest-compatible C{TestCase}.
        @param reason: The reason for it being skipped. The C{str()} of this
            object will be included in the subunit output stream.
        rgN)r0r�rqrg)r-r[rfrgs    rrgzSubunitReporter.addSkip9s;���$�-�-��D�9���?��O�O�D�!��M�M�!�!�$��/rc�n�d|_|jj|tj|��S)z�
        Record that C{test} failed with an unexpected error C{err}.

        Also marks the run as being unsuccessful, causing
        L{SubunitReporter.wasSuccessful} to return C{False}.
        F)r�r�rdr�excInfoOrFailureToExcInfo�r-r[�errs   rrdzSubunitReporter.addErrorJs.��!����}�}�%�%�d�D�,J�,J�3�,O�P�Prc�n�d|_|jj|tj|��S)z�
        Record that C{test} failed an assertion with the error C{err}.

        Also marks the run as being unsuccessful, causing
        L{SubunitReporter.wasSuccessful} to return C{False}.
        F)r�r�rarr�r�s   rrazSubunitReporter.addFailureTs.��!����}�}�'�'��d�.L�.L�S�.Q�R�Rrc��tj|�}t|jdd�}|�|j	|�y|||�y)z�
        Record an expected failure from a test.

        Some versions of subunit do not implement this. For those versions, we
        record a success.
        rnN)rr�r0r�rq)r-r[r�rkrns     rrnz"SubunitReporter.addExpectedFailure^sD���0�0��9��$�T�]�]�4H�$�O���%��O�O�D�!��t�W�-rc�&�|j|�y)z�
        Record an unexpected success.

        Since subunit has no way of expressing this concept, we record a
        success on the subunit stream.
        N)rqrjs   rrlz$SubunitReporter.addUnexpectedSuccessls��	
����rr+)r#r$r%r&rFr&r'r.ru�propertyr�r�rsrYr]rqrgrdrarnrlr'rrr�r��so��	��H��Z�Z�)�e�t� �(
��(��(�$�
 �-�,�.�0�"Q�S�.�rr�c����eZdZdZdZdZdZdZdZdZ	dZ
dZdZe
jf�fd�	Zd	�Z�fd
�Z�fd�Z�fd�Z�fd
�Z�fd�Z�fd�Z�fd�Zd�Zd�Z�fd�Z�fd�Z�fd�Z�fd�Zd�Z�xZS)�TreeReporterz�
    Print out the tests in the form a tree.

    Tests are indented according to which class and module they belong.
    Results are printed in ANSI color.
    r�z  �Orcrfrdc���t�|�|g|��i|��g|_ttt
fD]"}|j
|�s�||�|_yyr+)rAr.�	_lastTestr�rYr�rw�
_colorizer)r-r�r�r��	colorizerrCs     �rr.zTreeReporter.__init__�sT���
����1�$�1�&�1����)�>�>�J�	�I��"�"�6�*�"+�F�"3����	rc�F�|j�jd�dS)z�
        Return the name of the method which 'test' represents.  This is
        what gets displayed in the leaves of the tree.

        e.g. getDescription(TestCase('test_foo')) ==> test_foo
        r�r�)rr�rps  r�getDescriptionzTreeReporter.getDescription�s���w�w�y���s�#�B�'�'rc�\��t�|�|�|jd|j�yrJ)rArq�endLine�SUCCESSrZs  �rrqzTreeReporter.addSuccess�s"���
���4� ����V�T�\�\�*rc�V��t�|�|�|jd|j�yrL)rArdr��ERRORr8s  �rrdzTreeReporter.addError�s"���
���$�����Y��
�
�+rc�V��t�|�|�|jd|j�y)Nr)rArar��FAILUREr8s  �rrazTreeReporter.addFailure�s"���
���D�!����X�t�|�|�,rc�V��t�|�|�|jd|j�yrO)rArgr��SKIPr8s  �rrgzTreeReporter.addSkip�s!���
��������[�$�)�)�,rc�V��t�|�|�|jd|j�yrQ)rArnr��TODOr8s  �rrnzTreeReporter.addExpectedFailure�s"���
��"�D�)����X�t�y�y�)rc�V��t�|�|�|jd|j�yrS)rArlr��TODONEr8s  �rrlz!TreeReporter.addUnexpectedSuccess�s"���
��$�d�+����^�T�[�[�1rc�T��|r||z}||_t�|�	|j�yr+)�currentLinerAr�)r-r�r�rCs   �rr�zTreeReporter._write�s)�����d�]�F�!���
���t�'�'�(rc���|jd�dd}t|�dk(r|Sdj|dd�|dfD�cgc]}t|�dkDs�|��}}|Scc}w)z�
        Return a list of all non-leaf segments to display in the tree.

        Normally this is the module and class name.
        r�Nr�r)r�rGr	)r-�testID�segments�segs    r�_getPreludeSegmentsz TreeReporter._getPreludeSegments�ss���<�<��$�S�b�)���x�=�A���O��H�H�X�c�r�]�3�X�b�\�B�
��c�#�h�QR�l�C�
��
����
s�A�Ac�2�|j|�}d}|D]x}|t|j�kr6||j|k7rG|j|j|z�|�d��n#|j|j|z�|�d��|dz
}�z||_y)z�
        Write the name of the test to the stream, indenting it appropriately.

        If the test is the first test in a new 'branch' of the tree, also
        write all of the parents in that branch.
        rr�rN)r�rGr�r��indent)r-r�r��indentLevelr�s     r�_testPreludezTreeReporter._testPrelude�s����+�+�F�3�����	�C��S����0�0��$�.�.��5�5��K�K�4�;�;��#<�"=�c�U�"� E�F����t�{�{�[�8�9�#��b�A�B��1��K�
	�"��rc���|jjd|j�|jd|j�t�|�|�y)Nz    cleanup errorsr)r�r4r�r�rAr�r�s  �rr�zTreeReporter.cleanupErrors�s;��������2�D�J�J�?����Y��
�
�+�
���d�#rc���|jjd|z|j�|r|jd|j�t�|�||||�y)Nz  %sr)r�r4r�r�rAr�)r-r�rUr�r�rCs     �rr�zTreeReporter.upDownError�sG��������f�v�o�t�z�z�:���L�L��D�J�J�/�
���F�E�4��=rc����|j|j��|j|jt	|j
�z�|j
|��d��t�|�!|�y)zn
        Called when C{test} starts. Writes the tests name to the stream using
        a tree format.
        z ... N)	r�rr�r�rGr�r�rArYrZs  �rrYzTreeReporter.startTest�s\���
	
���$�'�'�)�$�����{�{�c�$�.�.�1�2�D�4G�4G��4M�
O�	
�	���$�rc����d|jt|j�z
t|�z
z}t�|�|�|j
j
||�t�|�d�y)z�
        Print 'message' in the given color.

        @param message: A string message, usually '[OK]' or something similar.
        @param color: A string color, 'red', 'green' and so forth.
        r,r�N)�columnsrGr�rAr�r�r4)r-�messager|�spacesrCs    �rr�zTreeReporter.endLine�sX�������s�4�+;�+;�'<�<�s�7�|�K�L��
���v�������g�u�-�
���t�rc���|j�}|j�rd}|j}nd}|j}|jj||�|j
d|�y)zo
        Print a line summarising the test results to the stream, and color the
        status result.
        rr rN)rrsr�r�r�r4r�)r-rr!r|s    rr"zTreeReporter._printSummary�s\��
�"�"�$�������F��L�L�E��F��L�L�E������f�e�,����F�G�$r) r#r$r%r&r�r�r�r�r�r�r�r�r�r&r'r.r�rqrdrargrnrlr�r�r�r�r�rYr�r"rzr{s@rr�r�ws������K�
�F��G��G��E��D��D�
�F��G�!�j�j��(�+�,�-�-�*�2�)��"�$$�
>�
 �
�
%rr�)rrxrwz'Todo')Ar&�
__future__rr�r&rM�unittest�pyunitr��collectionsr�typesr�typingrrrr	r
r�zope.interfacerr
�twisted.pythonrr�twisted.python.componentsr�twisted.python.failurer�twisted.python.utilr�
twisted.trialrrr�r�subunitrrurtrry�XUnitFailure�TrialFailurer�Warningr!r)�	IReporterr8r}r�r�r�r�r)r2rFrVrYr�r�r�r�r'rr�<module>r�s>���#�	�
����#��D�D�&��'�7�*�.�&����*��4�
�.�
�}�L�M���M��W�e�$4�5�5�6���\�7�*�+���"�G��
=�
=� 
�V�
�
��f��"�"�f��f�R
�V�
�
����f�&�&�(;�<����
�V�
�
��9�%8�9��9�$
�V�
�
��B�&�B��B�OG�*�OG�d
�V�
�
��e�z�e��e�P-�h�-�D�8��>(�(�(�V7�,�7�/;�/;�d;J�;J�|
 �
 � 
�V�
�
��Q�Q��Q�hR%�8�R%��g"�����s�1G,�,G7�6G7

Zerion Mini Shell 1.0