HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_fstring.cpython-37.pyc
B

��g��@sJddlZddlZddlZddlZdZGdd�dej�ZedkrFe��dS)�Nzglobal variablec@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkdl�Z8dmdn�Z9dodp�Z:dqdr�Z;dsS)t�TestCasecCsJxD|D]<}|j|d��&|�||��t|�WdQRXWdQRXqWdS)N)�str)ZsubTest�assertRaisesRegex�eval)�selfZexception_typeZregexZ
error_stringsr�r�-/usr/local/lib/python3.7/test/test_fstring.py�assertAllRaises
zTestCase.assertAllRaisecCs�Gdd�d�}|�}|�}t�dd�|�|_|�|�t|��|�|�d�|�t|�t|��|�|�d�d�|�|�d�d�|�t|��|d�d�|�t|��|d�d�dS)Nc@seZdZdd�ZdS)z(TestCase.test__format__lookup.<locals>.XcSsdS)N�classr)r�specrrr�
__format__sz3TestCase.test__format__lookup.<locals>.X.__format__N)�__name__�
__module__�__qualname__rrrrr�XsrcSsdS)N�instancer)rrrrr�<lambda>!�z/TestCase.test__format__lookup.<locals>.<lambda>r
�r)�types�
MethodTyper�assertEqual�format�type)rr�x�yrrr�test__format__lookupszTestCase.test__format__lookupcCsRGdd�d�}|�}d}t�|�}t|dd�}|�|j�t|�|�|j�dS)Nc@seZdZdd�Zdd�ZdS)zTestCase.test_ast.<locals>.XcSs
d|_dS)NF)�called)rrrr�__init__4sz%TestCase.test_ast.<locals>.X.__init__cSs
d|_dS)NT�)r)rrrr�__call__6sz%TestCase.test_ast.<locals>.X.__call__N)r
rrrr rrrrr3srz
a = 10
f'{a * x()}'r�exec)�ast�parse�compileZassertFalserr!Z
assertTrue)rrr�expr�t�crrr�test_ast1s
zTestCase.test_astcCs�d}t�|�}|�t|�tj�|�t|j�d�|�t|jd�tj�|�|jdjd�|�t|jd�tj	�|�t|jdj
�tj�|�t|jdj
j�d�|�t|jdj
jd�tj
�|�|jdjd�|�|jdj
jd�|�|jdj
jdjd�|jdj
jdj
}|�t|�tj�|�t|j�tj�|�t|j�tj�|�t|j�tj�|�|jd�|�|jjd�|�|jjd�|�|jd�|�|jjd�|�|jjd�dS)Nz
a = 10
f'{a * x()}'�r���)r"r#rr�Module�len�body�Assign�lineno�Expr�value�	JoinedStr�values�FormattedValue�BinOp�left�Name�op�Mult�right�Call�
col_offset)rr%r&�binoprrr�test_ast_line_numbersIs0
 zTestCase.test_ast_line_numberscCs^d}t�|�}|�t|�tj�|�t|j�d�|�t|jd�tj�|�t|jdj�tj	�|�|jdj
d�|�t|jd�tj�|�t|jdj�tj	�|�t|jdjj�d�|�t|jdjjd�tj�|�t|jdjjd�tj
�|�t|jdjjd�tj�|�t|jdjjd�tj
�|�|jdj
d�|�|jdjj
d�|�|jdjjdj
d�|�|jdjjdj
d�|�|jdjjdj
d�|�|jdjjdj
d�|jdjjdj}|�t|�tj�|�t|j�tj�|�t|j�tj�|�t|j�tj�|�|j
d�|�|jj
d�|�|jj
d�|�|jd�|�|jjd�|�|jjd�|jdjjdj}|�t|�tj�|�t|j�tj�|�t|j�tj�|�t|j�tj�|�|j
d�|�|jj
d�|�|jj
d�|�|jd	�|�|jjd	�|�|jjd
�dS)Nz8
f'no formatted values'
f'eggs {a * x()} spam {b + y()}'r)rr*rr+����)r"r#rrr-r.r/r2r3r4r1r5�Strr6r7r8r9r:r;r<r=r>ZAdd)rr%r&Zbinop1Zbinop2rrr�.test_ast_line_numbers_multiple_formattedvalueshsT
    z7TestCase.test_ast_line_numbers_multiple_formattedvaluescCs�d}t�|�}|�t|�tj�|�t|j�d�|�t|jd�tj�|�|jdjd�|�t|jd�tj	�|�t|jdj
