
    <e&                        	 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	 e j
        Zedz   ZdZdZej                            e
          Zd                                Zej                            e          ZdZd	Zd
Z G d d          Z G d de          Z G d de          Z G d deej                  Z G d deej                  Z G d deej                  Z G d deej                  Z G d deej                  Z  G d dej                  Z! G d dej                  Z"e#dk    r ej$                     dS dS )     N)support)	os_helperz.missingz
!@$)(!@#_1 zlinecache abcz3
" Docstring "

def function():
    return result

z%
def f():
    return 1 + 1

a = f()

z
def f():
    return 3c                        e Zd Z fdZ xZS )TempFilec                 8   t                                                       t          j        d          5 }|j        | _        |                    | j                   d d d            n# 1 swxY w Y   |                     t          j
        | j                   d S )NF)delete)supersetUptempfileNamedTemporaryFilename	file_namewritefile_byte_string
addCleanupr   unlink)selffp	__class__s     */usr/lib/python3.11/test/test_linecache.pyr   zTempFile.setUp+   s    (666 	,"WDNHHT*+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 		($.99999s   'A**A.1A.)__name__
__module____qualname__r   __classcell__r   s   @r   r   r   )   s8        : : : : : : : : :    r   c                   *     e Zd Z fdZd Zd Z xZS )GetLineTestsGoodDatac                     d                     | j                                      d          | _        t	                                                       d S )Nr   utf-8)join	file_listencoder   r
   r   )r   r   s    r   r   zGetLineTestsGoodData.setUp6   s<     " 7 7 > >w G Gr   c                 0   t          j        | j                  5 }t          |          D ]R\  }}|                    d          s|dz  }t          j        | j        |dz             }|                     ||           S	 d d d            d S # 1 swxY w Y   d S )N
   )tokenizeopenr   	enumerateendswith	linecachegetlineassertEqual)r   r   indexlinecached_lines        r   test_getlinez!GetLineTestsGoodData.test_getline:   s    ]4>** 	4b(}} 4 4t}}T** !DLD'/	JJ  {33334	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   A#BBBc                 n    t          j        | j                  }|                     || j                   d S N)r,   getlinesr   r.   r#   r   liness     r   test_getlinesz"GetLineTestsGoodData.test_getlinesC   s2    "4>22/////r   )r   r   r   r   r2   r8   r   r   s   @r   r   r   3   sV            4 4 40 0 0 0 0 0 0r   r   c                       e Zd Zd Zd ZdS )GetLineTestsBadDatac                 b    |                      t          j        | j        d          d           d S )Nr'   r   )r.   r,   r-   r   r   s    r   r2   z GetLineTestsBadData.test_getlineK   s-    *4>1==rBBBBBr   c                 `    |                      t          j        | j                  g            d S r4   )r.   r,   r5   r   r<   s    r   r8   z!GetLineTestsBadData.test_getlinesN   s+    +DN;;R@@@@@r   N)r   r   r   r2   r8    r   r   r:   r:   H   s:        C C CA A A A Ar   r:   c                       e Zd Zg ZdS )	EmptyFileNr   r   r   r#   r>   r   r   r@   r@   R   s        IIIr   r@   c                       e Zd ZdgZdS )SingleEmptyLiner&   NrA   r>   r   r   rC   rC   V   s        IIIr   rC   c                       e Zd Zg dZdS )GoodUnicode)u   á
zb
zabcdef
u   ááááá
NrA   r>   r   r   rE   rE   Z   s        ;;;IIIr   rE   c                       e Zd ZdZdS )BadUnicode_NoDeclarations   
abcNr   r   r   r   r>   r   r   rG   rG   ]   s        #r   rG   c                       e Zd ZdZdS )BadUnicode_WithDeclarations   # coding=utf-8
abcNrH   r>   r   r   rJ   rJ   `   s        1r   rJ   c                   P    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S )LineCacheTestsc                 .   t           j        }|                      |t          d          t                     |                      |t          d          t                     |                     t          |t          d           |                      |t          d          t                     |                      |t          d          t                     t          D ]}t          j
                            t          |          dz   }t          |d          5 }t          |          D ](\  }}|                     | |||dz                        )	 d d d            n# 1 swxY w Y   t          j        d          }|                     |g            d S )	Ni   g?r'   .pyr!   encodingza/b/c/__init__.py)r,   r-   r.   FILENAMEEMPTYassertRaises	TypeErrorINVALID_NAMEMODULESospathr"   MODULE_PATHr)   r*   r5   )r   r-   entryfilenamefiler/   r0   emptys           r   r2   zLineCacheTests.test_getlinef   s   # 	51159992..666 	)Wh<<< 	**E222q115999  	I 	IEw||K77%?Hh111 IT#,T?? I IKE4$$T778UQY+G+GHHHHII I I I I I I I I I I I I I I
 "#677#####s   9EE#	&E#	c                 b   |                      t          j        t          j                   t	          t          j        dd          5 }|                    t                     d d d            n# 1 swxY w Y   t          j        t          j                  }| 	                    |g d           d S )Nwr!   rP   )r&   z	def f():
