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

    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                s    / V n         R # N_save_contextself   &6/usr/lib/python3.14/site-packages/pyparsing/testing.py__init__Z/pyparsing_test.reset_pyparsing_context.__init__/   s
    !#D    c                s   \         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_CHARSZ_literalStringClassr   _packratEnabledZpackrat_cacheZsize_parse_left_recursion_enabledr   Z
_all_namesZgetattrr   r   )r   name   & r   saveZ+pyparsing_test.reset_pyparsing_context.save2   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                sN   \         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
   Zset_default_whitespace_charsr   r   r   ZinlineLiteralsUsingZitemsr   ZenableZdisabler   Zenable_packratr   r   r   r   )r   r   Zvalues   &  r   restoreZ.pyparsing_test.reset_pyparsing_context.restoreR   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                sp    \        V 4      ! 4       pVP                  P                  V P                  4       V# r   )typer
   Zupdate)r   Zretr    r   copyZ+pyparsing_test.reset_pyparsing_context.copys   s,    t*,C$$T%7%78Jr   c                s"    V P                  4       # r   )r!   r   r   r   	__enter__Z0pyparsing_test.reset_pyparsing_context.__enter__x   s    99;r   c                s&    V P                  4        R # r   )r"   )r   Zargss   &*r   __exit__Z/pyparsing_test.reset_pyparsing_context.__exit__{   s    LLNr   r	   N)__name__
__module____qualname____firstlineno____doc__r   r!   r"   r$   r%   r&   __static_attributes____classdictcell____classdict__   @r   reset_pyparsing_contextr      s/     	0	$	@	B	
		 	r   r1   c                   sf   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                s    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)ZassertEqualas_listZas_dict)r   resultexpected_listexpected_dictr4   s   &&&&&r   assertParseResultsEqualsZ?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 ``ParseResults.asList()`` is equal to the ``expected_list``.
T)Z	parse_all)r7   r4   NZparse_stringprintZdumpr5   r9   )r   exprtest_stringr7   r4   verboser6      &&&&&& r   assertParseAndCheckListZ>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckList   sM     &&{d&CFfkkm$fnn&'))&SV)Wr   c                r:   )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)ZparseAll)r8   r4   Nr;   )r   r=   r>   r8   r4   r?   r6   r@   r   assertParseAndCheckDictZ>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckDict   sM     &&{T&BFfkkm$fnn&'))&SV)Wr   c                s   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 ``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)]
Nzfailed runTestsr3   c              3   V   "   T F  p\        V\        4      '       g   K  Vx  K!  	  R # 5ir   )
isinstancestr.0Zexpr    r   	<genexpr>Npyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>   s      QJsC<P   )
)c              3   s   "   T F7  p\        V\        4      '       g   K  \        V\        4      '       g   K3  Vx  K9  	  R # 5ir   )rD   r#   Z
issubclass	ExceptionrF   r    r   rH   rI      s2      #+C%c40 5?Y5O #+s   AA
A)expected_exceptionr4   c              3   rC   r   )rD   listrF   r    r   rH   rI           JJsD4IrJ   c              3   rC   r   )rD   ZdictrF   r    r   rH   rI      rN   rJ   )r7   r8   r4   zno validation for NN)Z
assertTruezipZnextassertRaisesrD   rK   r9   r<   )r   Zrun_tests_reportZexpected_parse_resultsr4   Zrun_test_successZrun_test_resultsZrptZexpectedZmergedr>   r6   Zfail_msgrL   r7   r8   s   &&&&           r   assertRunTestResultsZ;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              #  s`  "   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)Nr3   )rD   rE   reZescapeZassertRaisesRegexrQ   )r   Zexc_typeZexpected_msgr4   Zctxs   &&&& r   assertRaisesParseExceptionZApyparsing_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)NTrO   )r'   r(   r)   r*   r+   r9   rA   rB   rR   r    r   rT   r,   r-   r.   r0   r   TestParseResultsAssertsr2   ~   s>     	
	K	X	X@	D 
)$	 
	r   rV   Nc                s   < 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[ /# )	i   s
start_lineend_lineexpand_tabseol_markmark_spacesmark_controlZreturn)rE   typingZOptionalZintZbool)Zformatr/   s   "r   Z__annotate__Zpyparsing_test.__annotate__   s     ]
 ]
]
OOC(]
 //#&]
 	]

 ]
 __S)]
 ooc*]
 
]
r   c           
     s  aa V'       d   V P                  4       p Ve   \        P                  ! \        V4      pVR8X  dQ   \	        \        ^ ^!4      \        RR4      4       UUu/ uF  w  rxWxbK	  	  p	ppRV	^&   \        P                  V	4      p
RoMK\        V4      p\        P                  \        \        ^ ^ 4      4      ^.,            Uu/ uF  qwV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       V^,
          V pM0V P                  R	4      V^,
          V  Uu. uF  qR	,           NK  	  ppV'       g   R# \        \        V4      4      o\        R
 V 4       4      pRS^,           ,          pV^c8  dB   VRP!                  R \        \        V^d,          ^4      4       4       4      ,           R,           pMRpVV,           RP!                  R \        V) ^
,          ) 4       4       4      ,           R,           pVRV) ^
,          ) ,          ,           R,           pVV,           RP!                  VV3R l\#        WR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.)

: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

:return: str - input string with leading line numbers and column number headers
Zunicodei $  i3$  i!$  Z  i	$  i#$  u   ␊c              3   s8   "   T F  p\        V4      x  K  	  R # 5ir   )len)rG   liner    r   rH   3pyparsing_test.with_line_numbers.<locals>.<genexpr>=  s     93t99s   c              3   sJ   "   T F  pR V^,           ^d,           2x  K  	  R# 5i)r_   Nzc                                                                                                   rU   rG   ir    r   rH   rb   B  s(      ?  j!a%30?s   !#Z
c              3   sH   "   T F  pR V^,           ^
,           2x  K  	  R# 5i)z	         NrU   rc   r    r   rH   rb   M  s!     X:WQ	1q5B,0:Ws    "Z
1234567890c              3   sB   <"   T F  w  rVS R 2 RV S 2x  K  	  R# 5i)ZdZ:NrU   )rG   rd   ra   r[   lineno_widths   &  r   rH   rb   T  s3      CGA l^1$%QtfXJ7Cs   )Zstart)Z
expandtabsr^   ZcastrE   rP   ZrangeZ	maketransZordrM   Z	translateZreplacer`   ZminZmaxZ
splitlinesZsplitZjoinZ	enumerate)rW   rX   rY   rZ   r[   r\   r]   ZcZuZtranstable_mapZtblZord_mark_controlZs_linesra   Zmax_line_lenZleadZheader0Zheader1Zheader2re   s   &&&&f&&            @r   with_line_numbersZ pyparsing_test.with_line_numbers   s   8 A#!;;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!^h?G01zA~PX0YZ0Ye||0YGZ3x=)999lQ&'2'' "3|s':A#>? 
   GggX%<-SUBU@V:WXXY  	 L=B+>)?@@4Gii (C  	
k" N& [s   $K2
K8;K=rU   )NNTZ|NN)r'   r(   r)   r*   r+   r1   rV   Zstaticmethodrf   r,   r-   r.   r0   r   r   r      s@     f fP{ {z ]
 ]
 ]
r   r   )Z
contextlibr    rS   r^   Zcorer   r   r   r   r   r   rU   r   r   <module>rg      s&    & 	  H
 H
r   