
    6bh                         d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
Z
 G d d	e
j                        Zed
k(  r e
j                          yy)z/test script for a few new invalid token catches    N)BOM_UTF8)support)	os_helper)script_helper)warnings_helperc                       e Zd Zd Zd Zd Z ej                  e      d        Z	d Z
 ej                  ej                   d      d        Zy	)
EOFTestCasec                    d}dD ]y  }| j                  t              5 }t        | d       d d d        | j                  t	        j
                        |       | j                  |j
                  j                  d       { y # 1 sw Y   WxY w)NzCunterminated string literal (detected at line 1) (<string>, line 1))'"zthis is a test                   )assertRaisesSyntaxErrorevalassertEqualstr	exceptionoffset)selfexpectquotecms       7/opt/python-3.12.12/usr/lib/python3.12/test/test_eof.pytest_EOF_single_quotez!EOFTestCase.test_EOF_single_quote   sx    V E"";/2% !   0 S.7R\\00!4 !//s   BB	c                    d}| j                  t              5 }t        d       d d d        | j                  t	        j
                        |       | j                  |j
                  j                  d       | j                  |j
                  j                  d       | j                  t              5 }t        dj                                d d d        | j                  t	        |j
                        |       | j                  |j
                  j                  d       | j                  |j
                  j                  d       | j                  t              5 }t        t        dj                         z          d d d        | j                  t	        |j
                        |       | j                  |j
                  j                  d       | j                  |j
                  j                  d       | j                  t              5 }t        dj                  d             d d d        | j                  t	        |j
                        d       | j                  |j
                  j                  d       | j                  |j
                  j                  d       y # 1 sw Y   |xY w# 1 sw Y   xY w# 1 sw Y   ?xY w# 1 sw Y   xY w)NzQunterminated triple-quoted string literal (detected at line 3) (<string>, line 1)   ä = '''thîs is 
a 
testu   ä = '''thîs is    *   # coding: latin1
ä = '''thîs is 
a 
testlatin1zQunterminated triple-quoted string literal (detected at line 4) (<string>, line 2))
r   r   r   r   r   r   textr   encoder   r   r   r   s      r   	test_EOFSzEOFTestCase.test_EOFS   s   e{+r23 ,R\\*F3**,?@,,a0{+r299;< ,R\\*F3**,?@,,a0{+r=DDFFG ,R\\*F3**,?@,,a0{+rDKKHUV ,R\\*,  	A**,?@,,a0- ,+ ,+ ,+ ,+s/   J2J+!J8	KJ(+J58KKc                    d}t        j                         5 }t        j                  |dd      }t        j                  dd|      \  }}}|j                         j                         }| j                  |dd  g d       t        j                  |ddj                               }t        j                  dd|      \  }}}|j                         j                         }| j                  |dd  g d       t        j                  |dt        dj                         z         }t        j                  dd|      \  }}}|j                         j                         }| j                  |dd  g d       t        j                  |ddj                  d	            }t        j                  dd|      \  }}}|j                         j                         }| j                  |dd  g d
       d d d        y # 1 sw Y   y xY w)Nz(<string>, line 1)foor   -Xutf8)       ä = '''thîs is 	        ^zKSyntaxError: unterminated triple-quoted string literal (detected at line 3)r   r   )r)   r*   zKSyntaxError: unterminated triple-quoted string literal (detected at line 4)