�tj�|�t|jdj
j�d�|�t|jdj
jd�tj
�|�|jdjd�|�|jdj
jd�|�|jdj
jdjd�|jdj
jdj
}|�t|�tj�|�t|j�tj�|�t|j�tj�|�t|j�tj�|�|jd�|�|jjd�|�|jjd�|�|jd�|�|jjd�|�|jjd�|�t|jj�d�|�t|jjd�tj�|�t|jjd�tj
�|�t|jjd�tj�|�|jjdjd�|�|jjdjd�|�|jjdjd�|jjdj
}|�t|�tj�|�|jd�|�|jd�dS)Nz
a = 10
f'{a * f"-{x()}-"}'r)rr*r+r,�)r"r#rrr-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r>rEr=)rr%r&r?Zcallrrr�test_ast_line_numbers_nested�sF
 z%TestCase.test_ast_line_numbers_nestedcCs>d}t�|�}|�t|�tj�|�t|j�d�|�t|jd�tj�|�|jdjd�|�t|jd�tj	�|�t|jdj
�tj�|�t|jdj
j�d�|�t|jdj
jd�tj
�|�t|jdj
jd�tj�|�t|jdj
jd�tj
�|�t|jdj
jd�tj�|�t|jdj
jd�tj
�|�|jdjd�|�|jdj
jd�|�|jdj
jdjd�|�|jdj
jdjd�|�|jdj
jdjd�|�|jdj
jdjd�|�|jdj
jdjd�|jdj
jdj
}|�t|�tj�|�t|j�tj�|�t|j�tj�|�t|j�tj�|�|jd�|�|jjd�|�|jjd�|�|jd�|�|jjd�|�|jjd�|jdj
jdj
}|�t|�tj�|�t|j�tj�|�t|j�tj�|�t|j�tj�|�|jd�|�|jjd�|�|jjd�|�|jd�|�|jjd�|�|jjd�|jdj
jdj
}|�t|�tj�|�t|j�tj�|�t|j�tj�|�t|j�tj�|�|jd�|�|jjd�|�|jjd�|�|jd�|�|jjd�|�|jjd�d	S)
z|Duplicate expression

        NOTE: this is currently broken, always sets location of the first
        expression.
        z)
a = 10
f'{a * x()} {a * x()} {a * x()}'
r)rr*�r+rr,N)r"r#rrr-r.r/r0r1r2r3r4r5r6rEr7r8r9r:r;r<r=r>)rr%r&r?rrr�*test_ast_line_numbers_duplicate_expression�sl	
     z3TestCase.test_ast_line_numbers_duplicate_expressioncCs�d}t�|�}|�t|�tj�|�t|j�d�|�t|jd�tj�|�|jdjd�|�t|jd�tj	�|�t|jdj
