
    <e{                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 dZ
 G d dej                  Zedk    r ej                     dS dS )    N)temp_cwd)assert_python_failurezglobal variablec                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<d; Z=d< Z>d= Z?d> Z@d? ZAd@ ZBdA ZCdB ZDdC ZEdD ZFdE ZGdFS )GTestCasec                     |D ]m}|                      |          5  |                     ||          5  t          |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   nd S )Nstr)subTestassertRaisesRegexeval)selfexception_typeregexerror_stringsr	   s        (/usr/lib/python3.11/test/test_fstring.pyassertAllRaisezTestCase.assertAllRaise   s      	 	C#&&  ++NEBB  III                            	 	s4   A%AA%AA%AA%%A)	,A)	c                     G d d          } |            } |            }t          j        d |          |_        |                     | t	          |                     |                     | d           |                     t	          |          t	          |                     |                     |                    d          d           |                     |                    d          d           |                     t          |                              |d          d           |                     t          |                              |d          d           d S )Nc                       e Zd Zd ZdS )(TestCase.test__format__lookup.<locals>.Xc                     dS )Nclass r   specs     r   
__format__z3TestCase.test__format__lookup.<locals>.X.__format__&   s    w    N__name__
__module____qualname__r   r   r   r   Xr   %   s#            r   r!   c                     dS )Ninstancer   r   s     r   <lambda>z/TestCase.test__format__lookup.<locals>.<lambda>.   s    : r   r    r#   )types
MethodTyper   assertEqualformattype)r   r!   xys       r   test__format__lookupzTestCase.test__format__lookup#   sZ   	 	 	 	 	 	 	 	 ACC ACC'(E(EqIIA+++A)))F1II...
 	b))7333b)):666 	a++Ar22G<<<a++Ar22G<<<<<r   c                     G d d          } |            }d}t          j        |          }t          |dd          }|                     |j                   t          |           |                     |j                   d S )Nc                       e Zd Zd Zd ZdS )TestCase.test_ast.<locals>.Xc                     d| _         d S )NFcalledr   s    r   __init__z%TestCase.test_ast.<locals>.X.__init__A   s    #r   c                     d| _         dS )NT   r2   r4   s    r   __call__z%TestCase.test_ast.<locals>.X.__call__C   s    "qr   N)r   r   r    r5   r8   r   r   r   r!   r0   @   s2        $ $ $    r   r!   