r   temp_dirr   make_scriptassert_python_failuredecode
splitlinesr   r!   r   )r   r   r,   	file_namercouterrs          r   test_EOFS_with_filezEOFTestCase.test_EOFS_with_file/   s   &!X%11(E2SUI(>>tVYWLBS**,))+CSX (_ `
 &11(E2S2Z2Z2\^I(>>tVYWLBS**,))+CSX (_ `
 &11(E2:=^=e=e=g2giI(>>tVYWLBS**,))+CSX (_ `
 &11(E2e2l2lmu2vxI(>>tVYWLBS**,))+CSX (_ `A "!!s   GG//G8)categoryc                     d}| j                  t              5 }t        ddd       d d d        | j                  t	        j
                        |       y # 1 sw Y   /xY w)N/unexpected EOF while parsing (<string>, line 1)z"\Xhh" \z<string>exec)r   r   compiler   r   r   r"   s      r   test_eof_with_line_continuationz+EOFTestCase.test_eof_with_line_continuationV   sJ    B{+rL*f5 ,R\\*F3 ,+s   AAc                 V   d}| j                  t              5 }t        d       ddd       | j                  t	        j
                        |       | j                  |j
                  j                  d       | j                  |j
                  j                  d       | j                  t              5 }t        dj                                ddd       | j                  t	        |j
                        |       | j                  |j
                  j                  d       | j                  |j
                  j                  d       | j                  t              5 }t        dj                  d             ddd       | j                  t	        |j
                        d       | j                  |j
                  j                  d       | j                  |j
                  j                  d       | j                  t              5 }t        t        dj                         z          ddd       | j                  t	        |j
                        |       | j                  |j
                  j                  d       | j                  |j
                  j                  d       | j                  t              5 }t        d	       ddd       | j                  t	        |j
                        |       y# 1 sw Y   xY w# 1 sw Y   /xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   bxY w)
z=A continuation at the end of input must be an error; bpo2180.r8   u   ä = 5\Nu   ä = 5\
   u   # coding:latin1
ä = 5\r   z/unexpected EOF while parsing (<string>, line 2)\)
r   r   r9   r   r   r   r    r   r!   r   r"   s      r   test_line_continuation_EOFz&EOFTestCase.test_line_continuation_EOF]   s8   B{+r ,R\\*F3**L9,,a0{+r""$% ,R\\*F3**L9,,a0{+r,33H=> ,R\\*J	L**L9,,a0{+rJ--//0 ,R\\*F3**L9,,a0{+rJ ,R\\*F37 ,+ ,+ ,+ ,+ ,+s;   K,2K9L!L2L,K69LLLL(zsys.executable requiredc                    t        j                         5 }t        j                  |dd      }t        j                  dd|      \  }}}|j                         j                         }| j                  |dd ddg       | j                  |d	   d
d d|       t        j                  |dd      }t        j                  dd|      \  }}}|j                         j                         }| j                  |d	d g d       | j                  |d   d
d d|       t        j                  |ddj                  d            }t        j                  dd|      \  }}}|j                         j                         }| j                  |d	d g d       | j                  |d   d
d d|       t        j                  |dt        dj                         z         }t        j                  dd|      \  }}}|j                         j                         }| j                  |d	d g d       | j                  |d   d
d d|       ddd       y# 1 sw Y   yxY w)z9Ensure tok_nextc() does not add too many ending newlines.r%   r>   r&   r'   Nz    \)SyntaxError: unexpected EOF while parsingr(   iz, line 1u   ä = 6\)u       ä = 6\          ^rB   u   # coding:latin1
ä = 7\r   )u       ä = 7\rC   rB   z, line 2u   ä = 8\)u       ä = 8\rC   rB   r+   )r   r,   r1   r2   r3   r4   s         r   ,test_line_continuation_EOF_from_file_bpo2180z8EOFTestCase.test_line_continuation_EOF_from_file_bpo2180}   s5    !X%11(E4HI(>>tVYWLBS**,))+CSX;(= > SWRS\:s;%11(E:NI(>>tVYWLBS**,))+CSX (= > SWRS\:s;%11(E3==CVH=MOI )>>tVYWLBS**,))+CSX (= > SWRS\:s;%11(E2:Z=N=N=P2PRI(>>tVYWLBS**,))+CSX (= > SWRS\:s;K "!!s   H%IIN)__name__
__module____qualname__r   r#   r5   r   ignore_warningsSyntaxWarningr;   r?   unittestskipIfsys
executablerE        r   r	   r	      sd    514%`N %_$$m<4 =44@ X__')BC'< D'<rP   r	   __main__)__doc__rM   codecsr   testr   test.supportr   r   r   rK   TestCaser	   rF   mainrO   rP   r   <module>rX      sL    5 
   " & ( Z<(## Z<z zHMMO rP   