+
    TBiq;                     R    ^ RI Ht ^ RIt^ RIt^RIHtHtHtHtH	t	  ! R R4      t
R# )    )contextmanagerN)ParserElementParseExceptionKeyword__diag__
__compat__c                   x   a  ] tR t^t o Rt ! R R4      t ! R R4      t]RRR	R
R/V 3R lR lll4       tRt	V t
R# )pyparsing_testz:
namespace class for classes useful in writing unit tests
c                   H   a  ] tR t^t o RtR tR tR tR tR t	R t
RtV tR	# )
&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:

.. testcode::

    ppt = pyparsing.pyparsing_test

    class MyTestClass(ppt.TestParseResultsAsserts):
        def test_literal(self):
            with ppt.reset_pyparsing_context():
                # test that literals used to construct
                # a grammar are automatically suppressed
                ParserElement.inline_literals_using(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                    / V n         R # N_save_contextselfs   &6/usr/lib/python3.14/site-packages/pyparsing/testing.py__init__/pyparsing_test.reset_pyparsing_context.__init__<   s
    !#D    c                   \         P                  V P                  R &   \        P                  V P                  R&   \         P
                  V P                  R&   \         P                  V P                  R&   \         P                  V P                  R&   \         P                  '       d)   \         P                  P                  V P                  R&   MRV P                  R&   \         P                  V P                  R&   \         P                  V P                  R&   \        P                   Uu/ uF  q\        \        V4      bK  	  upV P                  R	&   R
\        P                   /V P                  R&   V # u upi )default_whitespacedefault_keyword_charsliteral_string_classverbose_stacktracepackrat_enabledpackrat_cache_sizeNpackrat_parserecursion_enabledr   collect_all_And_tokensr   )r   DEFAULT_WHITE_CHARSr   r   DEFAULT_KEYWORD_CHARS_literalStringClassr   _packratEnabledpackrat_cachesize_parse_left_recursion_enabledr   
_all_namesgetattrr   r    )r   names   & r   save+pyparsing_test.reset_pyparsing_context.save?   sP   7D7X7XD34:A:W:WD67 11 56 8E7W7WD344A4Q4QD01,,,!//44 ""#78 <@""#782?2F2FD/55 23
 ;C:M:M.:M$gh--:M.Dz*
 )**K*K0D|, K.s   +E5c                N   \         P                  V P                  R ,          8w  d(   \         P                  ! V P                  R ,          4       V P                  R,          \         n        V P                  R,          \
        n        \         P                  ! V P                  R,          4       V P                  R,          P                  4        F3  w  rV'       d   \        P                  M\        P                  ! V4       K5  	  R\         n        V P                  R,          '       d)   \         P                  ! V P                  R,          4       MV P                  R,          \         n        V P                  R	,          \         n        V P                  R
,          \         n        V # )r   r   r   r   r   Fr   r   r   r   r   )r   r!   r   set_default_whitespace_charsr   r   r"   inlineLiteralsUsingitemsr   enabledisabler$   enable_packratr'   r(   r   r    )r   r+   values   &  r   restore.pyparsing_test.reset_pyparsing_context.restore_   s<    11%%&:;< ::&&';< 04/A/ABV/WM,,0,>,>?V,WG)--""#9:  $11*=CCE$)x/?/??F  F -2M)!!"344,,T-?-?@T-UV'+'9'9/'J$484F4F#5M1 150B0B<0PJ-Kr   c                p    \        V 4      ! 4       pVP                  P                  V P                  4       V# r   )typer   update)r   rets   & r   copy+pyparsing_test.reset_pyparsing_context.copy   s,    t*,C$$T%7%78Jr   c                "    V P                  4       # r   )r,   r   s   &r   	__enter__0pyparsing_test.reset_pyparsing_context.__enter__   s    99;r   c                &    V P                  4        R # r   )r6   )r   argss   &*r   __exit__/pyparsing_test.reset_pyparsing_context.__exit__   s    LLNr   r   N)__name__
__module____qualname____firstlineno____doc__r   r,   r6   r<   r?   rC   __static_attributes____classdictcell____classdict__s   @r   reset_pyparsing_contextr      s0     #	J	$	@	B	
		 	r   rN   c                   f   a  ] tR t^t o RtR	R ltR