�tj�|�t|jdj
j�d�|�t|jdj
jd�tj
�|�t|jdj
jd�tj�|�t|jdj
jd�tj
�|�|jdjd�|�|jdj
jd�|�|jdj
jdjd�|�|jdj
jdjd�|�|jdj
jdjd�|�|jdjd�|�|jdj
jd�|�|jdj
jdjd�|�|jdj
jdjd�|�|jdj
jdjd�|jdj
jdj
}|�t|�tj�|�t|j�tj�|�t|j�tj�|�t|j�tj�|�|jd�|�|jjd�|�|jjd	�|�|jd�|�|jjd�|�|jjd
�dS)Nz?
a = 10
f'''
  {a
     *
       x()}
non-important content
'''
r)rr*r+rA���r�r,)r"r#rrr-r.r/r0r1r2r3r4r5rEr6r>r7r8r9r:r;r<r=)rr%r&r?rrr�'test_ast_line_numbers_multiline_fstring
sB

   z0TestCase.test_ast_line_numbers_multiline_fstringcCs,dd�}|�|j�dd�}|�|j�dS)NcSsddS)NzNot a docstringrrrrr�fAsz"TestCase.test_docstring.<locals>.fcSsddS)NzNot a docstringrrrrr�gDsz"TestCase.test_docstring.<locals>.g)ZassertIsNone�__doc__)rrNrOrrr�test_docstring@szTestCase.test_docstringc	Cs&|�td��t�d�WdQRXdS)Nzmalformed node or stringzf'x')r�
ValueErrorr"Zliteral_eval)rrrr�test_literal_evalIszTestCase.test_literal_evalcCs<dg}d}t�|�}t|dd�}t|�|�|dd�dS)Nrzx[0] = 'foo' f'{3}'r!rZfoo3)r"r#r$r!r)rrr%r&r'rrr�test_ast_compile_time_concatMs
z%TestCase.test_ast_compile_time_concatcCs|�tdddg�dS)Nz&cannot mix bytes and nonbytes literalszf'' b''zb'' f'')r	�SyntaxError)rrrr�test_compile_time_concat_errorsVsz(TestCase.test_compile_time_concat_errorscCs(|��d�|�dd�|�dd�dS)Nr�a� )r)rrrr�test_literal]szTestCase.test_literalcCs|�tdddddg�dS)Nzf-string: unterminated stringzf'{"x'zf'{"x}'zf'{("x'zf'{("x}')r	rU)rrrr�test_unterminated_stringbs
z!TestCase.test_unterminated_stringcCs|�tddg�dS)Nzf-string: mismatchedzf'{((}')r	rU)rrrr�test_mismatched_parensjszTestCase.test_mismatched_parenscCsr|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�dd�|�d	d	�|�d
d
�|�dd�|�dd�|�d
d
�|�dd�|�dd�|�dd�|�dd��d�|�dd��d�|�dd��d�|�dd��d�|�d�d�d�|�d�d�d�|�d�d�d�|�d�d�d�|�d�d�|�tddg�dS) N�{za{z{bza{b�}za}z}bza}bz{}za{}z{b}z{}cza{b}za{}cz{b}cza{b}c�
z{10z}10z}{z}{10z}a{z}a{10z10{z10}z10}{z}a{}z10}a{}z{{}}zunhashable typezf'{ {{}} }')rr	�	TypeError)rrrr�test_double_bracesos6zTestCase.test_double_bracescCs�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�|�tddg�dS)N�defzabc## Zghizabc## defghi�abcZ	abcdefghi�4z
abcdefghidef z{x}z{x}defz{xz{xdefz{{x}}z{{x}}defz{{xz{{xdefzx}}zx}}defzdefx}}�2Zdef2�1Z1def2Z1def�-zdef-defrzf-string: expecting '}'z
f'{3' f'}')rr	rU)rrrrr�test_compile_time_concat�s6z!TestCase.test_compile_time_concatcCsBddi}|�d�d�|�|d�d�|�tdddddg�dS)N�#�hashz+f-string expression part cannot include '#'zf'{1#}'z	f'{3(#)}'zf'{#}'zf'{)#}')rr	rU)r�drrr�
test_comments�szTestCase.test_commentscCs�ddd�}d}d}x.tdd�D] }|�t||��|d|�qW|�t|d	�d
�|dd�|dd
�}|�t|�|dd�dd}|�t|�d�dS)NrcSsdd||dS)Nzf'z{x} �'r)�nZextrarrr�
build_fstr�sz2TestCase.test_many_expressions.<locals>.build_fstrrr*�irX��i��z{x:{width}} �zf'{1}' 'x' 'y'iA1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy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y1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy1xy)r)�rangerr)rrnr�width�i�srrr�test_many_expressions�s
  