a = 10
f'{a * x()}'r%   exec)astparsecompileassertFalser3   r:   
assertTrue)r   r!   r+   exprtcs         r   test_astzTestCase.test_ast>   s    	 	 	 	 	 	 	 	 ACC IdOOAr6"" 	""" 	Q 	!!!!!r   c                    d}t          j        |          }|                     t          |          t           j                   |                     t          |j                  d           |                     t          |j        d                   t           j                   |                     |j        d         j        d           |                     t          |j        d                   t           j	                   |                     t          |j        d         j
                  t           j                   |                     t          |j        d         j
        j                  d           |                     t          |j        d         j
        j        d                   t           j                   |                     |j        d         j        d           |                     |j        d         j
        j        d           |                     |j        d         j
        j        d         j        d           |j        d         j
        j        d         j
        }|                     t          |          t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     |j        d           |                     |j        j        d           |                     |j        j        d           |                     |j        d           |                     |j        j        d           |                     |j        j        d           d S )Nr9      r            )r;   r<   r(   r*   ModulelenbodyAssignlinenoExprvalue	JoinedStrvaluesFormattedValueBinOpleftNameopMultrightCall
col_offsetr   r@   rA   binops       r   test_ast_line_numberszTestCase.test_ast_line_numbersV   s    IdOOa#*---QVa(((afQi#*555)1---afQi#(333afQio..>>>QVAY_344a888afQio4Q788#:LMMM)1---/333/291===q	&q)/eci000ej))38444eh222ek**CH555q)))*A...+Q///)1---.222/33333r   c                    d}t          j        |          }|                     t          |          t           j                   |                     t          |j                  d           |                     t          |j        d                   t           j                   |                     t          |j        d         j                  t           j	                   |                     |j        d         j
        d           |                     t          |j        d                   t           j                   |                     t          |j        d         j                  t           j	                   |                     t          |j        d         j        j                  d           |                     t          |j        d         j        j        d                   t           j                   |                     t          |j        d         j        j        d         j                  t                     |                     t          |j        d         j        j        d                   t           j                   |                     t          |j        d         j        j        d                   t           j                   |                     t          |j        d         j        j        d         j                  t                     |                     t          |j        d         j        j        d                   t           j                   |                     |j        d         j
        d           |                     |j        d         j        j
        d           |                     |j        d         j        j        d         j
        d           |                     |j        d         j        j        d         j
        d           |                     |j        d         j        j        d         j
        d           |                     |j        d         j        j        d         j
        d           |j        d         j        j        d         j        }|                     t          |          t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     |j
        d           |                     |j        j
        d           |                     |j        j
        d           |                     |j        d           |                     |j        j        d           |                     |j        j        d           |j        d         j        j        d         j        }|                     t          |          t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     |j
        d           |                     |j        j
        d           |                     |j        j
        d           |                     |j        d	           |                     |j        j        d	           |                     |j        j        d
           d S )Nz8
f'no formatted values'
f'eggs {a * x()} spam {b + y()}'rE   r   rF   r7   rG               )r;   r<   r(   r*   rI   rJ   rK   rN   rO   rP   rM   rQ   Constantr	   rR   rS   rT   rU   rV   rW   rX   rY   rZ   Add)r   r@   rA   binop1binop2s        r   .test_ast_line_numbers_multiple_formattedvaluesz7TestCase.test_ast_line_numbers_multiple_formattedvaluesu   s   $ IdOOa#*---QVa(((afQi#(333afQio..>>>)1---afQi#(333afQio..>>>QVAY_344a888afQio4Q788#,GGGafQio4Q7=>>DDDafQio4Q788#:LMMMafQio4Q788#,GGGafQio4Q7=>>DDDafQio4Q788#:LMMM)1---/333/291===/291===/291===/291==='*0fsy111fk**CH555fi#(333fl++SX666***+Q///,a000*A.../3330"555'*0fsy111fk**CH555fi#'222fl++SX666***+Q///,a000*B////4440"55555r   c                 x   d}t          j        |          }|                     t          |          t           j                   |                     t          |j                  d           |                     t          |j        d                   t           j                   |                     |j        d         j        d           |                     t          |j        d                   t           j	                   |                     t          |j        d         j
                  t           j                   |                     t          |j        d         j
        j                  d           |                     t          |j        d         j
        j        d                   t           j                   |                     |j        d         j        d           |                     |j        d         j
        j        d           |                     |j        d         j
        j        d         j        d           |j        d         j
        j        d         j
        }|                     t          |          t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     |j        d           |                     |j        j        d           |                     |j        j        d           |                     |j        d           |                     |j        j        d           |                     |j        j        d           |                     t          |j        j                  d           |                     t          |j        j        d                   t           j                   |                     t          |j        j        d         j
                  t,                     |                     t          |j        j        d                   t           j                   |                     t          |j        j        d                   t           j                   |                     t          |j        j        d         j
                  t,                     |                     |j        j        d         j        d           |                     |j        j        d         j        d           |                     |j        j        d         j        d           |j        j        d         j
        }|                     t          |          t           j                   |                     |j        d           |                     |j        d           d S )Nz
a = 10
f'{a * f"-{x()}-"}'rE   r   rF   rG   rH      )r;   r<   r(   r*   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rZ   rc   r	   rY   )r   r@   rA   r\   calls        r   test_ast_line_numbers_nestedz%TestCase.test_ast_line_numbers_nested   s    IdOOa#*---QVa(((afQi#*555)1---afQi#(333afQio..>>>QVAY_344a888afQio4Q788#:LMMM)1---/333/291===q	&q)/eci000ej))38444eh222ek**CM:::q)))*A...+Q///)1---.222/333U[/00!444ek0344clCCCek039::C@@@ek0344c6HIIIek0344clCCCek039::C@@@+A.5q999+A.5q999+A.5q999{!!$*dSX...a((("-----r   c                 B   d}t          j        |          }|                     t          |          t           j                   |                     t          |j                  d           |                     t          |j        d                   t           j                   |                     |j        d         j        d           |                     t          |j        d                   t           j	                   |                     t          |j        d         j
                  t           j                   |                     t          |j        d         j
        j                  d           |                     t          |j        d         j
        j        d                   t           j                   |                     t          |j        d         j
        j        d                   t           j                   |                     t          |j        d         j
        j        d         j
                  t                     |                     t          |j        d         j
        j        d                   t           j                   |                     t          |j        d         j
        j        d                   t           j                   |                     t          |j        d         j
        j        d         j
                  t                     |                     t          |j        d         j
        j        d                   t           j                   |                     |j        d         j        d           |                     |j        d         j
        j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |j        d         j
        j        d         j
        }|                     t          |          t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     |j        d           |                     |j        j        d           |                     |j        j        d           |                     |j        d           |                     |j        j        d           |                     |j        j        d           |j        d         j
        j        d         j
        }|                     t          |          t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     |j        d           |                     |j        j        d           |                     |j        j        d           |                     |j        d	           |                     |j        j        d	           |                     |j        j        d
           |j        d         j
        j        d         j
        }|                     t          |          t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     |j        d           |                     |j        j        d           |                     |j        j        d           |                     |j        d           |                     |j        j        d           |                     |j        j        d           d S )Nz)
a = 10
f'{a * x()} {a * x()} {a * x()}'
rE   r   rF      rG   r7   rH         ra   rb   )r;   r<   r(   r*   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rc   r	   rS   rT   rU   rV   rW   rX   rY   rZ   r[   s       r   *test_ast_line_numbers_duplicate_expressionz3TestCase.test_ast_line_numbers_duplicate_expression   s    IdOOa#*---QVa(((afQi#*555)1---afQi#(333afQio..>>>QVAY_344a888afQio4Q788#:LMMMafQio4Q788#,GGGafQio4Q7=>>DDDafQio4Q788#:LMMMafQio4Q788#,GGGafQio4Q7=>>DDDafQio4Q788#:LMMM)1---/333/291===/291===/291===/291===/291===q	&q)/eci000ej))38444eh222ek**CH555q)))*A...+Q///)1---.222/333q	&q)/eci000ej))38444eh222ek**CH555q)))*A...+Q///)2....333/444q	&q)/eci000ej))38444eh222ek**CH555q)))*A...+Q///)2....333/44444r   c                 J   t          j        d          }|                     t          |j                  d           |                     |j        d         j        d           |                     t          |j        d                   t           j                   |                     t          |j        d         j                  t           j	                   |                     t          |j        d         j        j
                  d           |                     t          |j        d         j        j
        d                   t           j                   |                     t          |j        d         j        j
        d                   t           j                   |                     t          |j        d         j        j
        d                   t           j                   |j        d         j        j
        \  }}}|j        }|                     t          |          t           j                   |                     |j        d           |                     |j        d           |                     |j        d           |                     |j        d           d S )Nz%f"Here is that pesky {xxx:.3f} again"rF   r   rG   rE         )r;   r<   r(   rJ   rK   rM   r*   rN   rO   rP   rQ   rc   rR   rU   
end_linenorZ   end_col_offset)r   rA   _r@   names        r   (test_ast_numbers_fstring_with_formattingz1TestCase.test_ast_numbers_fstring_with_formatting  s   I=>>QVa((()1---afQi#(333afQio..>>>QVAY_344a888afQio4Q788#,GGGafQio4Q788#:LMMMafQio4Q788#,GGGVAY_+
4zdSX...a(((!,,,"---,b11111r   c                 (   d}t          j        |          }|                     t          |          t           j                   |                     t          |j                  d           |                     t          |j        d                   t           j                   |                     |j        d         j        d           |                     t          |j        d                   t           j	                   |                     t          |j        d         j
                  t           j                   |                     t          |j        d         j
        j                  d           |                     t          |j        d         j
        j        d                   t           j                   |                     t          |j        d         j
        j        d         j
                  t                     |                     t          |j        d         j
        j        d                   t           j                   |                     t          |j        d         j
        j        d                   t           j                   |                     t          |j        d         j
        j        d         j
                  t                     |                     |j        d         j        d           |                     |j        d         j
        j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j        d           |                     |j        d         j
        j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |j        d         j
        j        d         j
        }|                     t          |          t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     t          |j                  t           j                   |                     |j        d           |                     |j        j        d           |                     |j        j        d           |                     |j        d           |                     |j        j        d           |                     |j        j        d           d	}t          j        |          }|                     t          |          t           j                   |                     t          |j                  d           |                     t          |j        d                   t           j                   |                     t          |j        d         j
                  t           j                   |                     t          |j        d         j
        j                  d           |                     t          |j        d         j
        j        d                   t           j                   |                     |j        d         j        d           |                     |j        d         j
        j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j        d           |                     |j        d         j
        j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j        d           |                     |j        d         j
        j        d         j
        j        d           |                     |j        d         j
        j        d         j
        j        d           |                     |j        d         j
        j        d         j
        j        d
           |                     |j        d         j
        j        d         j
        j        d           d S )Nz?
a = 10
f'''
  {a
     *
       x()}
non-important content
'''
rE   r   rF   rG   r7      rH   z$
a = f'''
          {blech}
    '''
ri      )r;   r<   r(   r*   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rc   r	   rR   rZ   rS   rT   rU   rV   rW   rX   rY   rt   ru   r[   s       r   'test_ast_line_numbers_multiline_fstringz0TestCase.test_ast_line_numbers_multiline_fstring/  s    IdOOa#*---QVa(((afQi#*555)1---afQi#(333afQio..>>>QVAY_344a888afQio4Q788#,GGGafQio4Q7=>>DDDafQio4Q788#:LMMMafQio4Q788#,GGGafQio4Q7=>>DDD)1---/333/291===/291===/291===-q1113Q777/2=qAAA/2=qAAA/2=qAAA q	&q)/eci000ej))38444eh222ek**CH555q)))*A...+Q///)1---.222/333
 IdOOa#*---QVa(((afQi#*555afQio..>>>QVAY_344a888afQio4Q788#:LMMM)1---/333/291===/291===/291===-q1113Q777/2=qAAA/2=qAAA/2=qAAA/28?CCC/28CQGGG/28CRHHH/28GLLLLLr   c                    d}t          j        |          }|                     t          |          t           j                   |                     t          |j                  d           |j        d         j        j        d         j        }|                     t          |          t           j	                   |                     |j
        d           |                     |j        d           |                     |j        d           |                     |j        d           d}t          j        |          }|                     t          |          t           j                   |                     t          |j                  d           |j        d         j        j        d         }|                     t          |          t           j                   |                     t          |j                  d           |j        \  }}}|                     t          |          t           j                   |                     |j
        d           |                     |j        d	           |                     |j        d
           |                     |j        d           |j        }|                     t          |          t           j	                   |                     |j
        d           |                     |j        d           |                     |j        d           |                     |j        d           |                     t          |          t           j                   |                     |j
        d           |                     |j        d	           |                     |j        d
           |                     |j        d           d S )Nz
x = (
    f" {test(t)}"
)rF   r   rG   r_      zv
x = (
        'PERL_MM_OPT', (
            f'wat'
            f'some_string={f(x)} '
            f'wat'
        ),
)
r7   rz   r`      rm   rb      )r;   r<   r(   r*   rI   rJ   rK   rO   rQ   rY   rM   rt   rZ   ru   eltsrP   rc   )r   r@   rA   rj   fstringwat1middlewat2s           r   &test_ast_line_numbers_with_parenthesesz/TestCase.test_ast_line_numbers_with_parentheses~  s(    IdOOa#*---QVa(((vay%a(.dSX...a(((!,,,!,,,,b111 IdOOa#*---QVa(((&)/&q)g666W^,,a000$^fddS\222a(((!,,,"---,b111|dSX...a(((!,,,"---,b111dS\222a(((!,,,"---,b11111r   c                 z    d }|                      |j                   d }|                      |j                   d S )Nc                  
    d d S NzNot a docstringr   r   r   r   fz"TestCase.test_docstring.<locals>.f  s    """"r   c                  
    d d S r   r   r   r   r   gz"TestCase.test_docstring.<locals>.g  s       r   )assertIsNone__doc__)r   r   r   s      r   test_docstringzTestCase.test_docstring  sT    	# 	# 	#!)$$$	 	 	 	!)$$$$$r   c                     |                      t          d          5  t          j        d           d d d            d S # 1 swxY w Y   d S )Nzmalformed node or stringzf'x')r   
