
    Ngs                     v    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Zd dlZd dl	Zd dl
mZ  G d de          ZdS )    N)
CythonTestc                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	TestCyCachec                 &   t          j        |            t          j        dt          j                            d          rdnd           | _        t          j        d| j                  | _        t          j        d| j                  | _	        d S )Nzcycache-testTEST_TMP)prefixdirsrccache)
r   setUptempfilemkdtempospathisdirtemp_dirsrc_dir	cache_dir)selfs    Z/var/www/html/ai-engine/env/lib/python3.11/site-packages/Cython/Build/Tests/TestCyCache.pyr   zTestCyCache.setUp   s     (! gmmJ77A

TC C C  'u$-HHH!)dmLLL    c                 p    t          j         t          j                            | j        |                    S N)globr   r   joinr   )r   	file_globs     r   cache_fileszTestCyCache.cache_files   s$    ydni@@AAAr   c                     t           j                                         d t           j        j        _        t          j        j        j        |i | d S r   )CythonUtilsclear_function_cachesBuildDependencies	_dep_tree	cythonize)r   argskwargss      r   fresh_cythonizezTestCyCache.fresh_cythonize   sD    **,,,.2!+!+T<V<<<<<r   c                    d}d}t           j                            | j        d          }|d d         dz   }t	          |d          5 }|                    |           d d d            n# 1 swxY w Y   |                     || j                   |                     || j                   |                     dt          | 
                    d	                               t	          |          5 }|                                }d d d            n# 1 swxY w Y   t          j        |           t	          |d          5 }|                    |           d d d            n# 1 swxY w Y   |                     || j                   t	          |          5 }|                                }d d d            n# 1 swxY w Y   t          j        |           |                     ||d
           |                     dt          | 
                    d	                               t	          |d          5 }|                    |           d d d            n# 1 swxY w Y   |                     || j                   |                     dt          | 
                    d	                               t	          |          5 }|                                }d d d            n# 1 swxY w Y   |                     ||d                    t          t          j        |                    d          |                    d                              d d                              d S )Nz
value = 1
z
value = 2
a.pyx.cwr      za.c*zC file not changed!   

   )msg)r   r   r   r   openwriter(   r   assertEquallenr   readunlinkassertNotEquallistdifflibunified_diffsplit)	r   content1content2a_pyxa_cfa_contents1a_contents2
a_contentss	            r   test_cycache_switchzTestCyCache.test_cycache_switch    s     T\733CRCj4% 	GGH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	U$.999U$.999C 0 0 8 899:::#YY 	#!&&((K	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#
	#% 	GGH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	U$.999#YY 	#!&&((K	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#
	#K6KLLLC 0 0 8 899:::% 	GGH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	U$.999C 0 0 8 899:::#YY 	"!J	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"		$w3  &&(9(9$(?(? A  A B BBE2#G H H 	 	I 	I 	I 	I 	Isl   A))A-0A-1DDDE##E'*E'F::F>F>6IIIK%%K),K)c                 d   t           j                            | j        d          }|d d         dz   }t	          |d          5 }|                    d           d d d            n# 1 swxY w Y   |                     || j                   t           j                            | j        t          j        | j                  d                   }t          j
        |d          5 }|                    d	                    d
                     d d d            n# 1 swxY w Y   t          j        |           |                     || j                   t	          |          5 }|                                }d d d            n# 1 swxY w Y   |                     |d	d|d d         z             d S )Nr*   r+   r,   r-   passr.   r   wbz
fake stuffasciizUnexpected contents: %s...d   )r   r   r   r   r4   r5   r(   r   listdirgzipGzipFileencoder9   r8   r6   )r   rA   rB   rC   a_cachegzipfilerF   s          r   test_cycache_uses_cachez#TestCyCache.test_cycache_uses_cacheD   s2   T\733CRCj4% 	GGFOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	U$.999',,t~rz$./I/I!/LMM]7D)) 	9XNN<..w77888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9
	#U$.999#YY 	"!J	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"\5
4C48HH	J 	J 	J 	J 	Js6   A%%A),A)#)DDD"FF
Fc                    t           j                            | j        d          }|d d         dz   }|d d         dz   }|d d         dz   }t	          |d          5 }|                    d           d d d            n# 1 swxY w Y   |                     || j                   |||g}|D ]I}|                     t           j        	                    |          |           t          j
        |           J|                     || j                   |D ]5}|                     t           j        	                    |          |           6d S )	Nr*   r+   r,   z.hz_api.hr-   z)cdef public api int foo(int x): return x
r.   )r   r   r   r   r4   r5   r(   r   
assertTrueexistsr9   )r   rA   rB   a_ha_api_hrC   expectedoutputs           r   test_multi_file_outputz"TestCyCache.test_multi_file_outputT   s   T\733CRCj4CRCj4*x'% 	BGG@AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	BU$.999g& 	 	FOOBGNN622F;;;IfU$.999 	< 	<FOOBGNN622F;;;;	< 	<s   A??BBc                    t           j                            | j        d          }|d t	          d                    dz   }t          |d          5 }|                    d           d d d            n# 1 swxY w Y   |                     || j        d           | 	                    dt	          | 
                    d	                               t          j        |           |                     || j        d
           | 	                    dt	          | 
                    d	                               t          j        |           |                     || j        dd           | 	                    dt	          | 
                    d	                               t          j        |           |                     || j        dd
           | 	                    dt	          | 
                    d	                               d S )Nzoptions.pyxz.pyxr,   r-   rI   F)r   cplusr/   z
options.c*Tr0   )r   r]   show_version)r   r   r   r   r7   r4   r5   r(   r   r6   r   r9   )r   hash_pyxhash_crC   s       r   test_options_invalidationz%TestCyCache.test_options_invalidationd   s   7<<m<<-CKK<-(4/(C   	AGGFOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	XT^5IIIC 0 0 > >??@@@
	&XT^4HHHC 0 0 > >??@@@
	&XT^5W\]]]C 0 0 > >??@@@
	&XT^5W[\\\C 0 0 > >??@@@@@s   A33A7:A7N)
__name__
__module____qualname__r   r   r(   rG   rS   r[   ra    r   r   r   r      s        M M MB B B= = =
"I "I "IHJ J J < < < A A A A Ar   r   )r<   r   rN   r   sysr   unittestCython.Build.Dependenciesr   Cython.UtilsCython.TestUtilsr   r   re   r   r   <module>rk      s       				 



               ' ' ' ' ' 'iA iA iA iA iA* iA iA iA iA iAr   