zTestCase.test_many_expressionsc	Cs�d}d}t�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�|�ddd	�d��d
�|�dd�dd
�d���d
�|�ddd�dd
�d��d�|�dd�dd	�dd���d�|�dddddik�oH|�d��d
�|�tddg�|�tddg�|�tddg�|�tddg�dS)Nr^rz12.34567zresult: �.zresult:      12.35�0rer*rrh�0xz
       0xari����rfz
      -0xar+rIzf-string: expecting '}'zf'{"s"!r{":10"}}'zinvalid syntaxzf'{4:{/5}}'z'f-string: expressions nested too deeplyz,f'result: {value:{width:{0}}.{precision:1}}'z&f-string: invalid conversion characterzf'{"s"!{"r"}}')�decimalZDecimalrr	rU)rruZ	precisionr3rrr�!test_format_specifier_expressions�s*
"&& &z*TestCase.test_format_specifier_expressionscCs.Gdd�d�}|�}|�|�d|��d�dS)Nc@seZdZdd�Zdd�ZdS)z*TestCase.test_side_effect_order.<locals>.XcSs
d|_dS)Nr)rv)rrrrr�sz3TestCase.test_side_effect_order.<locals>.X.__init__cSs|jd7_t|j�S)Nr*)rvr)rrrrrrsz5TestCase.test_side_effect_order.<locals>.X.__format__N)r
rrrrrrrrr�srrXz1 2)r)rrrrrr�test_side_effect_order�szTestCase.test_side_effect_ordercCsJ|�tddddddddd	d
ddd
dddddddg�|�tdddg�dS)Nz&f-string: empty expression not allowedzf'{}'z
f'{ }'f' {} 'zf'{!r}'zf'{ !r}'zf'{10:{ }}'zf' { } 'z
f'''{	
}'''zf'{!x}'z	f'{ !xr}'zf'{!x:}'z	f'{!x:a}'z
f'{ !xr:}'zf'{ !xr:a}'zf'{!}'zf'{:}'zf'{!'zf'{!s:'zf'{:'zf'{:x'zinvalid character in identifieruf'''{ }'''� )r	rU)rrrr�test_missing_expressions.z TestCase.test_missing_expressioncCsD|�d�d�|�tdddg�|�tddg�|�tddg�dS)	N)r+z(3,)zinvalid syntaxzf'{,}'zf-string: expecting '}'z
f'{3)+(4}'z!EOL while scanning string literalzf'{
}')rr	rU)rrrr�test_parens_in_expressions0sz#TestCase.test_parens_in_expressionsc	Cs�|�dd�|�dd�|�dd�|�d�d�d�|�d�dd��d�|�dd��d�|�dd�|�d	d	�|�d	d	�|�d�d�d
�|�d�dd��d�|�dd��d�|�dd�|�d
d
�|�d
d
�|�d�d�d
�|�d�dd��d�|�dd��d�|�dd�|�d�d�d
�|�d�dd��d�|�dd��d�|�d
d
�|�dd�|�dd�|�dd�|�dd�|�dd�|�d�d�d�|�d�dd��d�|�dd��d�|�dd�|�dd�|�dd�|�t��td�}WdQRX|�|d�|�dd��d�|�dd��d�d}|�dd�|�d|��d�|�d|��d�|�dd�dS)N�	z\tr)z2	r+z2	3z	3uΔz\u0394u2Δu2Δ3uΔ3z
\U00000394rXz\x20z2 z2 3z 3z	f'\{6*7}'z\42�\�*Zspam�&z\Nz\Nspamz\&)rZassertWarns�DeprecationWarningr)rr3Z	AMPERSANDrrr�test_backslashes_in_string_partDsXz(TestCase.test_backslashes_in_string_partc
Cs|�tdddddddg�dS)Nzi\(unicode error\) 'unicodeescape' codec can't decode bytes in position .*: malformed \\N character escapezf'\N'zf'\N{'z f'\N{GREEK CAPITAL LETTER DELTA'z'\N'z'\N{'z'\N{GREEK CAPITAL LETTER DELTA')r	rU)rrrr�%test_misformed_unicode_character_name{sz.TestCase.test_misformed_unicode_character_namecCs"|�tddddddddd	g�dS)
Nz3f-string expression part cannot include a backslashz
f'{\'a\'}'zf'{\t3}'zf'{\}'zrf'{\'a\'}'z	rf'{\t3}'zrf'{\}'zrf'{"\N{LEFT CURLY BRACKET}"}'zf'{\n}')r	rU)rrrr�&test_no_backslashes_in_expression_part�sz/TestCase.test_no_backslashes_in_expression_partcCs4|�dd�|�dd�|�dd�|�dd�dS)z@
        Only literal curly braces begin an expression.
        z{1+1}z{1+1N)r)rrrr�test_no_escapes_for_braces�sz#TestCase.test_no_escapes_for_bracescCs |�d�d�|�d�d�dS)Nrrzr,�7)r)rrrr�test_newlines_in_expressions�sz%TestCase.test_newlines_in_expressionscsjd�|��fdd�d��d�|��fdd�d�d�d�|��fd	d�d�d�d
