o
    j                     @   sF   d dl Z d dlZd dlZddlmZ ddlmZ G dd dejZdS )    N   )open_source_file   )strip_string_literalsc                   @   s<   e Zd ZdZedd Zdd Zdd Zdd	 Zd
d Z	dS )TestStripLiteralsNc                    s    fdd}t d|| S )Nc                    s    |    S N)group)matchliterals e/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/Cython/Build/Tests/TestStripLiterals.pylookup   s   z1TestStripLiterals._rebuild_string.<locals>.lookupz__Pyx_L[0-9]+_)resub)strippedr   r   r   r
   r   _rebuild_string   s   z!TestStripLiterals._rebuild_stringc                     sV   fdd}g 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"D  d# fg }|D ]e\}} j|d$ ||| W d    n1 sXw   Y  | }| } j|d$ ||| W d    n1 s{w   Y  |d%7 }|d%7 } j|d$ ||| W d    n1 sw   Y  q>|d&d' d S )(Nc                    s4   t | \}} ||  ||} | | d S r   )r   assertEqualr   )sexpectedr   r   	recoveredselfr   r   strip_equals   s   zBTestStripLiterals.test_strip_string_literals.<locals>.strip_equals) abcZ123z	func(123)z '' z '''''''''''' z '''''''''''''' c                 S   s   g | ]}||fqS r   r   ).0coder   r   r   
<listcomp>%   s    z@TestStripLiterals.test_strip_string_literals.<locals>.<listcomp>)z"x"z"__Pyx_L1_")z'x''__Pyx_L1_')z	 '"' "'" z '__Pyx_L1_' "__Pyx_L2_" )z
 '''' '''  '''__Pyx_L1_''' )z
 """" """ z """__Pyx_L1_""" )z
 '''a
''' r    )z'a\'b'r   )z'a\\'r   )z'a\\\'b'r   )zu'abc'zu'__Pyx_L1_')zr'abc\\'zr'__Pyx_L1_')z	ru'abc\\'zru'__Pyx_L1_')z	abc # fooabc #__Pyx_L1_)z	abc # 'x'r!   )z'abc#'r   )z include 'a.pxi' # something herezinclude '__Pyx_L1_' #__Pyx_L2_)z!cdef extern from 'a.h': # commentz(cdef extern from '__Pyx_L1_': #__Pyx_L2_)z4 func('xyz') + " " + "" '' # '' | "" "123" 'xyz' "' z3 func('__Pyx_L1_') + "__Pyx_L2_" + "" '' #__Pyx_L3_)z f'f' z f'__Pyx_L1_' )z f'a{123}b' z f'__Pyx_L1_{123}__Pyx_L2_' )z f'{1}{f'xyz'}' z f'{1}{f'__Pyx_L1_'}' )z f'{f'''xyz{f"""abc"""}'''}' z) f'{f'''__Pyx_L1_{f"""__Pyx_L2_"""}'''}' )z* f'{{{{{"abc"}}}}}{{}}{{' == '{{abc}}{}{' z3 f'__Pyx_L1_{"__Pyx_L2_"}__Pyx_L3_' == '__Pyx_L4_' a  f'{x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x} {x:{width}} 'zf'r   c                 S   s   g | ]}d | dqS )z
{x}__Pyx_L_r   )r   nr   r   r   r   f   s          z{x:{width}}__Pyx_L251_')r   
z( print("Say something: %s' % something) z print("__Pyx_L1_)joinrangesubTeststrip)r   r   Z	unchangedtestsr   r   r   r   r   test_strip_string_literals   sb   
 Dz,TestStripLiterals.test_strip_string_literalsc              
   C   s   t dj}t|D ]n}| jt||dY tt|}| }W d    n1 s-w   Y  t	|\}}||}	|	r]t
|	ddkr]|	 d }
| d||
d |
d   | ||}| || W d    n1 ssw   Y  q
d S )Nz[^_'"}](['"]+)[^_'"{])filer$   r   zLeftover string found:    )r   compilesearchsortedr)   strrelative_tor   readr   lenr   startZfailr   r   )r   base_dir
file_pathsZ_find_leftover_string	file_pathfr   r   r   r	   Z	match_posr   r   r   r   _test_all_files{   s    
 z!TestStripLiterals._test_all_filesc                 C   s>   t t jd }|jdksJ |j}| ||d d S )Nr   Cython*.py)	pathlibPath__file__absoluteparentsnameparentr;   rglob)r   Zpackage_dirr7   r   r   r   #test_strip_string_literals_py_files   s   z5TestStripLiterals.test_strip_string_literals_py_filesc                 C   sp   t t jd }|d }g }| D ]}| r/|jdkr/||	d ||	d q| 
|| d S )Nr   r+   errorsr=   z*.pyx)r>   r?   r@   rA   rB   iterdiris_dirrC   extendrE   r;   )r   r7   Z	tests_dirZ
test_filesZtest_subdirr   r   r   %test_strip_string_literals_test_files   s   z7TestStripLiterals.test_strip_string_literals_test_files)
__name__
__module____qualname__ZmaxDiffstaticmethodr   r,   r;   rF   rK   r   r   r   r   r   	   s    
hr   )	r>   r   ZunittestZUtilsr   ZDependenciesr   ZTestCaser   r   r   r   r   <module>   s    