z    return 3
)
r   r   r   TESTFNr)   r   SOURCE_3r,   r5   r.   )r   r   r7   s      r   test_no_ending_newlinez%LineCacheTests.test_no_ending_newline   s    	()*:;;;)"C'::: 	bHHX	 	 	 	 	 	 	 	 	 	 	 	 	 	 	"9#344 F F FGGGGGs   A..A25A2c                    g }t           D ]T}t          j                            t          |          dz   }|                    |           t          j        |d           U|                     |g            d |D             }| 	                    |g            t          j
                     d |D             }| 	                    |g            d S )NrO   r'   c                 .    g | ]}|t           j        v|S r>   r,   cache.0fns     r   
<listcomp>z2LineCacheTests.test_clearcache.<locals>.<listcomp>   s$    IIIrr/H/H/H/H/Hr   c                 .    g | ]}|t           j        v |S r>   rf   rh   s     r   rk   z2LineCacheTests.test_clearcache.<locals>.<listcomp>   s$    EEErrY_/D/D/D/D/Dr   )rW   rX   rY   r"   rZ   appendr,   r-   assertNotEqualr.   
clearcache)r   cachedr[   r\   cached_emptys        r   test_clearcachezLineCacheTests.test_clearcache   s     	+ 	+Ew||K77%?HMM(###h**** 	FB'''IIVIIIr*** 	EEVEEEr*****r   c           
      F   t           j        }t          j        dz   }|                     t          j        |           t          |dd          5 }|                    t                     d d d            n# 1 swxY w Y    ||d           g }t          |d          5 }t          |          D ]=\  }}| 
                    | |||dz                        |                    |           >	 d d d            n# 1 swxY w Y   t          |dd          5 }|                    t                     d d d            n# 1 swxY w Y   t          j        d           t          |          D ](\  }}| 
                    | |||dz                        )t          j        |           t          |d          5 }t          |          D ]=\  }}| 
                    | |||dz                        |                    |           >	 d d d            d S # 1 swxY w Y   d S )NrO   r`   r!   rP   r'   dummy)r,   r-   r   ra   r   r   r)   r   SOURCE_1r*   r.   rm   SOURCE_2
checkcache)r   r-   source_namesourcesource_listr/   r0   s          r   test_checkcachezLineCacheTests.test_checkcache   s<   #&.	(+666+sW555 	#LL"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#Q +000 	)F(00 ) )t  ww{EAI'F'FGGG""4(((()	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)
 +sW555 	#LL"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	W%%% %[11 	D 	DKE4T77;	#B#BCCCC 	[)))+000 	)F(00 ) )t  ww{EAI'F'FGGG""4(((()	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)sJ   A55A9<A9AC::C>C>D>>EE:AHHHc                    t          j        t                    }t          j                     |                     dt          j        t          d                      |                     |t          j        t                               d S )NF)r,   r5   rR   ro   r.   	lazycacher6   s     r   test_lazycache_no_globalsz(LineCacheTests.test_lazycache_no_globals   sk    "8,,	 3Hd C CDDD	 28 < <=====r   c                    t          j        t          t                                }t          j                     |                     dt          j        t          t                                           |                     dt          t           j        t                                        |                     |t          j        t                               d S )NTr'   )	r,   r5   NONEXISTENT_FILENAMEglobalsro   r.   r}   lenrg   r6   s     r   test_lazycache_smokez#LineCacheTests.test_lazycache_smoke   s    "#7CC)%&:GIIFF	H 	H 	HC	0D EFFGGG 		 23G H HIIIIIr   c                 v   t          j                     t          j        t          t	                                }t          j                     t          j        t                     t          j        t          t	                                 |                     |t          j        t                               d S r4   )r,   ro   r5   r   r   r}   r.   updatecacher6   s     r   *test_lazycache_provide_after_failed_lookupz9LineCacheTests.test_lazycache_provide_after_failed_lookup   s    "#7CC/0000'))<<<	 56J K KLLLLLr   c                     t          j                     t          j        t          t	                                 t          j                     d S r4   )r,   ro   r}   r   r   rw   r<   s    r   test_lazycache_checkz#LineCacheTests.test_lazycache_check   s>    0'))<<<r   c                     t          j                     |                     dt          j        dt	                                           |                     dt          j        dt	                                           d S )NFr   z<foo>)r,   ro   r.   r}   r   r<   s    r   test_lazycache_bad_filenamez*LineCacheTests.test_lazycache_bad_filename   se    	 3B		 B BCCC	 3GWYY G GHHHHHr   c                 \   t          j                     t          j        t          t	                                }|                     dt          j        t          t	                                           |                     dt          t           j        t                                        d S )NF   )	r,   ro   r5   r   r   r.   r}   r   rg   r6   s     r   test_lazycache_already_cachedz,LineCacheTests.test_lazycache_already_cached   s    "#7CC 4gii@@	B 	B 	B 	C	0D EFFGGGGGr   c                 p   t          j        t                    }|                     |           d }t	          j        t           d|          5  t          j        t                    }d d d            n# 1 swxY w Y   |                     ||           t          j                     t	          j        t           d|          5  t          j        t                    }d d d            n# 1 swxY w Y   |                     |g            |                     t          j        t                    |           d S )Nc                      t           r4   )MemoryError)argskwargss     r   raise_memoryerrorz:LineCacheTests.test_memoryerror.<locals>.raise_memoryerror   s    r   r   )r,   r5   rR   