�|�tddg�dS)
NrIcs�|S)Nr)r)rrrr�rz&TestCase.test_lambda.<locals>.<lambda>�8z'88888'cs�|S)Nr)r)rrrr�rZ10z
'88888'   cs�|S)Nr)r)rrrr�rz
88888     zunexpected EOF while parsingzf'{lambda x:x}')rr	rU)rr)rr�test_lambda�szTestCase.test_lambdacCs$dd�}|d�}|�t|�d�dS)Ncssd|dV��dS)Nzy:r)r)rrrr�fn�szTestCase.test_yield.<locals>.fnrrA)r�next)rr�rOrrr�
test_yield�szTestCase.test_yieldcCs>dd�}|d�}t|�}|�|d�d�|�|�d�d�dS)Nc3sd�fdd�V��VdS)Nzx:cs�|S)Nr)rv)rrrr�rz6TestCase.test_yield_send.<locals>.fn.<locals>.<lambda>r)rr)rrr��sz$TestCase.test_yield_send.<locals>.fnr^r�(�stringzx:string)r�r�send)rr�rOZ
the_lambdarrr�test_yield_send�s
zTestCase.test_yield_sendcCst|�d�d�|�d�d�|�d�d�|�d�d�|�d�d�|�d�d�|�d�d�|�d�d�dS)Nrzeric'szxeric"syzxeric"szeric"sy)r)rrrr�+test_expressions_with_triple_quoted_strings�sz4TestCase.test_expressions_with_triple_quoted_stringscCs�d}d}|�|�|��d�|�d|�|��d�|�|�d|��d�|�|�|�d�d�|�d|�d|��d	�|�d|�|�d�d
�|�|�d|�d�d�|�d|�d|�d�d
�dS)N�brbZ98abcrZX98abcZ98XabcZ98abcX�YZX98YabcZX98abcYZ98XabcY�ZZX98YabcZ)r)rrrrrr�test_multiple_vars�szTestCase.test_multiple_varscCs0dd�}|�|d��d�|�|d��d�dS)Ncs�fdd�}|S)Ncs
d���S)Nzx:rr)rrr�inner�sz3TestCase.test_closure.<locals>.outer.<locals>.innerr)rr�r)rr�outer�sz$TestCase.test_closure.<locals>.outerZ987zx:987r,zx:7)r)rr�rrr�test_closure�szTestCase.test_closurecs<d��fdd�}|�|dd�d�d}|�|dd�d�dS)	Nr)csd|�|���S)Nzx=r)rru)rrrrN�sz"TestCase.test_arguments.<locals>.f�foor^zx=foofoo    �barzx=        20)r)rrNrr)rr�test_arguments�s
zTestCase.test_argumentscCsd}|�d|��d�dS)N�{zv:zv:123)r)rr3rrr�test_locals�szTestCase.test_localsc	Cs$|�t��dt��WdQRXdS)Nzv:)ZassertRaises�	NameErrorr3)rrrr�test_missing_variable�szTestCase.test_missing_variablecCsfGdd�d�}|�|�d�d�|�|��d�|�|���d�|�d��d�|�d��d�dS)Nc@seZdZdd�ZdS)z,TestCase.test_missing_format_spec.<locals>.OcSs|sdS|S)N�*r)rrrrrr�sz7TestCase.test_missing_format_spec.<locals>.O.__format__N)r
rrrrrrr�O�sr�rr�r+�3)r)rr�rrr�test_missing_format_spec�sz!TestCase.test_missing_format_speccCs||�dt��d�|�dt��d�d}|�dt�d|��d�|�dt��d�|�dt�d|��d�|�dt��dS)	Nzg:zg:global variablezg:'global variable'zlocal variablez l:z"g:global variable l:local variablez$g:global variable l:'local variable'zmodule 'unittest' from)r�a_globalZassertIn�unittest)r�a_localrrr�test_globalszTestCase.test_globalcCsrd}|�d|��d�|�d|��d�d}|�d|�d|��d�|�d|��d�|�d|�d|��d�dS)	Nzreally a localzg:zg:really a localzg:'really a local'zlocal variablez l:z!g:really a local l:local variablez#g:really a local l:'local variable')r)rr�r�rrr�test_shadowed_globalszTestCase.test_shadowed_globalcCsdd�}|�|d��d�dS)NcSsdt|�S)Nzx=)r)rrrrr�"szTestCase.test_call.<locals>.foor^zx=10)r)rr�rrr�	test_call!szTestCase.test_callcCs0d}|�d�d�d�|�|�d�d�dS)NrIrr+Z000Z555)r)rrrrr�test_nested_fstrings'szTestCase.test_nested_fstringscCs>|�tddddddddd	d
ddd
ddddddddddg�dS)Nzunexpected EOF while parsingzfu''zuf''zFu''zfU''zUf''zuF''zufr''zurf''zfur''zfru''zrfu''zruf''zFUR''zFur''zfb''zfB''zFb''zFB''zbf''zbF''zBf''zBF'')r	rU)rrrr�test_invalid_string_prefixes,s.z%TestCase.test_invalid_string_prefixescCst|�d�d�|�d�d�|�d�d�|�d�d�|�ddd�dD���d�|�ddd�dD���d�dS)	Nr+r�zexpr=cSsi|]\}}||�qSrr)�.0rrrrr�
<dictcomp>Lsz9TestCase.test_leading_trailing_spaces.<locals>.<dictcomp>))r*r)zexpr={1: 2}cSsi|]\}}||�qSrr)r�rrrrrr�Ns)r)rrrr�test_leading_trailing_spacesFsz%TestCase.test_leading_trailing_spacescCsP|�ddk�d�|�ddk��d�|�ddk�d�|�ddkd�d�dS)Nr+r�Truez.3ZTru)r)rrrr�test_not_equalQszTestCase.test_not_equalcCs�|�dd�d�|�dd�d�|�dd�d�|�dd�d�|�d�d�|�d�d�|�d�d�|�d�d�|�dd�d	�|�td
ddd
ddddg�|�tdddddg�dS)Ng��Q�	@z10.10z
      3.14z
3.14      rWz'a'za!rz!<10.10z
3.14!!!!!!z&f-string: invalid conversion characterzf'{3!g}'zf'{3!A}'zf'{3!3}'zf'{3!G}'zf'{3!!}'zf'{3!:}'z	f'{3! s}'zf-string: expecting '}'zf'{x!s{y}}'z	f'{3!ss}'z
f'{3!ss:}'zf'{3!ss:s}')rr	rU)rrrr�test_conversions[s,zTestCase.test_conversionscCs|�tddddg�dS)Nzinvalid syntaxzf'' = 3z
f'{0}' = xz
f'{x}' = x)r	rU)rrrr�test_assignment|szTestCase.test_assignmentcCs|�tdddg�dS)Nzinvalid syntaxzdel f''z
del '' f'')r	rU)rrrr�test_del�szTestCase.test_delcCs�|�tddddddddd	g�|�td
ddd
dddddddddddg�|�d�d�|�d�d�|�dd�d��d�|�dd�d��d�dS) Nz#f-string: single '}' is not allowedzf'{{}'zf'{{}}}'zf'}'zf'x}'zf'x}x'z
f'\u007b}'zf'{3:}>10}'zf'{3:}}>10}'zf-string: expecting '}'zf'{3:{{>10}'zf'{3'zf'{3!'zf'{3:'zf'{3!s'zf'{3!s:'z	f'{3!s:3'zf'x{'zf'x{x'zf'{x'zf'{3:s'zf'{{{'zf'{{}}{'zf'{'r\r]r+z>10z
}}}}}}}}}3r)z
{{{{{{{{{2)r	rUr)rrrr�test_mismatched_braces�s8zTestCase.test_mismatched_bracescsd�fdd�}�fdd�}�fdd�}|dd�|d	d
�|dd�|d	d
�|dd
�|d	d
�dS)Ncs$d}|�rd}nd}��||�dS)Nrr*r))r)r�expected�flag)rrr�test_fstring�s
z2TestCase.test_if_conditional.<locals>.test_fstringcs$d}|�rd}nd}��||�dS)Nrr*r))r)rr�r�)rrr�test_concat_empty�s
z7TestCase.test_if_conditional.<locals>.test_concat_emptycs(d}d|��rd}nd}��||�dS)NrrXr*r))r)rr�r�)rrr�test_concat_non_empty�s

