%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/markdown/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/markdown/__pycache__/test_tools.cpython-312.pyc

�

���e�!���dZddlmZddlZddlZddlZddlZddlmZddl	m
Z
mZmZ	ddl
Z
gd�ZGd�d	ej �ZGd
�d�ZGd�d
e�Zd�ZGd�de�ZGd�dej e��Zy#e$rdZ
Y�]wxYw)zJ A collection of tools for testing the Markdown code base and extensions. �)�annotationsN)�Any�)�markdown�Markdown�util)�TestCase�LegacyTestCase�Kwargsc�0�eZdZUdZiZded<	dd�Zd�Zy)r	a�
    A [`unittest.TestCase`][] subclass with helpers for testing Markdown output.

    Define `default_kwargs` as a `dict` of keywords to pass to Markdown for each
    test. The defaults can be overridden on individual tests.

    The `assertMarkdownRenders` method accepts the source text, the expected
    output, and any keywords to pass to Markdown. The `default_kwargs` are used
    except where overridden by `kwargs`. The output and expected output are passed
    to `TestCase.assertMultiLineEqual`. An `AssertionError` is raised with a diff
    if the actual output does not equal the expected output.

    The `dedent` method is available to dedent triple-quoted strings if
    necessary.

    In all other respects, behaves as `unittest.TestCase`.
    zdict[str, Any]�default_kwargsNc�*�|xsi}|jj�}|j|�tdi|��}|j	|�}|j||�|j
�D]!\}}	|jt||�|	��#y)a�
        Test that source Markdown text renders to expected output with given keywords.

        `expected_attrs` accepts a `dict`. Each key should be the name of an attribute
        on the `Markdown` instance and the value should be the expected value after
        the source text is parsed by Markdown. After the expected output is tested,
        the expected value for each attribute is compared against the actual
        attribute of the `Markdown` instance using `TestCase.assertEqual`.
        N�)	r
�copy�updater�convert�assertMultiLineEqual�items�assertEqual�getattr)
�self�source�expected�expected_attrs�kwargs�kws�md�output�key�values
          �5/usr/lib/python3/dist-packages/markdown/test_tools.py�assertMarkdownRenderszTestCase.assertMarkdownRenders=s���(�-�2���!�!�&�&�(���
�
�6��
�_��_�����F�#���!�!�&�(�3�(�.�.�0�	6�J�C�����W�R��-�u�5�	6�c�H�tj|�j�S)z
        Dedent text.
        )�textwrap�dedent�strip)r�texts  r!r&zTestCase.dedentQs�����t�$�*�*�,�,r#�N)�__name__�
__module__�__qualname__�__doc__r
�__annotations__r"r&rr#r!r	r	's ���$&(�N�N�'�>�6�(-r#r	c�"�eZdZdZd�Zd�Zd�Zy)�recursionlimita�
    A context manager which temporarily modifies the Python recursion limit.

    The testing framework, coverage, etc. may add an arbitrary number of levels to the depth. To maintain consistency
    in the tests, the current stack depth is determined when called, then added to the provided limit.

    Example usage:

    ``` python
    with recursionlimit(20):
        # test code here
    ```

    See <https://stackoverflow.com/a/50120316/866026>.
    c�n�tj�|z|_tj�|_yr))r�_get_stack_depth�limit�sys�getrecursionlimit�	old_limit)rr3s  r!�__init__zrecursionlimit.__init__ls'���*�*�,�u�4��
��.�.�0��r#c�B�tj|j�yr))r4�setrecursionlimitr3)rs r!�	__enter__zrecursionlimit.__enter__ps�����d�j�j�)r#c�B�tj|j�yr))r4r9r6)r�typer �tbs    r!�__exit__zrecursionlimit.__exit__ss�����d�n�n�-r#N)r*r+r,r-r7r:r>rr#r!r0r0[s��� 1�*�.r#r0c��eZdZdZy)rz4 A `dict` like class for holding keyword arguments. N�r*r+r,r-rr#r!rr|s��>�r#rc�P�tj|ddddddddddd�
��\}}|S)z< Normalize whitespace for a string of HTML using `tidylib`. rr�LF)
�drop_empty_paras�
fix_backslash�fix_bad_comments�fix_uri�join_styles�lower_literals�
merge_divs�output_xhtml�quote_ampersand�newline)�options)�tidylib�
tidy_fragment)r(r�errorss   r!�_normalize_whitespacerQ�sB���*�*�4�����������:��N�F�F��Mr#c��eZdZd�Zy)�LegacyTestMetac��d�}|jdd�}|jdg�}|jdd�}|jdd�}|jd	d
�}	|jdt��}
tjj	|��r(tj
|�D�]}tjj
||�}tjj|�s�Dtjj|�\}
}||k(s�ltjj
||
|	z�}|
jdd
�jdd
�}
|
j�}|
|vr|j||
�d|
z}|
|vr|||||�||<��tjd�d��||<��tj||||�S)Nc����������fd�}|S)Nc����t�d��5}|j�}ddd�t�d��5}|j�jdd�}ddd�tfi���}tr�r	t�}t|�}n�r|jd�|j|�y#1swY��xYw#1swY�gxYw#t$r|jd�Y�GwxYw)Nzutf-8)�encodingz
�
z"Tidylib's c library not available.zTidylib not available.)	�open�read�replacerrNrQ�OSError�skipTestr)	r�f�inputrr�infiler�	normalize�outfiles	     ����r!�testz;LegacyTestMeta.__new__.<locals>.generate_test.<locals>.test�s�����&�7�3�%�q��F�F�H�E�%��'�G�4�>�� !�v�v�x�/�/���=�H�>�"�%�2�6�2���y�L�#8��#B��!6�v�!>����M�M�":�;��)�)�&�(�;�%�%��>�>��#�L��
�
�&J�K�L�s(�B0�!B<�3C�0B9�<C�C%�$C%r)r`rbrarrcs```` r!�
generate_testz-LegacyTestMeta.__new__.<locals>.generate_test�s���
<�"�Kr#�location��excluderaF�	input_extz.txt�
output_extz.htmlr
� �_�-ztest_%s�Excludedc��yr)rrr#r!�<lambda>z(LegacyTestMeta.__new__.<locals>.<lambda>�s�r#)�getr�os�path�isdir�listdir�join�isfile�splitextr[rr�unittest�skipr<�__new__)�cls�name�bases�dctrdrergrarhrir�filer`�tname�extrbr�	test_names                  r!rzzLegacyTestMeta.__new__�s���	�(�7�7�:�r�*���'�'�)�R�(���G�G�K��/�	��G�G�K��0�	��W�W�\�7�3�
����)�6�8�4��
�7�7�=�=��"��
�
�8�,�
U�������h��5���7�7�>�>�&�)�!#���!1�!1�$�!7�J�E�3��i�'�"$�'�'�,�,�x���9K�"L�� %�
�
�c�3� 7� ?� ?��S� I��$�k�k�m�� �C�<��J�J�s�5�z�2�$-��$5�	� ��/�-:�6�7�I�WZ�-[�C�	�N�-F�X�]�]�:�-F�|�-T�C�	�N�
U� �|�|�C��u�c�2�2r#N)r*r+r,rzrr#r!rSrS�s��.3r#rSc��eZdZdZy)r
a�
    A [`unittest.TestCase`][] subclass for running Markdown's legacy file-based tests.

    A subclass should define various properties which point to a directory of
    text-based test files and define various behaviors/defaults for those tests.
    The following properties are supported:

    Attributes:
        location (str): A path to the directory of test files. An absolute path is preferred.
        exclude (list[str]): A list of tests to exclude. Each test name should comprise the filename
            without an extension.
        normalize (bool): A boolean value indicating if the HTML should be normalized. Default: `False`.
        input_ext (str): A string containing the file extension of input files. Default: `.txt`.
        output_ext (str): A string containing the file extension of expected output files. Default: `html`.
        default_kwargs (Kwargs[str, Any]): The default set of keyword arguments for all test files in the directory.

    In addition, properties can be defined for each individual set of test files within
    the directory. The property should be given the name of the file without the file
    extension. Any spaces and dashes in the filename should be replaced with
    underscores. The value of the property should be a `Kwargs` instance which
    contains the keyword arguments that should be passed to `Markdown` for that
    test file. The keyword arguments will "update" the `default_kwargs`.

    When the class instance is created, it will walk the given directory and create
    a separate `Unitttest` for each set of test files using the naming scheme:
    `test_filename`. One `Unittest` will be run for each set of input and output files.
    Nr@rr#r!r
r
�s���6	r#r
)�	metaclass)r-�
__future__rrqr4rxr%�typingrrfrrrrN�ImportError�__all__r	r0�dictrrQr<rSr
rr#r!�<module>r�s���(Q�"�	�
����&�&���3��1-�x� � �1-�h.�.�B	�T�	�
�"/3�T�/3�d	�X�&�&�.�	��G���G��s�B�B�B

Zerion Mini Shell 1.0