assertTruer   	swap_attrr.   ro   )r   r7   r   lines2lines3s        r   test_memoryerrorzLineCacheTests.test_memoryerror   s   "8,,	 	 	y-9JKK 	2 	2'11F	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2'''y-9JKK 	2 	2'11F	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2$$$+H55u=====s$   A33A7:A7C((C,/C,N)r   r   r   r2   rc   rr   r{   r~   r   r   r   r   r   r   r>   r   r   rL   rL   d   s        $ $ $2H H H+ + +") ) )B> > >J J JM M M  
I I I
H H H> > > > >r   rL   c                   0     e Zd Z fdZd Zd Zd Z xZS )LineCacheInvalidationTestsc                 >   t                                                       t          j                     t          j        dz   | _        t          j        dz   | _        t          j        dz   | _        | j        | j        | j        fD ]}| 	                    t          j
        |           t          |dd          5 }|                    d| d           d d d            n# 1 swxY w Y   |                     |t          j                   t          j        |           |                     |t          j                   t#          j        | j                   t          | j        dd          5 }|                    d	           d d d            d S # 1 swxY w Y   d S )
Nz.1z.2z.3r`   r!   rP   zprint("I am z")zprint("was modified"))r
   r   r,   ro   r   ra   deleted_filemodified_fileunchanged_filer   r   r)   r   assertNotInrg   r5   assertInrX   remove)r   fnamery   r   s      r   r   z LineCacheInvalidationTests.setUp   s   %,t3&-4'.5'()+ 		2 		2E OOI,e444eS7333 7v5E5556667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 UIO444u%%%MM%1111
	$#$$$$$cG<<< 	2LL0111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s$   9CC#	&C#	/FFFc                    t          j        | j                   |                     | j        t           j                   |                     | j        t           j                   |                     | j        t           j                   d S r4   )r,   rw   r   r   rg   r   r   r   r<   s    r    test_checkcache_for_deleted_filez;LineCacheInvalidationTests.test_checkcache_for_deleted_file	  si    T.///*IO<<<d()/:::d)9?;;;;;r   c                    t          j        | j                   |                     | j        t           j                   |                     | j        t           j                   |                     | j        t           j                   d S r4   )r,   rw   r   r   r   rg   r   r   r<   s    r   !test_checkcache_for_modified_filez<LineCacheInvalidationTests.test_checkcache_for_modified_file  si    T/000d'999+Y_===d)9?;;;;;r   c                 
   t          j                     |                     | j        t           j                   |                     | j        t           j                   |                     | j        t           j                   d S r4   )r,   rw   r   r   rg   r   r   r   r<   s    r   !test_checkcache_with_no_parameterz<LineCacheInvalidationTests.test_checkcache_with_no_parameter  sf    *IO<<<+Y_===d)9?;;;;;r   )r   r   r   r   r   r   r   r   r   s   @r   r   r      se        2 2 2 2 2,< < << < << < < < < < <r   r   __main__)%r,   unittestos.pathrX   r   r(   testr   test.supportr   __file__rR   r   rV   rS   rY   dirname	TEST_PATHsplitrW   rZ   ru   rv   rb   r   r   r:   TestCaser@   rC   rE   rG   rJ   rL   r   r   mainr>   r   r   <module>r      s   &               " " " " " " *, 
GOOH%%	



!
!gooh''
: : : : : : : :0 0 0 0 08 0 0 0*A A A A A( A A A    $h&7       *H,=   < < < < <&(9 < < <$ $ $ $ $2H4E $ $ $2 2 2 2 2!4h6G 2 2 2K> K> K> K> K>X& K> K> K>\'< '< '< '< '<!2 '< '< '<T zHMOOOOO r   