ValueErrorr;   literal_evalr4   s    r   test_literal_evalzTestCase.test_literal_eval  s    ##J0JKK 	% 	%V$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   >AAc                     dg}d}t          j        |          }t          |dd          }t          |           |                     |d         d           d S )Nr%   zx[0] = 'foo' f'{3}'r:   r   foo3)r;   r<   r=   r:   r(   )r   r+   r@   rA   rB   s        r   test_ast_compile_time_concatz%TestCase.test_ast_compile_time_concat  sW    D(IdOOAr6""Q1v&&&&&r   c                 B    |                      t          dddg           d S )Nz&cannot mix bytes and nonbytes literalszf'' b''zb'' f''r   SyntaxErrorr4   s    r   test_compile_time_concat_errorsz(TestCase.test_compile_time_concat_errors  s4    KD++	  	  	  	  	 r   c                     |                       d           |                      dd           |                      dd           d S )Nr%   a r(   r4   s    r   test_literalzTestCase.test_literal  sJ    b!!!s###s#####r   c                 B    |                      t          dg d           d S )Nzf-string: unterminated string)zf'{"x'zf'{"x}'zf'{("x'zf'{("x}'r   r4   s    r   test_unterminated_stringz!TestCase.test_unterminated_string  s8    K)H  	  	  	  	  	 r   c                 j   |                      t          ddg           |                      t          ddg           |                      t          ddg           |                      t          ddg           |                      t          dd	g           |                     t          t          d
           d S )NzJf-string: closing parenthesis '\}' does not match opening parenthesis '\('zf'{((}'zJf-string: closing parenthesis '\)' does not match opening parenthesis '\['z	f'{a[4)}'zJf-string: closing parenthesis '\]' does not match opening parenthesis '\('z	f'{a(4]}'zJf-string: closing parenthesis '\}' does not match opening parenthesis '\['zf'{a[4}'zf'{a(4}'a  f'{((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((}')r   r   assertRaisesr   r4   s    r   test_mismatched_parenszTestCase.test_mismatched_parens  s    K *G& 	  	  	  	K *G( 	 	 	 	K *G( 	 	 	 	K *G' 	 	 	 	K *G' 	 	 	 	+t-CDDDDDr   c                    |                      dd           |                      dd           |                      dd           |                      dd           |                      dd           |                      dd           |                      dd           |                      dd           |                      d	d	           |                      d
d
           |                      dd           |                      dd           |                      dd           |                      dd           |                      dd           |                      dd           |                      dd d           |                      dd d           |                      dd d           |                      dd d           |                      d dd           |                      d dd           |                      d dd           |                      d dd           |                      d d           |                     t          ddg           d S ) N{za{z{bza{b}za}z}bza}bz{}za{}z{b}z{}cza{b}za{}cz{b}cza{b}c
   z{10z}10z}{z}{10z}a{z}a{10z10{z10}z10}{z}a{}z10}a{}z{{}}zunhashable typezf'{ {{}} }')r(   r   	TypeErrorr4   s    r   test_double_braceszTestCase.test_double_braces  s   $$$&&&&&&%((($$$&&&&&&%((($'''5)))5)))5)))F+++F+++F+++W---bE***bE***f---w///BE***BE***Bf---B)))8444 	Ff---I'8* 	  	  	  	  	 r   c                    d}|                      d| dd           |                      d| dd           |                      d| d|dd           |                      d	| d
           |                      d| d           |                      d	| d
           |                      d| d           |                      d| d           |                      d| d           |                      | dd           |                      | d           |                      | d           |                      | d           |                      | dd           |                      d| dd           |                      d| d           |                      | d| d           |                       d           |                       d           |                       d           |                       d           |                       d           |                       d           |                       d           |                     t          ddg           d S )Ndefzabc## ghizabc## defghiabc	abcdefghi4zabcdefghidef z{x}z{x}defz{xz{xdefz{{x}}z{{x}}defz{{xz{{xdefzx}}zx}}defzdefx}}2def211def21def-zdef-defr%   f-string: expecting '}'z
f'{3' f'}'r(   r   r   r   r+   s     r   test_compile_time_concatz!TestCase.test_compile_time_concat  s   +Q+++^<<<+!+++[9994!44q944oFFF!x000g...!x000A444!x000!x000Ax000AE***qu---qE***AV,,,111V,,,AA333$$$B'''+++b!!!$$$R(((+++K)B) 	  	  	  	  	 r   c                     ddi}|                      d d           |                      |d          d           |                     t          dg d           |                     t          ddg           d S )N#hashz+f-string expression part cannot include '#')zf'{1#}'z	f'{3(#)}'zf'{#}'f-string: unmatched '\)'zf'{)#}'r   r   ds     r   test_commentszTestCase.test_comments6  s    &MC3'''AcFf---K)V  	  	  	 
 	K)D& 	  	  	  	  	 r   c                    dd}d}d}t          dd          D ]4}|                     t           ||                    |dz   |z             5|                     t           |d          d	z            |dz   d