R ltR
R ltRR lt]	]
RR3R l4       tRtV tR# )&pyparsing_test.TestParseResultsAssertsz[
A mixin class to add parse results assertion methods to normal unittest.TestCase classes.
Nc                    Ve"   V P                  W!P                  4       VR7       Ve$   V P                  W1P                  4       VR7       R# R# )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_dictrS   s   &&&&&r   assertParseResultsEquals?pyparsing_test.TestParseResultsAsserts.assertParseResultsEquals   sI     (  0@c J(  0@c J )r   c                    VP                  VRR7      pV'       d   \        VP                  4       4       M\        VP                  4       4       V P	                  WcVR7       R# )z
Convenience wrapper assert to test a parser element and input string, and assert that
the resulting :meth:`ParseResults.as_list` is equal to the ``expected_list``.
T)	parse_all)rX   rS   Nparse_stringprintdumprU   rZ   )r   exprtest_stringrX   rS   verboserW   s   &&&&&& r   assertParseAndCheckList>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckList   sM     &&{d&CFfkkm$fnn&'))&SV)Wr   c                    VP                  VRR7      pV'       d   \        VP                  4       4       M\        VP                  4       4       V P	                  WcVR7       R# )z
Convenience wrapper assert to test a parser element and input string, and assert that
the resulting :meth:`ParseResults.as_dict` is equal to the ``expected_dict``.
T)parseAll)rY   rS   Nr^   )r   rb   rc   rY   rS   rd   rW   s   &&&&&& r   assertParseAndCheckDict>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckDict   sM     &&{T&BFfkkm$fnn&'))&SV)Wr   c                   Vw  rEVf   T P                  YCe   TMRR7       R# \        WR4       UUu. uF  w  rg. VOVN5NK  	  pppV F  w  rp\        R V 4       R4      p\        R V 4       R4      pVeI   T P                  Y;'       g    TR7      ;_uu_ 4        \	        V
\
        4      '       d   V
h RRR4       Kx  \        R V 4       R4      p\        R V 4       R4      pW3R8w  d"   T P                  T
TTT;'       g    TR	7       K  \        R
V	: 24       K  	  T P                  YCe   TMRR7       R# u uppi   + '       g   i     EK  ; i)a  
Unit test assertion to evaluate output of
:meth:`~ParserElement.run_tests`.

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 ``run_tests()``
and evaluated using :meth:`assertParseResultsEquals`.
Finally, asserts that the overall
`:meth:~ParserElement.run_tests` success value is ``True``.

:param run_tests_report: the return value from :meth:`ParserElement.run_tests`
:type run_tests_report: tuple[bool, list[tuple[str, ParseResults | Exception]]]
:param expected_parse_results: (optional)
:type expected_parse_results: list[tuple[str | list | dict | Exception, ...]]
Nzfailed runTestsrR   c              3   V   "   T F  p\        V\        4      '       g   K  Vx  K!  	  R # 5ir   )
isinstancestr.0exps   & r   	<genexpr>Npyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>   s      QJsC<P   )
)c              3      "   T F7  p\        V\        4      '       g   K  \        V\        4      '       g   K3  Vx  K9  	  R # 5ir   )rm   r9   
issubclass	Exceptionro   s   & r   rr   rs      s2      #+C%c40 5?Y5O #+s   AA
A)expected_exceptionrS   c              3   V   "   T F  p\        V\        4      '       g   K  Vx  K!  	  R # 5ir   )rm   listro   s   & r   rr   rs           JJsD4Irt   c              3   V   "   T F  p\        V\        4      '       g   K  Vx  K!  	  R # 5ir   )rm   dictro   s   & r   rr   rs      r{   rt   )rX   rY   rS   zno validation for NN)
assertTruezipnextassertRaisesrm   rw   rZ   r`   )r   run_tests_reportexpected_parse_resultsrS   run_test_successrun_test_resultsrptexpectedmergedrc   rW   fail_msgrx   rX   rY   s   &&&&           r   assertRunTestResults;pyparsing_test.TestParseResultsAsserts.assertRunTestResults   s   & 2B.%-$#FW     &))9%R%RMC !# x %R   28-X   Q QSWX%)#+
 &" &1**+=??s +   &fi88"(L 9  %)JJD%M %)JJD%M &5E55"*7*7 (C	 6   2;/BCG 28L OO _cBS  U$  s   D<EEc              #  `  "   VeW   \        V\        4      '       d   \        P                  ! V4      pV P	                  WVR7      ;_uu_ 4       pVx  R R R 4       R # V P                  WR7      ;_uu_ 4       pVx  R R R 4       R #   + '       g   i     R # ; i  + '       g   i     R # ; i5i)NrR   )rm   rn   reescapeassertRaisesRegexr   )r   exc_typeexpected_msgrS   ctxs   &&&& r   assertRaisesParseExceptionApyparsing_test.TestParseResultsAsserts.assertRaisesParseException  s      'lC00#%99\#:L++H+LLPSI ML &&x&99SI :9	 MLL :99s6   AB.B$B.7B<
