$45 GRAYBYTE WORDPRESS FILE MANAGER $31

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.216.174
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/hc_python/lib/python3.12/site-packages/nose/plugins/__pycache__/

HOME
Current File : /opt/hc_python/lib/python3.12/site-packages/nose/plugins/__pycache__//errorclass.cpython-312.pyc
�

H��gk����dZddlmZddlmZddlmZddlmZGd�de	�Z
Gd�d	e�ZGd
�dee
��Z
d
�Zd�Zd�Zd�Zd�Zedk(rddlZej*�yy)a�
ErrorClass Plugins
------------------

ErrorClass plugins provide an easy way to add support for custom
handling of particular classes of exceptions.

An ErrorClass plugin defines one or more ErrorClasses and how each is
handled and reported on. Each error class is stored in a different
attribute on the result, and reported separately. Each error class must
indicate the exceptions that fall under that class, the label to use
for reporting, and whether exceptions of the class should be
considered as failures for the whole test run.

ErrorClasses use a declarative syntax. Assign an ErrorClass to the
attribute you wish to add to the result object, defining the
exceptions, label and isfailure attributes. For example, to declare an
ErrorClassPlugin that defines TodoErrors (and subclasses of TodoError)
as an error class with the label 'TODO' that is considered a failure,
do this:

    >>> class Todo(Exception):
    ...     pass
    >>> class TodoError(ErrorClassPlugin):
    ...     todo = ErrorClass(Todo, label='TODO', isfailure=True)

The MetaErrorClass metaclass translates the ErrorClass declarations
into the tuples used by the error handling and reporting functions in
the result. This is an internal format and subject to change; you
should always use the declarative syntax for attaching ErrorClasses to
an ErrorClass plugin.

    >>> TodoError.errorClasses # doctest: +ELLIPSIS
    ((<class ...Todo...>, ('todo', 'TODO', True)),)

Let's see the plugin in action. First some boilerplate.

    >>> import sys
    >>> import unittest
    >>> try:
    ...     # 2.7+
    ...     from unittest.runner import _WritelnDecorator
    ... except ImportError:
    ...     from unittest import _WritelnDecorator
    ... 
    >>> buf = _WritelnDecorator(sys.stdout)

Now define a test case that raises a Todo.

    >>> class TestTodo(unittest.TestCase):
    ...     def runTest(self):
    ...         raise Todo("I need to test something")
    >>> case = TestTodo()

Prepare the result using our plugin. Normally this happens during the
course of test execution within nose -- you won't be doing this
yourself. For the purposes of this testing document, I'm stepping
through the internal process of nose so you can see what happens at
each step.

    >>> plugin = TodoError()
    >>> from nose.result import _TextTestResult
    >>> result = _TextTestResult(stream=buf, descriptions=0, verbosity=2)
    >>> plugin.prepareTestResult(result)

Now run the test. TODO is printed.

    >>> _ = case(result) # doctest: +ELLIPSIS
    runTest (....TestTodo) ... TODO: I need to test something

Errors and failures are empty, but todo has our test:

    >>> result.errors
    []
    >>> result.failures
    []
    >>> result.todo # doctest: +ELLIPSIS
    [(<....TestTodo testMethod=runTest>, '...Todo: I need to test something\n')]
    >>> result.printErrors() # doctest: +ELLIPSIS
    <BLANKLINE>
    ======================================================================
    TODO: runTest (....TestTodo)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
    ...
    ...Todo: I need to test something
    <BLANKLINE>

Since we defined a Todo as a failure, the run was not successful.

    >>> result.wasSuccessful()
    False
�)�make_instancemethod)�Plugin)�TextTestResult)�isclassc�"��eZdZdZ�fd�Z�xZS)�MetaErrorClasszhMetaclass for ErrorClassPlugins that allows error classes to be
    set up in a declarative manner.
    c�<��g}t|j��D]X\}}t|t�s�|j	|�|D],}|j|||j|jff��.�Ztt|�+|||�t|�|_y�N)
�list�items�
isinstance�
ErrorClass�pop�append�label�	isfailure�superr�__init__�tuple�errorClasses)�self�name�bases�attrr�detail�cls�	__class__s       ��F/opt/hc_python/lib/python3.12/site-packages/nose/plugins/errorclass.pyrzMetaErrorClass.__init__hs������ �����.�L�D�&��&�*�-������!�C� �'�'��t�V�\�\�6�3C�3C�D�E�G�"�/�	�n�d�,�T�5�$�?�!�,�/���)�__name__�
__module__�__qualname__�__doc__r�
__classcell__)rs@rrrds����	0�	0rrc��eZdZd�Zd�Zy)rc��||_	dD]}t|||j|��� y#t$rt	dz��wxYw)N)rrz.%r is a required named argument for ErrorClass)r�setattrr�KeyError�	TypeError)rr�kw�keys    rrzErrorClass.__init__usT��(���	#�-����c�2�6�6�#�;�/�.���	#��L�!�"�#�
#�	#�s	�#-�Ac�,�t|j�Sr
)�iterr)rs r�__iter__zErrorClass.__iter__~s���D�%�%�&�&rN)r r!r"rr.�rrrrts��#�'rrc�*�eZdZdZdZdZd�Zd�Zd�Zy)�ErrorClassPluginz�
    Base class for ErrorClass plugins. Subclass this class and declare the
    exceptions that you wish to handle as attributes of the subclass.
    i�r/c��|\}}}t|�sy|jD�cgc]}|d��	}}|D�cgc]}t||�s�|��c}ryycc}wcc}w)NrT)rr�
issubclass)	r�test�err�err_cls�a�b�e�classes�cs	         r�addErrorzErrorClassPlugin.addError�sc���
���A��w���!%�!2�!2�3�!2�A�1�Q�4�!2��3��9�w�!�*�W�a�"8�A�w�9��:��4��9s�A�A�Ac���t|d�s|j|�|jD]D\}\}}}||jvs�t||g�}t	|||�|||f|j|<�Fy)Nr)�hasattr�patchResultr�getattrr')r�resultr�storage_attrr�isfail�storages       r�prepareTestResultz"ErrorClassPlugin.prepareTestResult�sv���v�~�.����V�$�26�2C�2C�.�C�.�,��v��&�-�-�-�!�&�,��;�����g�6�,3�U�F�+C��#�#�C�(�	3Drc�r�t|�|_|jt|�c|_|_|j
t
|�c|_|_t|d�r"|jt|�c|_|_	t|d�r"|jt|�c|_|_i|_y)N�printErrors�addSkip)�print_label_patch�
printLabelr<�add_error_patch�_orig_addError�
wasSuccessful�wassuccessful_patch�_orig_wasSuccessfulr>rG�print_errors_patch�_orig_printErrorsrH�add_skip_patch�
_orig_addSkipr)rrAs  rr?zErrorClassPlugin.patchResult�s���-�f�5����O�O�_�V�4�	/���v��
� � �"5�f�"=�	9��"�F�$8��6�=�)��"�"�$6�v�$>�
9�F�$�f�&8��6�9�%�����v� 6�
1�F� �&�.� ��rN)	r r!r"r#�scorerr<rEr?r/rrr1r1�s#���
�E��L��D�!rr1)�	metaclassc�6�ttj|�S)z�Create a new addError method to patch into a result instance
    that recognizes the errorClasses attribute and deals with
    errorclasses correctly.
    )rrr<�rAs rrKrK�s��
�~�6�6��?�?rc�6�ttj|�S)zPCreate a new printErrors method that prints errorClasses items
    as well.
    )rrrGrWs rrPrP�s���~�9�9�6�B�Brc�6�ttj|�S)zOCreate a new printLabel method that prints errorClasses items
    as well.
    )rrrJrWs rrIrI�s���~�8�8�&�A�Arc�6�ttj|�S)z�Create a new wasSuccessful method that checks errorClasses for
    exceptions that were put into other slots than error or failure
    but that still count as not success.
    )rrrMrWs rrNrN�s��
�~�;�;�V�D�Drc�6�ttj|�S)z`Create a new addSkip method to patch into a result instance
    that delegates to addError.
    )rrrHrWs rrRrR�s���~�5�5�v�>�>r�__main__N)r#�nose.pyversionr�nose.plugins.baser�nose.resultr�	nose.utilr�typer�objectrr1rKrPrIrNrRr �doctest�testmodr/rr�<module>res|��\�|/�$�&��
0�T�
0� '��'�%!�v��%!�P@�C�B�E�?��z����G�O�O��r


Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Apr 2025 8.03 AM
root / root
0755
__init__.cpython-312.pyc
6.404 KB
4 Apr 2025 8.03 AM
root / root
0644
allmodules.cpython-312.pyc
2.301 KB
4 Apr 2025 8.03 AM
root / root
0644
attrib.cpython-312.pyc
9.89 KB
4 Apr 2025 8.03 AM
root / root
0644
base.cpython-312.pyc
30.225 KB
4 Apr 2025 8.03 AM
root / root
0644
builtin.cpython-312.pyc
1.157 KB
4 Apr 2025 8.03 AM
root / root
0644
capture.cpython-312.pyc
5.098 KB
4 Apr 2025 8.03 AM
root / root
0644
collect.cpython-312.pyc
4.975 KB
4 Apr 2025 8.03 AM
root / root
0644
cover.cpython-312.pyc
13.917 KB
4 Apr 2025 8.03 AM
root / root
0644
debug.cpython-312.pyc
3.077 KB
4 Apr 2025 8.03 AM
root / root
0644
deprecated.cpython-312.pyc
2.106 KB
4 Apr 2025 8.03 AM
root / root
0644
doctests.cpython-312.pyc
21.004 KB
4 Apr 2025 8.03 AM
root / root
0644
errorclass.cpython-312.pyc
9.29 KB
4 Apr 2025 8.03 AM
root / root
0644
failuredetail.cpython-312.pyc
2.273 KB
4 Apr 2025 8.03 AM
root / root
0644
isolate.cpython-312.pyc
5.177 KB
4 Apr 2025 8.03 AM
root / root
0644
logcapture.cpython-312.pyc
12.53 KB
4 Apr 2025 8.03 AM
root / root
0644
manager.cpython-312.pyc
21.718 KB
4 Apr 2025 8.03 AM
root / root
0644
multiprocess.cpython-312.pyc
38.254 KB
4 Apr 2025 8.03 AM
root / root
0644
plugintest.cpython-312.pyc
17.021 KB
4 Apr 2025 8.03 AM
root / root
0644
prof.cpython-312.pyc
6.642 KB
4 Apr 2025 8.03 AM
root / root
0644
skip.cpython-312.pyc
2.459 KB
4 Apr 2025 8.03 AM
root / root
0644
testid.cpython-312.pyc
11.73 KB
4 Apr 2025 8.03 AM
root / root
0644
xunit.cpython-312.pyc
16.276 KB
4 Apr 2025 8.03 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF