AlkantarClanX12

Your IP : 18.117.159.65


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/__pycache__/ddt.cpython-311.pyc

�

�܋f�1��x�ddlZddlZddlZddlZddlZddlmZmZddlm	Z		ddl
Z
dZn
#e$rdZYnwxYwdZ
dZdZd	Zd
ZdZ	ed��eeeefZn#e$red��eeeefZYnwxYweGd�d
e����Zd�Zd�Zd�Zdd�Zdd�Z ddej!fd�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(dd�Z)dS)�N)�Enum�unique)�wrapsTFz1.4.4z%valuesz
%file_pathz%yaml_loaderz%unpackz
%index_lenc��eZdZdZdZdZdS)�TestNameFormata�
    An enum to configure how ``mk_test_name()`` to compose a test name.  Given
    the following example:

    .. code-block:: python

        @data("a", "b")
        def testSomething(self, value):
            ...

    if using just ``@ddt`` or together with ``DEFAULT``:

    * ``testSomething_1_a``
    * ``testSomething_2_b``

    if using ``INDEX_ONLY``:

    * ``testSomething_1``
    * ``testSomething_2``

    r�N)�__name__�
__module__�__qualname__�__doc__�DEFAULT�
INDEX_ONLY���T/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/ddt.pyrr*s$��������*�G��J�J�Jrrc��t|t��rdSt|ttf��r"t	tt|����SdS)NTF)�
isinstance�
trivial_types�list�tuple�all�map�
is_trivial)�values rrrEsL���%��'�'�+��t�	�E�D�%�=�	)�	)�+��3�z�5�)�)�*�*�*��5rc�2�t|td��|S)z2
    Method decorator to add unpack feature.

    T)�setattr�UNPACK_ATTR)�funcs r�unpackrMs��
�D�+�t�$�$�$��Krc� �t|��S)z
    Method decorator to add to your test methods.

    Should be added to methods of instances of ``unittest.TestCase``.

    )�idata)�valuess r�datar#Vs����=�=�rc������8t����ttt����������fd�}|S)a�
    Method decorator to add to your test methods.

    Should be added to methods of instances of ``unittest.TestCase``.

    :param iterable: iterable of the values to provide to the test function.
    :param index_len: an optional integer specifying the width to zero-pad the
        test identifier indices to.  If not provided, this will add the fewest
        zeros necessary to make all identifiers the same length.
    Nc�`��t|t���t|t���|S�N)r�	DATA_ATTR�	INDEX_LEN)r�	index_len�iterables ��r�wrapperzidata.<locals>.wrapperps,�����i��*�*�*���i��+�+�+��r)r�len�str)r*r)r+s`` rr!r!`sW��������?�?����C��M�M�*�*�+�+�	�������
�Nrc������fd�}|S)a�
    Method decorator to add to your test methods.

    Should be added to methods of instances of ``unittest.TestCase``.

    ``value`` should be a path relative to the directory of the file
    containing the decorated ``unittest.TestCase``. The file
    should contain JSON encoded data, that can either be a list or a
    dict.

    In case of a list, each value in the list will correspond to one
    test case, and the value will be concatenated to the test method
    name.

    In case of a dict, keys will be used as suffixes to the name of the
    test case, and values will be fed as test data.

    ``yaml_loader`` can be used to customize yaml deserialization.
    The default is ``None``, which results in using the ``yaml.safe_load``
    method.
    c�d��t|t����rt|t���|Sr&)r�	FILE_ATTR�YAML_LOADER_ATTR)rr�yaml_loaders ��rr+zfile_data.<locals>.wrapper�s5�����i��'�'�'��	9��D�*�K�8�8�8��rr)rr2r+s`` r�	file_datar3xs)����,������
�Nr�c�b�d�|dz|��}|tjust|��sd�||��S	t	|��}n&#t
$r|�dd��}YnwxYwd�|||��}tjdd|��S)	a
    Generate a new name for a test case.

    It will take the original test name and append an ordinal index and a
    string representation of the value, and convert the result into a valid
    python identifier by replacing extraneous characters with ``_``.

    We avoid doing str(value) if dealing with non-trivial values.
    The problem is possible different names with different runs, e.g.
    different order of dictionary keys (see PYTHONHASHSEED) or dealing
    with mock objects.
    Trivial scalar values are passed as is.

    A "trivial" value is a plain scalar, or a tuple or list consisting
    only of trivial values.

    The test name format is controlled by enum ``TestNameFormat`` as well. See
    the enum documentation for further details.
    z{0:0{1}}rz{0}_{1}�ascii�backslashreplacez{0}_{1}_{2}z
\W|^(?=\d)�_)	�formatrrrr-�UnicodeEncodeError�encode�re�sub)�namer�indexr)�name_fmt�	test_names      r�mk_test_namerB�s���,
���e�a�i��3�3�E��>�,�,�,�J�u�4E�4E�,�����e�,�,�,�:��E�
�
�����:�:�:����W�&8�9�9����:�����$�$�T�5�%�8�8�I�
�6�-��i�0�0�0s�A� B�Bc������t������fd���}||_�|_|�||_n7�jr0	�jj�i���|_n#t
tf$rYnwxYw|S)zO
    This internal method decorator feeds the test data item to the test.

    c����|g��Ri���Sr&r)�self�argsr�kwargss ���rr+zfeed_data.<locals>.wrapper�s#����t�D�*�4�*�*�*�6�*�*�*r)rr	�__wrapped__rr9�
IndexError�KeyError)r�new_name�test_data_docstringrFrGr+s`  `` r�	feed_datarM�s������
�4�[�[�+�+�+�+�+�+��[�+��G���G���&�-�����<�	�
�"5�$�,�"5�t�"F�v�"F�"F�������)�
�
�
�
��
�����Ns�A�A,�+A,c	�H�t||t|||g|�Ri|����dS)z~
    Add a test case to this class.

    The test will be based on an existing function but will give it a new
    name.

    N)rrM)�clsrA�test_docstringrrFrGs      r�add_testrQ�sP���C��I�d�I�~��
�����������rc���tj�tj|����}tj�tj�|�����}�fd�}tj�|��s0t|d��}d}t||||d��d��dS|�
d��}	|	r7ts0t|d��}d}t||||d��d��dStj
|dd	��5}
|	rVt|t��r,t!|t��}t#j|
|�
��}n)t#j|
��}nt)j|
��}ddd��n#1swxYwYt+||||��dS)z=
    Process the parameter in the `file_data` decorator.
    c������fd�}|S)Nc�(��t��z���r&)�
ValueError)rF�	file_attr�messages ��rrz:process_file_data.<locals>.create_error_func.<locals>.func�s����W�y�0�1�1�1rr)rWrrVs` �r�create_error_funcz,process_file_data.<locals>.create_error_func�s'����	2�	2�	2�	2�	2�	2��r�errorzError!z%s does not existN)z.ymlz.yamlz(%s is a YAML file, please install PyYAML�rzutf-8)�Loader)�os�path�abspath�inspect�
getsourcefile�join�dirname�existsrBrQ�endswith�
_have_yaml�codecs�open�hasattrr1�getattr�yaml�load�	safe_load�json�_add_tests_from_data)
rOr>rrV�cls_path�data_file_pathrXrArP�
_is_yaml_file�fr2r#s
   `         r�process_file_datars�s����w���w�4�S�9�9�:�:�H��W�\�\�"�'�/�/�(�";�";�Y�G�G�N�������7�>�>�.�)�)�� ��w�/�/�	�%����i��"�"�#6�7�7��	?�	?�	?���"�+�+�,=�>�>�M��
�Z�
� ��w�/�/�	�%��������H�I�I��	
�	
�	
�	��	��^�S�'�	2�	2�	 �a��	 ��t�-�.�.�
)�%�d�,<�=�=���y��;�7�7�7����~�a�(�(����9�Q�<�<�D�	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ���d�D�$�/�/�/�/�/s�(A-F!�!F%�(F%c��ttt|������}t|��D]�\}}t|t��r|||}}t||||��}	n)t|t��r|}t||||��}	t|t��rt||	|	|fi|����t||	|	||����dS)zF
    Add tests from data loaded from the data file into the class
    N)r,r-�	enumerater�dictrBrrQ)
rOr>rr#r)�i�elem�keyrrAs
          rrnrns����C��D�	�	�N�N�#�#�I��T�?�?�
=�
=���4��d�D�!�!�	@��t�D�z��C�$�T�3��9�=�=�I�I�
��d�
#�
#�	@��E�$�T�5�!�Y�?�?�I��e�T�"�"�	=��S�)�Y��>�>��>�>�>�>��S�)�Y��e�<�<�<�<�
=�
=rc�$�t|d��S)zNFinds out if the obj is a "primitive". It is somewhat hacky but it works.
    �__dict__)rh)�objs r�
_is_primitiver}"s���s�J�'�'�'�'rc�@�t|��s|jr|jSdS)z�Returns a docstring based on the following resolution strategy:
    1. Passed value is not a "primitive" and has a docstring, then use it.
    2. In all other cases return None, i.e the test name is used.
    N)r}r)rrs  r�_get_test_data_docstringr(s*��
�����E�M���}���trc���|�dtj����fd�}tj|��r||��n|S)a
    Class decorator for subclasses of ``unittest.TestCase``.

    Apply this decorator to the test case class, and then
    decorate test methods with ``@data``.

    For each method decorated with ``@data``, this will effectively create as
    many methods as data items are passed as parameters to ``@data``.

    The names of the test methods follow the pattern
    ``original_test_name_{ordinal}_{data}``. ``ordinal`` is the position of the
    data argument, starting with 1.

    For data we use a string representation of the data value converted into a
    valid python identifier.  If ``data.__name__`` exists, we use that instead.

    For each method decorated with ``@file_data('test_data.json')``, the
    decorator will try to load the test_data.json file located relative
    to the python file containing the method that is decorated. It will,
    for each ``test_name`` key create as many methods in the list of values
    from the ``data`` key.

    Decorating with the keyword argument ``testNameFormat`` can control the
    format of the generated test names.  For example:

    - ``@ddt(testNameFormat=TestNameFormat.DEFAULT)`` will be index and values.

    - ``@ddt(testNameFormat=TestNameFormat.INDEX_ONLY)`` will be index only.

    - ``@ddt`` is the same as DEFAULT.

    �testNameFormatc
���t|j�����D�]\\}}t|t��r�t|t��}tt|t����D]�\}}t|t|d|��||�	��}t||��}t|t��rLt|t��st|t��rt||||g|�R���t||||fi|����t|||||����t||����t|t��r7t|t��}t!||||��t||����^|S)Nr	)rr{�itemsrhr'rir(rurBrrrrrQ�delattrr0rs)
rOr>rr)rw�vrArLrV�
fmt_test_names
         �rr+zddt.<locals>.wrapperVs�����s�|�1�1�3�3�4�4�$	#�$	#�J�D�$��t�Y�'�'�#
#�#�D�)�4�4�	�%�g�d�I�&>�&>�?�?�O�O�D�A�q� ,����:�q�1�1��!�%�!�!�I�+C�4��*K�*K�'��t�[�1�1�O�%�a��/�/��:�a��3F�3F��$� #� )� 3� $�	�
"#������%� #� )� 3� $�	��
#$�����!��i�1D�d�A�N�N�N�N���T�"�"�"�"���y�)�)�
#�#�D�)�4�4�	�!�#�t�T�9�=�=�=���T�"�"�"���
r)�getrr
r_�isclass)�argrGr+r�s   @r�ddtr�3sZ���B�J�J�/��1G�H�H�M�&�&�&�&�&�T#�?�3�/�/�<�7�7�3�<�<�<�W�<rr&)*rfr_rmr\r<�enumrr�	functoolsrrjre�ImportError�__version__r'r0r1rr(�type�bool�int�float�
basestringr�	NameErrorr-rrrr#r!r3r
rBrMrQrsrnr}rr�rrr�<module>r�s?���
�
�
���������	�	�	�	�	�	�	�	�����������������K�K�K��J�J�������J�J�J�����
��
�	��	�!�����	�8��T�$�Z�Z��s�E�:�>�M�M���8�8�8��T�$�Z�Z��s�E�3�7�M�M�M�8����������T������4�������������0����<%&��^�=S�1�1�1�1�D���6	�	�	�.0�.0�.0�b=�=�=�$(�(�(����M=�M=�M=�M=�M=�M=s�+�5�5�A�A.�-A.