B.B		B.B+	%	B. )NNN)NTr~   )rE   rF   rG   rH   rI   rZ   re   ri   r   r   r   r   rJ   rK   rL   s   @r   TestParseResultsAssertsrP      s>     	
	K	X	XG	R 
)$	 
	r   r   NTindent base_1c                  < V ^8  d   QhRS[ RS[P                  S[,          RS[P                  S[,          RS[RS[ RS[P                  S[ ,          RS[P                  S[ ,          RS[P
                  S[ S[3,          R	S[R
S[ /
# )   s
start_lineend_lineexpand_tabseol_markmark_spacesmark_controlr   r   return)rn   typingOptionalintboolUnion)formatrM   s   "r   __annotate__pyparsing_test.__annotate__  s     t
 t
t
OOC(t
 //#&t
 	t

 t
 __S)t
 ooc*t
 S#X&t
 t
 
t
r   c                 aaa V'       d   V P                  4       p \        S\        4      '       d
   RS,          oSP                  4       oVe   \        P                  ! \
        V4      pVR8X  dQ   \        \        ^ ^!4      \        RR4      4       U	U
u/ uF  w  rWbK	  	  pp	p
RV^&   \
        P                  V4      pRoMK\        V4      p\
        P                  \        \        ^ ^ 4      4      ^.,            U	u/ uF  qVbK  	  up	4      pV P                  V4      p VeL   VR8w  dE   VR8X  d,   \
        P                  ^	R^ R/4      pV P                  V4      p MV P                  RV4      p Vf   ^ pVf   \        V 4      p\        V\        V 4      4      p\        \        ^ V4      V4      pVR8w  d   V P!                  4       W,
          V pM/V P#                  R	4      W,
          V  Uu. uF  qR	,           NK  	  ppV'       g   R# \        \        V4      4      o\        R
 V 4       4      pSRS^,           ,          ,           pV^c8  d^   TV'       d   RMR,           RP%                  R \        V'       d   ^M^ \        V^d,          ^4      4       4       4      ,           R,           pMRpV'       d   RMRV,           RP%                  R \        V) ^
,          ) 4       4       4      ,           R,           pRpTV'       d   RMR,           VV) ^
,          ) ,          ,           R,           pVV,           RP%                  VVV3R l\'        WV,           R7       4       4      ,           R,           # u up
p	i u up	i u upi )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: string to be printed with line and column numbers
:param start_line: starting line number in s to print (default=1)
:param end_line: ending line number in s to print (default=len(s))
:param expand_tabs: expand tabs to spaces, to match the pyparsing default
:param eol_mark: string to mark the end of lines, helps visualize trailing spaces
:param mark_spaces: special character to display in place of spaces
:param mark_control: 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: string to indent with line and column numbers; if an int
               is passed, converted to ``" " * indent``
:param base_1: whether to label string using base 1; if False, string will be
               labeled based at 0

:returns: input string with leading line numbers and column number headers

.. versionchanged:: 3.2.0
   New ``indent`` and ``base_1`` arguments.
 unicodei $  i3$  i!$  r   i	$  i#$  u   ␊c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   )len)rp   lines   & r   rr   3pyparsing_test.with_line_numbers.<locals>.<genexpr>d  s     93t99s   c              3   J   "   T F  pR V^,           ^d,           2x  K  	  R# 5i)r   Nzc                                                                                                   r   rp   is   & r   rr   r   j  s(      S  j!a%30Ss   !#
c              3   H   "   T F  pR V^,           ^
,           2x  K  	  R# 5i)z	         Nr   r   s   & r   rr   r   u  s!     X:WQ	1q5B,0:Ws    "
12345678900c              3   F   <"   T F  w  rS VS R 2 RV S 2x  K  	  R# 5i)d:Nr   )rp   r   r   r   r   lineno_widths   &  r   rr   r     s7      LGA (1l^1,-QtfXJ?Ls   !)start)
expandtabsrm   r   r   castrn   r   range	maketransordrz   	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   &&&&f&&d$             @r   with_line_numbers pyparsing_test.with_line_numbers  s@   T Afc""6\F""$#!;;sL9Ly(%(q"uVV7L%M"%MTQAD%M  " '-s#mmN3#&|#4 mm26uQ|2Du2LM2LQ((2LM C A"{c'9i'mmQF$;<KK$IIc;/J1vHxQ(Q
+X6
9$llnZ%88DG *+
8Kh)W)Wu)W   3x=)999|a/0022S*'' "1As<3;NPQ7RS    GRsggX%<-SUBU@V:WXXY  	 &Bc*V,"9L7M-NNQUU 	 ii (V8KL  	
w" N&s   M(:M.)M3r   )NNT|NN)rE   rF   rG   rH   rI   rN   r   staticmethodr   rJ   rK   rL   s   @r   r
   r
      sV     s sjB BH t
 *,t
 t
 t
 t
r   r
   )
contextlibr   r   r   corer   r   r   r   r   r
   r   r   r   <module>r      s&    & 	  s
 s
r   