HOME


Mini Shell 1.0
DIR: /snap/certbot/4482/lib/python3.12/site-packages/pyparsing/__pycache__/
Upload File :
Current File : //snap/certbot/4482/lib/python3.12/site-packages/pyparsing/__pycache__/testing.cpython-312.pyc
�

�S�gZ9��P�ddlmZddlZddlZddlmZmZmZmZm	Z	Gd�d�Z
y)�)�contextmanagerN�)�
ParserElement�ParseException�Keyword�__diag__�
__compat__c��eZdZdZGd�d�ZGd�d�Ze						dddd	�d
edeje
deje
d
ededejedejedejee
fdedefd��Z
y)�pyparsing_testzB
    namespace class for classes useful in writing unit tests
    c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�&pyparsing_test.reset_pyparsing_contexta�
        Context manager to be used when writing unit tests that modify pyparsing config values:
        - packrat parsing
        - bounded recursion parsing
        - default whitespace characters.
        - default keyword characters
        - literal string auto-conversion class
        - __diag__ settings

        Example::

            with reset_pyparsing_context():
                # test that literals used to construct a grammar are automatically suppressed
                ParserElement.inlineLiteralsUsing(Suppress)

                term = Word(alphas) | Word(nums)
                group = Group('(' + term[...] + ')')

                # assert that the '()' characters are not included in the parsed tokens
                self.assertParseAndCheckList(group, "(abc 123 def)", ['abc', '123', 'def'])

            # after exiting context manager, literals are converted to Literal expressions again
        c��i|_y�N)�
_save_context��selfs ��/build/snapcraft-certbot-29b1212f749eeba2f1dece1adfe9a83a/parts/certbot/install/lib/python3.12/site-packages/pyparsing/testing.py�__init__z/pyparsing_test.reset_pyparsing_context.__init__/s
��!#�D��c���tj|jd<tj|jd<tj
|jd<tj|jd<tj|jd<tjr(tjj|jd<nd|jd<tj|jd<tj|jd<tjD�cic]}|tt|���c}|jd	<d
tj i|jd<|Scc}w)N�default_whitespace�default_keyword_chars�literal_string_class�verbose_stacktrace�packrat_enabled�packrat_cache_size�
packrat_parse�recursion_enabledr�collect_all_And_tokensr	)r�DEFAULT_WHITE_CHARSrr�DEFAULT_KEYWORD_CHARS�_literalStringClassr�_packratEnabled�
packrat_cache�size�_parse�_left_recursion_enabledr�
_all_names�getattrr	r)r�names  r�savez+pyparsing_test.reset_pyparsing_context.save2sJ��7D�7X�7X�D���3�4�:A�:W�:W�D���6�7��1�1�
���5�6�8E�7W�7W�D���3�4�4A�4Q�4Q�D���0�1��,�,�!�/�/�4�4��"�"�#7�8�<@��"�"�#7�8�2?�2F�2F�D����/��5�5�
���2�3�
;C�:M�:M�.�26��g�h��-�-�.�D���z�*�
)�*�*K�*K�0�D���|�,��K��.s�%E.c���tj|jdk7r"tj|jd�|jdt_|jdt
_tj|jd�|jdj�D]-\}}|rtjntj|��/dt_|jdr#tj|jd�n|jd	t_|jd
t_|jdt _|S)NrrrrrFrrrrr	)rr r�set_default_whitespace_charsrrr!�inlineLiteralsUsing�itemsr�enable�disabler#�enable_packratr&r'r	r)rr*�values   r�restorez.pyparsing_test.reset_pyparsing_context.restoreRs@���1�1��%�%�&:�;�<��:�:��&�&�';�<��04�/A�/A�BV�/W�M�,�,0�,>�,>�?V�,W�G�)��-�-��"�"�#9�:�
� $�1�1�*�=�C�C�E�
G���e�?�E����x�/?�/?��F�
G�-2�M�)��!�!�"3�4��,�,�T�-?�-?�@T�-U�V�'+�'9�'9�/�'J�
�$�48�4F�4F�#�5�M�1�15�0B�0B�<�0P�J�-��Krc�p�t|��}|jj|j�|Sr)�typer�update)r�rets  r�copyz+pyparsing_test.reset_pyparsing_context.copyss.���$�t�*�,�C����$�$�T�%7�%7�8��Jrc�"�|j�Sr)r+rs r�	__enter__z0pyparsing_test.reset_pyparsing_context.__enter__xs���9�9�;�rc�$�|j�yr)r4)r�argss  r�__exit__z/pyparsing_test.reset_pyparsing_context.__exit__{s���L�L�NrN)
�__name__�
__module__�__qualname__�__doc__rr+r4r9r;r>�rr�reset_pyparsing_contextr
s'��	�0	$�	�@	�B	�
	�	rrDc�P�eZdZdZ	dd�Z	d	d�Z	d	d�Z	d
d�Zee	ddfd��Z
y)�&pyparsing_test.TestParseResultsAssertszk
        A mixin class to add parse results assertion methods to normal unittest.TestCase classes.
        Nc��|�"|j||j�|��|�#|j||j�|��yy)z�
            Unit test assertion to compare a :class:`ParseResults` object with an optional ``expected_list``,
            and compare any defined results names with an optional ``expected_dict``.
            N��msg)�assertEqual�as_list�as_dict)r�result�
expected_list�
expected_dictrIs     r�assertParseResultsEqualsz?pyparsing_test.TestParseResultsAsserts.assertParseResultsEquals�sM���(�� � �����0@�c� �J��(�� � �����0@�c� �J�)rc��|j|d��}|rt|j��nt|j��|j	|||��y)z�
            Convenience wrapper assert to test a parser element and input string, and assert that
            the resulting ``ParseResults.asList()`` is equal to the ``expected_list``.
            T)�	parse_all)rNrIN��parse_string�print�dumprKrP)r�expr�test_stringrNrI�verboserMs       r�assertParseAndCheckListz>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckList�sO���&�&�{�d�&�C�F���f�k�k�m�$��f�n�n�&�'��)�)�&�
�SV�)�Wrc��|j|d��}|rt|j��nt|j��|j	|||��y)z�
            Convenience wrapper assert to test a parser element and input string, and assert that
            the resulting ``ParseResults.asDict()`` is equal to the ``expected_dict``.
            T)�parseAll)rOrINrS)rrWrXrOrIrYrMs       r�assertParseAndCheckDictz>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckDict�sO���&�&�{�T�&�B�F���f�k�k�m�$��f�n�n�&�'��)�)�&�
�SV�)�Wrc�j�|\}}|�|j||�|��yd��yt||�D��cgc]\}}g|�|����}}}|D]�\}	}
}td�|D�d�}td�|D�d�}|�4|j||xs|��5t	|
t
�r|
�	ddd��ctd�|D�d�}
td�|D�d�}|
|fd	k7r|j
|
|
||xs|�
���td|	�����|j||�|��yd��ycc}}w#1swY��xYw)ah
            Unit test assertion to evaluate output of ``ParserElement.runTests()``. If a list of
            list-dict tuples is given as the ``expected_parse_results`` argument, then these are zipped
            with the report tuples returned by ``runTests`` and evaluated using ``assertParseResultsEquals``.
            Finally, asserts that the overall ``runTests()`` success value is ``True``.

            :param run_tests_report: tuple(bool, [tuple(str, ParseResults or Exception)]) returned from runTests
            :param expected_parse_results (optional): [tuple(str, list, dict, Exception)]
            Nzfailed runTestsrHc3�BK�|]}t|t�s�|���y�wr)�
isinstance�str��.0�exps  r�	<genexpr>zNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>�s���� Q��J�s�C�<P�� Q����c3�`K�|]&}t|t�rt|t�r|���(y�wr)r`r6�
issubclass�	Exceptionrbs  rrezNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>�s+������%�c�4�0�Z��Y�5O���s�,.)�expected_exceptionrIc3�BK�|]}t|t�s�|���y�wr)r`�listrbs  rrezNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>������J��J�s�D�4I��J�rfc3�BK�|]}t|t�s�|���y�wr)r`�dictrbs  rrezNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>�rmrf�NN)rNrOrIzno validation for )�
assertTrue�zip�next�assertRaisesr`rirPrU)r�run_tests_report�expected_parse_resultsrI�run_test_success�run_test_results�rpt�expected�mergedrXrM�fail_msgrjrNrOs               r�assertRunTestResultsz;pyparsing_test.TestParseResultsAsserts.assertRunTestResults�s���2B�.��.�%�-����$���#� ���GX� ���&)�)9�;Q�%R��!�C��!�#� �x� ��F��28�#
D�-��V�X� � Q�� Q�SW�X��%)��#+��
�
&�"�&�1��*�*�+=�8�?�s�+��)�&�f�i�8�"(�L�9�)�)�%)�J��J�D�%�M�%)�J��J�D�%�M�&�}�5��E��5�5�"�*7�*7� (��C�	6��� 2�;�/�B�C�G#
D�L
�O�O� �S�_�c�
�
�BS�
�
��U�$)�)�s�D#�D)�)D2	c#�K�|�Gt|t�rtj|�}|j	|||��5}|��ddd�y|j||��5}|��ddd�y#1swYyxYw#1swYyxYw�w)NrH)r`ra�re�escape�assertRaisesRegexrt)r�exc_type�expected_msgrI�ctxs     r�assertRaisesParseExceptionzApyparsing_test.TestParseResultsAsserts.assertRaisesParseException�s������'��l�C�0�#%�9�9�\�#:�L��+�+�H�l��+�L��PS��I����&�&�x�S�&�9��S��I���	�����s4�<B�A-�B�A9�$	B�-A6�2B�9B�>B)NNN)NTrp)r?r@rArBrPrZr]r}rrr�rCrr�TestParseResultsAssertsrF~sW��	�
GK�
	K�GK�	X�GK�	X�FJ�@	�D