z              |dd          }|                     t          |          |dz   dz             ddz  }|                     t          |          d           d S )Nr%   c                     dd| z  z   |z   dz   S )Nzf'z{x} 'r   )nextras     r   
build_fstrz2TestCase.test_many_expressions.<locals>.build_fstrK  s    6A:&.44r   r!   rF      i  r         i      z{x:{width}}    zf'{1}' 'x' 'y'i      1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy)r%   )ranger(   r   )r   r   r+   widthiss         r   test_many_expressionszTestCase.test_many_expressionsF  s   
	5 	5 	5 	5  sC 	= 	=AT**Q--001S5!)<<<< 	jjooc122QsUW4EFFFJsN++a1S5#+... t#a,/////r   c           	         d}d}t          j        d          }|                     d|| d| d           |                     d||d| d           |                     d||dd|dd           |                     d|d	 d
dd|dd           |                     d|d	 d
dd|dd           |                     ddd	 dd           |                     dd dd
 d d           |                     ddd dd
 dd           |                     dd dd	 dd d           |                     dddddik    o| dd           |                     t          ddg           |                     t          ddg           |                     t          ddg           |                     t          ddg           d S )Nr   r7   z12.34567zresult: .zresult:      12.350r   rF   r   r   0xz
       0xar+   ir   z
      -0xarG   rm   r   zf'{"s"!r{":10"}}'f-string: invalid syntaxzf'{4:{/5}}'z'f-string: expressions nested too deeplyz,f'result: {value:{width:{0}}.{precision:1}}'&f-string: invalid conversion characterzf'{"s"!{"r"}}')decimalDecimalr(   r   r   )r   r   	precisionrO   s       r   !test_format_specifier_expressionsz*TestCase.test_format_specifier_expressions_  s   	