z;TestCase.test_if_conditional.<locals>.test_concat_non_emptyrr)rXr*r)rr�r�r�r)rr�test_if_conditional�s




zTestCase.test_if_conditionalcCsFd}|�|�d�|�|��d�|�|��d�|�|��d�dS)NZtestz'test')r)rrrrr�test_empty_format_specifier�s
z$TestCase.test_empty_format_specifiercCspddd�}d}|�|d�d�|�|d�d�|�||�d�|�dj|d�d�|�dj|d�d�dS)	Nr�Zinteger)rWrrrWz{d[a]})rjz{d[0]})rr)rrjrWrrr�test_str_format_differences�sz$TestCase.test_str_format_differencescCs|�tdddg�dS)Nzinvalid syntaxz	f'{a[4)}'z	f'{a(4]}')r	rU)rrrr�test_invalid_expressions�sz!TestCase.test_invalid_expressionscCs(|�tdddg�|�tdddg�dS)NZunsupportedzf'{(lambda: 0):x}'zf'{(0,):x}'zUnknown format codezf'{1000:j}')r	r_rR)rrrr�test_errors�szTestCase.test_errorscCs0x*td�D]}|�d|��dt|��q
WdS)Ni�zi:)rtrr)rrvrrr�	test_loop�szTestCase.test_loopcCsXdddd�}|�|d�d�|�|d�d�|�|d�d�|�|d�d�dS)NZdquoteZsquoter�)�"rlr�rlr�r�)r)rrjrrr�	test_dict�szTestCase.test_dictcCs$|�td�d�|�td�d�dS)Nzf"\
"rzf"\
")rr)rrrr�test_backslash_charszTestCase.test_backslash_charN)<r
rrr	rr(r@rFrHrJrMrQrSrTrVrYrZr[r`rgrkrxr}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�r�r�r�r�r�r�r�r�rrrrrsr2+E6		#%(7
				

!%&r�__main__)r"rr|r�r�rr
�mainrrrr�<module>s