�)��$�	�
�	rr�NT�)�indent�base_1�s�
start_line�end_line�expand_tabs�eol_mark�mark_spaces�mark_controlr�r��returnc�����|r|j�}t�t�rd�z��j��|��tjt
|�}|dk(rPt
tdd�tdd��D�	�
cic]\}	}
|	|
��
}}	}
d|d<t
j|�}d	�nFt|�}
t
jttdd
��dgzD�	cic]}	|	|
��c}	�}|j|�}|�F|dk7rA|dk(r*t
jddd
��}|j|�}n|jd|�}|�d}|�t|�}t|t|��}ttd|�|�}|dk7r|j!�||z
|}n'|j#d�||z
|D�cgc]}|dz��	}}|sy	tt|���td�|D��}�d�dzzz}|dk\rA||rd	ndzd	j%d�t|rdndt|dzd��D��zdz}nd	}|rd	nd|zd	j%d�t|dz�D��zdz}d}||rd	ndz||dzzzdz}||zdj%���fd�t'|||z��D��zdzScc}
}	wcc}	wcc}w)u�
        Helpful method for debugging a parser - prints a string with line and column numbers.
        (Line and column numbers are 1-based by default - if debugging a parse action,
        pass base_1=False, to correspond to the loc value passed to the parse action.)

        :param s: tuple(bool, str - string to be printed with line and column numbers
        :param start_line: int - (optional) starting line number in s to print (default=1)
        :param end_line: int - (optional) ending line number in s to print (default=len(s))
        :param expand_tabs: bool - (optional) expand tabs to spaces, to match the pyparsing default
        :param eol_mark: str - (optional) string to mark the end of lines, helps visualize trailing spaces (default="|")
        :param mark_spaces: str - (optional) special character to display in place of spaces
        :param mark_control: str - (optional) convert non-printing control characters to a placeholding
                                 character; valid values:
                                 - "unicode" - replaces control chars with Unicode symbols, such as "␍" and "␊"
                                 - any single character string - replace control characters with given string
                                 - None (default) - string is displayed as-is
        :param indent: str | int - (optional) string to indent with line and column numbers; if an int
                                   is passed, converted to " " * indent
        :param base_1: bool - (optional) whether to label string using base 1; if False, string will be
                              labeled based at 0 (default=True)

        :return: str - input string with leading line numbers and column number headers
        � �unicoder�!i$i3$i!$�r�� i	$i#$)�	r�u␊c3�2K�|]}t|����y�wr)�len)rc�lines  rrez3pyparsing_test.with_line_numbers.<locals>.<genexpr>Js����9��3�t�9�9���r�cc3�4K�|]}d�|dzdz�����y�w)zc                                                                                                   r�dNrC�rc�is  rrez3pyparsing_test.with_line_numbers.<locals>.<genexpr>Ps)������ �j�!�a�%�3���0��s�r��
c3�2K�|]}d|dzdz�����y�w)z	         r�
NrCr�s  rrez3pyparsing_test.with_line_numbers.<locals>.<genexpr>[s����X�Q�	�1�q�5�B�,��0�X�r�r��
1234567890�0c3�B�K�|]\}}��|��d��d|�������y�w)�d�:NrC)rcr�r�r�r��lineno_widths   ���rrez3pyparsing_test.with_line_numbers.<locals>.<genexpr>es:�������A�t��(�1�l�^�1�,�-�Q�t�f�X�J�?��s�)�start)�
expandtabsr`�int�typing�castrarr�range�	maketrans�ordrl�	translate�replacer��min�max�
splitlines�split�join�	enumerate)r�r�r�r�r�r�r�r�r��c�u�transtable_map�tbl�ord_mark_control�s_linesr��max_line_len�lead�header0�header1�digits�header2r�s    `  `              @r�with_line_numbersz pyparsing_test.with_line_numbers�s9���H�����A��f�c�"��6�\�F��"�"�$���#�!�;�;�s�L�9�L��y�(�%(��q�"��u�V�V�7L�%M�"�!�Q��A�q�D�"��"�'-��s�#��m�m�N�3����#&�|�#4� ��m�m�26�u�Q��|�2D��u�2L�M�Q�Q�(�(�M������C� �A��"�{�c�'9��i�'��m�m��F�$;�<���K�K��$���I�I�c�;�/�����J����1�v�H��x��Q��(����Q�
�+�X�6�
��9�$��l�l�n�Z�&�%8�8�D�G�*+�����
�V�8K�h�)W��!%��u���G�����3�x�=�)���9��9�9����|�a�/�0�0���2����2�S�*��'�'��"��1�A�s�<�3�;N�PQ�7R�S�����
�
��G��R�s��
��g�g�X�%�<�-�SU�BU�@V�:W�X�X�
Y��
�	����&�B�c�*�V�,��"�9L�7M�-N�N�QU�U�	�
��
��i�i��(��
�V�8K�L���
��

�	
��w"��N��&s�?
K�!
K�<K)NNT�|NN)r?r@rArBrDr��staticmethodrar��Optionalr��bool�Unionr�rCrrrrs����f�f�P{�{�z�,0�)-� ��,0�-1�n
�*,��n
��n
��O�O�C�(�n
��/�/�#�&�n
��	n
�
�n
��_�_�S�)�
n
��o�o�c�*�n
����S�#�X�&�n
��n
�

�n
��n
rr)�
contextlibrrr��corerrrrr	rrCrr�<module>r�s&��&�	�
���Y
�Y
r