++?E5??9????AUVVVAE5AAYAAAACWXXXCE5CCCYCCCCCEYZZZBE1BaBBBIBBBBBDXYYYEEAEEEEyEEEEEG[\\\B666B//a////>>>C-#------|<<<C11q113111<@@@B9qe!59999<HHHK)B4 	  	  	  	K)C*	  	  	 
 	K)RK	  	  	 
 	K)Q 2	  	  	  	  	 r   c                 j     G d d          } |            }|                      | d| d           d S )Nc                       e Zd Zd Zd ZdS )*TestCase.test_side_effect_order.<locals>.Xc                     d| _         d S )Nr   )r   r4   s    r   r5   z3TestCase.test_side_effect_order.<locals>.X.__init__  s    r   c                 J    | xj         dz  c_         t          | j                   S )NrF   )r   r	   r   s     r   r   z5TestCase.test_side_effect_order.<locals>.X.__format__  s    !46{{"r   N)r   r   r    r5   r   r   r   r   r!   r     s2          # # # # #r   r!   r   z1 2r   )r   r!   r+   s      r   test_side_effect_orderzTestCase.test_side_effect_order  s]    	# 	# 	# 	# 	# 	# 	# 	# ACCAU+++++r   c                 2   |                      t          dg d           |                      t          dg d           |                      t          dg d           |                      t          dg d           |                      t          d	d
dg           d S )Nz&f-string: empty expression not allowed)zf'{}'zf'{ }'f' {} 'zf'{10:{ }}'zf' { } 'zf'''{	
}'''z(f-string: expression required before '!')zf'{!r}'zf'{ !r}'zf'{!}'zf'''{	
!a}'''zf'{!'zf'{!s:'zf'{!x}'z	f'{ !xr}'zf'{!x:}'z	f'{!x:a}'z
f'{ !xr:}'zf'{ !xr:a}'z(f-string: expression required before ':')zf'{:}'zf'{ :!}'zf'{:2}'zf'''{	
:a}'''zf'{:'z(f-string: expression required before '=')zf'{=}'zf'{ =}'zf'{ =:}'z
f'{   =!}'zf'''{	
=}'''zf'{='z'invalid non-printable character U\+00A0u   f'''{ }'''    r   r4   s    r   test_missing_expressionz TestCase.test_missing_expression  s    K)Q	 	 	
	  
	  
	  	K)S  	  	  	 * 	K)S  	  	  	  	K)S  	  	  	  	K)S,#	  	  	  	  	 r   c                     |                      d d           |                     t          dddg           |                     t          ddg           |                     t          ddg           d S )	N)rG   z(3,)r   zf'{,}'r   z
f'{3)+(4}'zunterminated string literalzf'{
}'r   r4   s    r   test_parens_in_expressionsz#TestCase.test_parens_in_expressions  s    4&))) 	K)C%%	  	  	 
 	K)D) 	  	  	  	K)F& 	  	  	  	  	 r   c                 B    |                      t          dg d           d S )Ninvalid syntax)zf'{.}'z
f'{.}'z

f'{.}'r   r4   s    r   !test_newlines_before_syntax_errorz*TestCase.test_newlines_before_syntax_error  s2    K)9444	6 	6 	6 	6 	6r   c                    |                      dd           |                      dd           |                      dd           |                      d dd           |                      d dd d           |                      dd d           |                      dd           |                      d	d	           |                      d	d	           |                      d dd
           |                      d dd d           |                      dd d           |                      dd           |                      dd           |                      dd           |                      d dd
           |                      d dd d           |                      dd d           |                      dd           |                      d dd
           |                      d dd d           |                      dd d           |                      d
d
           |                      dd           |                      dd           |                      dd           |                      dd           |                      dd           |                      d dd           |                      d dd d           |                      dd d           |                      dd           |                      dd           |                      dd           |                     t                    5  t          d          }d d d            n# 1 swxY w Y   |                      |d           |                      dd d           |                      dd d           d}|                      dd           |                      d| d           |                      d| d           |                      dd           d S )N	z\trE   z2	rG   z2	3z	3u   Δz\u0394u   2Δu   2Δ3u   Δ3z
\U00000394r   z\x20z2 z2 3z 3z	f'\{6*7}'z\42\*   spam&z\Nz\Nspamz\&)r(   assertWarnsDeprecationWarningr   )r   rO   	AMPERSANDs      r   test_backslashes_in_string_partz(TestCase.test_backslashes_in_string_part  s   %%%&&&'''A5)))Af---a5)))H---I...Y///Ay111AQ*555!y111111666777A)))9555A,,,,j999)a))9555:HEEEA===yIIIA@@Q@@*MMM=!==yIII;YGGG<jIII;YGGG#&&&'***7+++AT***A1...T***4(((E***4(((011 	' 	'&&E	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	''''cV,,,cV,,,	 	)3///*y**I666*y**I666+U33333s   >MM!Mc                 B    |                      t          dg d           d S )Nzi\(unicode error\) 'unicodeescape' codec can't decode bytes in position .*: malformed \\N character escape)
zf'\N'zf'\N 'zf'\N  'zf'\N{'z f'\N{GREEK CAPITAL LETTER DELTA'z'\N'z'\N 'z'\N  'z'\N{'z'\N{GREEK CAPITAL LETTER DELTA'r   r4   s    r   %test_misformed_unicode_character_namez.TestCase.test_misformed_unicode_character_name  s=     	K  *V  	  	  	  	  	 r   c                 B    |                      t          dg d           d S )Nz3f-string expression part cannot include a backslash)z
f'{\'a\'}'zf'{\t3}'zf'{\}'zrf'{\'a\'}'z	rf'{\t3}'zrf'{\}'zrf'{"\N{LEFT CURLY BRACKET}"}'zf'{\n}'r   r4   s    r   &test_no_backslashes_in_expression_partz/TestCase.test_no_backslashes_in_expression_part*  s8    K)^  		  		  		  		  		 r   c                     	 |                      dd           |                      dd           |                      dd           |                      dd           d S )Nz{1+1}z{1+1r   r4   s    r   test_no_escapes_for_bracesz#TestCase.test_no_escapes_for_braces6  sh    	 	w///V,,,v...LgVVVVVr   c                 b    |                      d d           |                      d d           d S )Nr   r   rH   7r   r4   s    r   test_newlines_in_expressionsz%TestCase.test_newlines_in_expressions@  sI    A%%%   
	 	 	 	 	r   c                    d|                       fdd          d           |                       fdd          dd           |                       fdd          dd	           |                     t          d
dg           d S )Nrm   c                     | z  S Nr   r,   r+   s    r   r$   z&TestCase.test_lambda.<locals>.<lambda>G      ac r   8z'88888'c                     | z  S r   r   r  s    r   r$   z&TestCase.test_lambda.<locals>.<lambda>H  r  r   10z
'88888'   c                     | z  S r   r   r  s    r   r$   z&TestCase.test_lambda.<locals>.<lambda>I  r  r   z
88888     r   zf'{lambda x:x}'r   r   s    @r   test_lambdazTestCase.test_lambdaE  s    \\\\\3//3Y???\\\\\3//66EEE\\\\\3//44lCCC 	K)C. 	  	  	  	  	 r   c                     d } |d          }|                      t          |          d           |                      t          |          d            d S )Nc              3   (   K   d| dz  V   d V   d S )Nzy:rE   r   )r,   s    r   fnzTestCase.test_yield.<locals>.fnT  s+      qsuuJJJJr   r7   r_   )r(   next)r   r
  r   s      r   
test_yieldzTestCase.test_yieldQ  s^    	 	 	 BqEEa!$$$a$'''''r   c                     d } |d          }t          |          }|                      |d          d           |                     |                    d          d           d S )Nc              3   $    K   d fdV  V  d S )Nx:c                     | z  S r   r   )r   r+   s    r   r$   z6TestCase.test_yield_send.<locals>.fn.<locals>.<lambda>^  s    A r   r   r+   s   `r   r
  z$TestCase.test_yield_send.<locals>.fn]  s-      0oooo..0000000r   r   r7   (   stringzx:string)r  r(   send)r   r
  r   
the_lambdas       r   test_yield_sendzTestCase.test_yield_send\  sq    	1 	1 	1 BrFF!WW
A+++)):66666r   c                 v   |                      d d           |                      d d           |                      d d           |                      d d           |                      d d           |                      d d           |                      d d           |                      d d           d S )Nr+   zeric'szxeric"syzxeric"szeric"syr   r4   s    r   +test_expressions_with_triple_quoted_stringsz4TestCase.test_expressions_with_triple_quoted_stringse  s    Gs+++L*H555 	02J???,.	:::,.	:::46
CCC8:JGGG9;ZHHHHHr   c                    d}d}|                      | | d           |                      d| | d           |                      | d| d           |                      | | dd           |                      d| d| d	           |                      d| | dd
           |                      | d| dd           |                      d| d| dd           d S )Nb   r   98abcr!   X98abc98Xabc98abcXYX98YabcX98abcY98XabcYZX98YabcZr   )r   r+   r,   s      r   test_multiple_varszTestCase.test_multiple_varsq  s   AqG,,,QX...AX...AqX...Qi000Qi000Ai000Qz22222r   c                     d }|                        |d                      d           |                        |d                      d           d S )Nc                       fd}|S )Nc                      d  S )Nr  r   r  s   r   innerz3TestCase.test_closure.<locals>.outer.<locals>.inner  s    Axxr   r   )r+   r)  s   ` r   outerz$TestCase.test_closure.<locals>.outer  s!             Lr   987zx:987rH   zx:7r   )r   r*  s     r   test_closurezTestCase.test_closure  sa    	 	 	
 	u111qU+++++r   c                     dfd}|                       |dd          d           d}|                       |dd          d           d S )NrE   c                     d| z  | S Nx=r   )r+   r   r,   s     r   r   z"TestCase.test_arguments.<locals>.f  s    %!U%%%%r   foor   zx=foofoo    barzx=        20r   )r   r   r+   r,   s      @r   test_argumentszTestCase.test_arguments  sn    	& 	& 	& 	& 	& 	5"~6662rN33333r   c                 <    d}|                      d| d           d S )N{   v:zv:123r   )r   rO   s     r   test_localszTestCase.test_locals  s)    ew/////r   c                     |                      t                    5  dt            d d d            d S # 1 swxY w Y   d S )Nr6  )r   	NameErrorrO   r4   s    r   test_missing_variablezTestCase.test_missing_variable  s    y)) 	 	LLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   377c                 >    G d d          }|                       |            dd           |                       |             d           |                       |             d           |                      d d           |                      d d           d S )Nc                       e Zd Zd ZdS ),TestCase.test_missing_format_spec.<locals>.Oc                     |sdS |S )N*r   r   s     r   r   z7TestCase.test_missing_format_spec.<locals>.O.__format__  s     3r   Nr   r   r   r   Or=    s#            r   r@  r+   r?  rG   3r   )r   r@  s     r   test_missing_format_specz!TestCase.test_missing_format_spec  s    	 	 	 	 	 	 	 	 	AACCS)))AACC3'''AACCC(((A#&&&AC(((((r   c                 z   |                      dt           d           |                      dt          d           d}|                      dt           d| d           |                      dt          d           |                      dt           d|d           |                     dt                      d S )	Ng:zg:global variablezg:'global variable'local variable l:z"g:global variable l:local variablez$g:global variable l:'local variable'zmodule 'unittest' from)r(   a_globalassertInunittest)r   a_locals     r   test_globalzTestCase.test_global  s    h*=>>>*h**,ABBB"4h44744=	? 	? 	?*h**.	0 	0 	06h66766?	A 	A 	A 	.8>>>>>r   c                    d}|                      d| d           |                      d|d           d}|                      d| d| d           |                      d|d           |                      d| d|d           d S )	Nzreally a localrD  zg:really a localzg:'really a local'rE  rF  z!g:really a local l:local variablez#g:really a local l:'local variable'r   )r   rG  rJ  s      r   test_shadowed_globalzTestCase.test_shadowed_global  s    #h*<===*h**,@AAA"4h44744<	> 	> 	>*h**-	/ 	/ 	/6h66766>	@ 	@ 	@ 	@ 	@r   c                 L    d }|                       |d           d           d S )Nc                 &    dt          |           z   S r/  r   r  s    r   r1  zTestCase.test_call.<locals>.foo  s    #a&&= r   r   zx=10r   )r   r1  s     r   	test_callzTestCase.test_call  s9    	! 	! 	! 	CCGGv.....r   c                 v    d}|                      d dz   d           |                      | dz   d           d S )Nrm   r   rG   000555r   )r   r,   s     r   test_nested_fstringszTestCase.test_nested_fstrings  sI    qF1H...qF1H.....r   c                 d    g d}d |D             }|                      t          d||z              d S )N)zfu''zuf''zFu''zfU''zUf''zuF''zufr''zurf''zfur''zfru''zrfu''zruf''zFUR''zFur''zfb''zfB''zFb''zFB''zbf''zbF''zBf''zBF''c                 :    g | ]}|                     d d          S )r   ")replace).0cases     r   
<listcomp>z9TestCase.test_invalid_string_prefixes.<locals>.<listcomp>  s&    TTTdll344TTTr   r   r   )r   single_quote_casesdouble_quote_casess      r   test_invalid_string_prefixesz%TestCase.test_invalid_string_prefixes  sa    & & &, UTASTTTK)9.1CC	E 	E 	E 	E 	Er   c                 J   |                      d d           |                      d d           |                      d d           |                      d d           |                      dd dD              d           |                      dd dD              d           d S )NrG   rA  zexpr=c                     i | ]\  }}||	S r   r   rY  r+   r,   s      r   
<dictcomp>z9TestCase.test_leading_trailing_spaces.<locals>.<dictcomp>      "?"?"?DAq1a"?"?"?r   ))rF   rE   zexpr={1: 2}c                     i | ]\  }}||	S r   r   ra  s      r   rb  z9TestCase.test_leading_trailing_spaces.<locals>.<dictcomp>  rc  r   r   r4   s    r   test_leading_trailing_spacesz%TestCase.test_leading_trailing_spaces  s    Q#&&&a3'''A#&&&A3'''A"?"?J"?"?"?AA&	( 	( 	(B"?"?J"?"?"?BB&	( 	( 	( 	( 	(r   c                     |                      ddk     d           |                      ddk     d           |                      ddk    d           |                      ddk    dd           d S )NrG   r7   Truez.3Trur   r4   s    r   test_not_equalzTestCase.test_not_equal  s~    
 	AqDF+++AqDV,,,AqDf---AqD/////r   c                 <    |                      ddk     d           d S )Nr   rF   Falser   r4   s    r   test_equal_equalzTestCase.test_equal_equal  s&     	AqDG,,,,,r   c                 &   |                      ddd           |                      ddd           |                      ddd           |                      ddd           |                      d d           |                      dd           |                      dd           |                      d d           |                      ddd	           |                     t          d
g d           |                     t          dg d           d S )NgQ	@z10.10z
      3.14z
3.14      r   z'a'za!rz!<10.10z
3.14!!!!!!r   )zf'{3!g}'zf'{3!A}'zf'{3!3}'zf'{3!G}'zf'{3!!}'zf'{3!:}'z	f'{3! s}'r   )zf'{x!s{y}}'z	f'{3!ss}'z
f'{3!ss:}'zf'{3!ss:s}'r   r4   s    r   test_conversionszTestCase.test_conversions  sT   D,777D**L999D**L999D**L999C3'''CU+++CU+++ 	EU+++ 	D**L999K)Q  	  	  	  	K)B  	  	  	  	  	 r   c                 B    |                      t          dg d           d S )Nr   )zf'' = 3z
f'{0}' = xz
f'{x}' = xr   r4   s    r   test_assignmentzTestCase.test_assignment%  s8    K):  	  	  	  	  	 r   c                 B    |                      t          dddg           d S )Nr   zdel f''z
del '' f''r   r4   s    r   test_delzTestCase.test_del,  s4    K)9&)	  	  	  	  	 r   c                 F   |                      t          dg d           |                      t          dg d           |                     d d           |                     d d           |                     dd dd	           |                     d
d dd           d S )Nz#f-string: single '}' is not allowed)zf'{{}'zf'{{}}}'zf'}'zf'x}'zf'x}x'z
f'\u007b}'zf'{3:}>10}'zf'{3:}}>10}'r   )zf'{3:{{>10}'zf'{3'zf'{3!'zf'{3:'zf'{3!s'zf'{3!s:'z	f'{3!s:3'zf'x{'zf'x{x'zf'{x'zf'{3:s'zf'{{{'zf'{{}}{'zf'{'zf'x{<'zf'x{>'zf'{i='r   r   rG   z>10z
}}}}}}}}}3rE   z
{{{{{{{{{2)r   r   r(   r4   s    r   test_mismatched_braceszTestCase.test_mismatched_braces2  s    K)N
 
 
	  	  	  	K)B  	  	  	 * 	C3'''C3'''As,777As,77777r   c                       fd} fd} fd} |dd            |dd            |dd            |dd            |dd            |dd           d S )Nc                 H    d}|  rd}nd}                     ||           d S Nr   rF   rE   r   r+   expectedflagr   s      r   test_fstringz2TestCase.test_if_conditional.<locals>.test_fstring_  s:    Dv T8,,,,,r   c                 H    d}|  rd}nd}                     ||           d S rw  r   rx  s      r   test_concat_emptyz7TestCase.test_if_conditional.<locals>.test_concat_emptyg  s:    Dy T8,,,,,r   c                 L    d}d|  rd}nd}                     ||           d S )Nr   r   rF   rE   r   rx  s      r   test_concat_non_emptyz;TestCase.test_if_conditional.<locals>.test_concat_non_emptyo  s>    Dazz T8,,,,,r   r%   rE   r   rF   r   )r   r{  r}  r  s   `   r   test_if_conditionalzTestCase.test_if_conditionalZ  s    
	- 	- 	- 	- 	-	- 	- 	- 	- 	-	- 	- 	- 	- 	- 	RS!"a   #q!!!b!$$$c1%%%%%r   c                     d}|                      | d           |                      | d           |                      | d           |                      | d           d S )Ntestz'test'r   r   s     r   test_empty_format_specifierz$TestCase.test_empty_format_specifier  ss    A(((A&)))AF+++AH-----r   c                 j   ddd}d}|                      |d          d           |                      |d          d           |                      ||          d           |                      d                    |          d           |                      d                    |          d           d S )	Nr  integer)r   r   r   r   z{d[a]})r   z{d[0]})r(   r)   )r   r   r   s      r   test_str_format_differencesz$TestCase.test_str_format_differences  s      AaDI...AcFh///AaDI...1--x8881--y99999r   c                 ~    |                      t          dddg           |                      t          dddg           d S )Nunsupportedzf'{(lambda: 0):x}'zf'{(0,):x}'zUnknown format codezf'{1000:j}')r   r   r   r4   s    r   test_errorszTestCase.test_errors  s]    I}2+	  	  	  	J(=++	 	 	 	 	r   c                    t                      5 }t          j                            |d          }t	          |dd          5 }|                    d           d d d            n# 1 swxY w Y   t          |d          \  }}}d d d            n# 1 swxY w Y   |                     |                    dd          |           d S )	Nzt.pywzutf-8)encodingzf"{a b}"ascii)PYTHONIOENCODINGbackslashreplace)	r   ospathjoinopenwriter   rH  encode)r   cwd	file_pathr   rv   stderrs         r   test_filename_in_syntaxerrorz%TestCase.test_filename_in_syntaxerror  sK   ZZ 	K3S&11Iiw777 $1
###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $0BIK K KLAq&		K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	i&&w0BCCVLLLLLs5   3BA$B$A(	(B+A(	,BBBc                 |    t          d          D ]+}|                     d| dt          |          z              ,d S )Ni  zi:)r   r(   r	   )r   r   s     r   	test_loopzTestCase.test_loop  sJ    t 	6 	6AX!XXtc!ff}5555	6 	6r   c                     dddd}|                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           d S )Ndquotesquoter2  )rW  r   r1  r   rW  r1  r   r   s     r   	test_dictzTestCase.test_dict  s      	af(333af(333AeH...AeH.....r   c                     |                      t          d          d           |                      t          d          d           d S )Nzf"\
"r%   zf"\")r(   r   r4   s    r   test_backslash_charzTestCase.test_backslash_char  sB     	i"---i"-----r   c           	      0   d|                      ddt                    z              |                      ddt                    z              |                      ddt                    z              |                      ddt                    z              |                      ddt                    z              d|                      dddt	          d          z              |                      d dt	          d          z              |                      dddt	          t                    d          z              |                      dddt	          t                    d          z              |                      dddt	          t                    d          z              d|                      d	d
z  dz   d           d}|                      d|dd           |                      ddd           |                      ddddd           d}|                      d|dd           |                      dd
d           |                      ddk     d            |                      ddk     d!           |                      ddk     d!           |                      ddk     d            |                      d"x d"           |                      d"           |                      d#x d"           |                      d#           |                      d$ d$           d%|                      d&d'           fd(}d|                       |d)*           d+           |                      d)           |                       |d,*           d)           |                      d,            G d- d.          }|                      d/ |            d0           |                      d/ |            d0           |                      d/ |             d1           |                      d/ |            d2d3           |                      d/ |            d4d5           |                      d/ |            dd6           |                     t          t          d7           d8|                      d9d:d9t                    z   d:z              |                      d;d:d;t                    z   d:z              |                      d<d:d<t                    z   d:z              |                      d=d:d=t                    z   d:z              d S )>NzA stringr0  zx =g	@z.2fr%   z^20	   z3*x+15=rG   r~   z	3*x+15=42gffffff?@u   tenπ=u   tenπ=31.40u   "Σ"=u   Σu	   "Σ"='Σ'z3.1415=go!	@z.1fz*^20z*****3.1415=3.1*****u   πu   alpha α pi=u	    ω omegau   alpha α pi='π' ω omegaz
3
=z
3
=3r   rF   rk  rg  5rm   =   =10
        20c                     }| |S r   r   )r   oldxr+   s     r   r   z)TestCase.test_debug_conversion.<locals>.f  s    DAKr   z3=)r   r   r7   c                       e Zd Zd Zd ZdS ))TestCase.test_debug_conversion.<locals>.Cc                     d| S )NzFORMAT-r   )r   r   s     r   r   z4TestCase.test_debug_conversion.<locals>.C.__format__  s    $}}$r   c                     dS )NREPRr   r4   s    r   __repr__z2TestCase.test_debug_conversion.<locals>.C.__repr__  s    vr   N)r   r   r    r   r  r   r   r   Cr    s2        % % %    r   r  zC()=zC()=REPRzC()=FORMAT-r   zC()=FORMAT- r+   zC()=FORMAT-xzC()=********REPR********zf'{C=]'r1  zXx=r  zXx  =zXx=  zXx  =  )r(   reprr	   r  r)   r   r   r   )r      tenπpir   r  r+   s        @r   test_debug_conversionzTestCase.test_debug_conversion  s*   A$a.111A5477?333AD3q66M222AD477N333AD588O444AdVAu-=-=&=>>>A4&B--#7888Avd1ggu/E/E(EFFFAvc!ffe/D/D(DEEEAveAhh/F/F(FGGGAaCF{333 E-888 	D]333 	,v,,,335KLLL 3R3335PQQQ 	   	 	 	 	AqDG,,,AqDF+++AqDF+++AqDG,,,VQ,,,C   TQc***AC3''' 	A\222	 	 	 	 	
 AAIII---D!!!AAFFFd+++A	 	 	 	 	 	 	 	 	AACCJ///AACCj111AACC]333AACCn555AACCn555)AACC)))+EFFF+tY777 QE$q''M#$5666 	Qgd1ggoc&9:::Qgd1ggoc&9:::Q	$q''(9#(=>>>>>r   c                     d}|                      |dd           |                      dx} d           |                      |d           d S )Nr  r  r  r   r  r   r   s     r   test_walruszTestCase.test_walrus$  s]     	A\222 	UQt,,,Br   c                     |                      t          d          5  t          ddd           d d d            d S # 1 swxY w Y   d S )Nr   z
f'{a $ b}'?r:   )r   r   r=   r4   s    r   !test_invalid_syntax_error_messagez*TestCase.test_invalid_syntax_error_message.  s    ##K1KLL 	/ 	/L#v...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   ;??c                     t          j        d          }|                     t          |          5  dd d d d            d S # 1 swxY w Y   d S )NzCannot specify ',' with ','.rF   z,,reescaper   r   r   	error_msgs     r   (test_with_two_commas_in_format_specifierz1TestCase.test_with_two_commas_in_format_specifier2      I<==	##J	:: 	 	III	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   AA	Ac                     t          j        d          }|                     t          |          5  dd d d d            d S # 1 swxY w Y   d S )NzCannot specify '_' with '_'.rF   __r  r  s     r   ,test_with_two_underscore_in_format_specifierz5TestCase.test_with_two_underscore_in_format_specifier7  r  r  c                     t          j        d          }|                     t          |          5  dd d d d            d S # 1 swxY w Y   d S )N Cannot specify both ',' and '_'.rF   z,_r  r  s     r   8test_with_a_commas_and_an_underscore_in_format_specifierzATestCase.test_with_a_commas_and_an_underscore_in_format_specifier<      I@AA	##J	:: 	 	III	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r  c                     t          j        d          }|                     t          |          5  dd d d d            d S # 1 swxY w Y   d S )Nr  rF   z_,r  r  s     r   7test_with_an_underscore_and_a_comma_in_format_specifierz@TestCase.test_with_an_underscore_and_a_comma_in_format_specifierA  r  r  c                 h   t          j        d          }|                     t          |          5  t	          ddd           d d d            n# 1 swxY w Y   t          j        d          }|                     t          |          5  t	          ddd           d d d            d S # 1 swxY w Y   d S )Nz"cannot use starred expression herezf'{*a}'r  r:   z)cannot use double starred expression herezf'{**a}')r  r  r   r   r=   r  s     r   )test_syntax_error_for_starred_expressionsz2TestCase.test_syntax_error_for_starred_expressionsF  s-   IBCC	##K;; 	, 	,IsF+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, IIJJ	##K;; 	- 	-JV,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s#   AAAB''B+.B+N)Hr   r   r    r   r-   rC   r]   rg   rk   rp   rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r%  r,  r3  r7  r:  rB  rK  rM  rP  rT  r^  re  ri  rl  rn  rp  rr  rt  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r      sJ         = = =6" " "04 4 4>26 26 26h+. +. +.Z@5 @5 @5D2 2 2.MM MM MM^32 32 32j% % %% % %' ' '     $ $ $
     E E E.!  !  ! F     >      0 0 02#  #  # J	, 	, 	,8  8  8 t     &6 6 654 54 54n     &
  
  
 W W W  

  
  
 	( 	( 	(7 7 7
I 
I 
I3 3 3, , ,4 4 40 0 0  ) ) )? ? ?@ @ @/ / // / /
E E E6	( 	( 	(0 0 0- - -     B          &8 &8 &8P$& $& $&L. . .	: 	: 	:	 	 	M M M6 6 6	/ 	/ 	/. . .]? ]? ]?P     / / /  
  
  
  
- - - - -r   r   __main__)r;   r  r  r&   r   rI  test.support.os_helperr   test.support.script_helperr   rG  r   r   mainr   r   r   <module>r     s    


 				 				    + + + + + + < < < < < <q- q- q- q- q-x  q- q- q-f) zHMOOOOO r   