
     YHh                     ^    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ej                        Zy)    N   )open_source_file   )strip_string_literalsc                   8    e Zd ZdZed        Zd Zd Zd Zd Z	y)TestStripLiteralsNc                 <    fd}t        j                  d||       S )Nc                 *    | j                            S N)group)matchliteralss    ]/var/www/html/planif/env/lib/python3.12/site-packages/Cython/Build/Tests/TestStripLiterals.pylookupz1TestStripLiterals._rebuild_string.<locals>.lookup   s    EKKM**    z__Pyx_L[0-9]+_)resub)strippedr   r   s    ` r   _rebuild_stringz!TestStripLiterals._rebuild_string   s    	+ vv&99r   c           "           fd}g d}|D cg c]  }||f c}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j                  t        dd      D cg c]  }d| d 
 c}      z   d!z   fgz   }|D ]  \  }} j                  |"      5   |||       d d d        |j                         }|j                         } j                  |"      5   |||       d d d        |d#z  }|d#z  } j                  |"      5   |||       d d d          |d$d%       y c c}w c c}w # 1 sw Y   xY w# 1 sw Y   YxY w# 1 sw Y   xY w)&Nc                     t        |       \  }}j                  ||       j                  ||      }j                  | |       y r   )r   assertEqualr   )sexpectedr   r   	recoveredselfs        r   strip_equalszBTestStripLiterals.test_strip_string_literals.<locals>.strip_equals   sD    !6q!9HhXx0,,Xx@IQ	*r   ) abc123z	func(123)z '' z '''''''''''' z '''''''''''''' )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         z
{x}__Pyx_L_z{x:{width}}__Pyx_L251_')code
z( print("Say something: %s' % something) z print("__Pyx_L1_)joinrangesubTeststrip)r   r   	unchangedr'   ntestsr   s   `      r   test_strip_string_literalsz,TestStripLiterals.test_strip_string_literals   s   	+
	 +44$$4.&&"/9H#1+@H 5BGG%3-HQ|A3a0HIILeegAB8
 B
H $ 
	-ND(4( -T8,-::<D~~'H4( -T8,-DLDH4( -T8,- -
	- 	:#	
c 5B I- -- -- -s/   DD<
D	
D+7
D7D(	+D4	7E 	c           	      f   t        j                  d      j                  }t        |      D ]  }| j	                  t        |j                  |                  5  t        t        |            5 }|j                         }d d d        t              \  }} ||      }	|	rMt        |	j                  d            dk7  r0|	j                         dz   }
| j                  d||
dz
  |
dz           | j                  ||      }| j                  ||       d d d         y # 1 sw Y   xY w# 1 sw Y   xY w)Nz[^_'"}](['"]+)[^_'"{])filer$   r   zLeftover string found:    )r   compilesearchsortedr+   strrelative_tor   readr   lenr   startfailr   r   )r   base_dir
file_paths_find_leftover_string	file_pathfr'   r   r   r   	match_posr   s               r   _test_all_filesz!TestStripLiterals._test_all_files{   s    "

+G H O O
+ 	2I3y'<'<X'F#GH 2%c)n5 $668D$%:4%@"(-h7SQ0A5 % 1III 7RR[^`R`8a7def 008D	  y12 2	2$ $2 2s%   D&-D>BD&D#D&&D0	c                     t        j                  t              j                         j                  d   }|j
                  dk(  sJ |j                  }| j                  ||j                  d             y )Nr   Cython*.py)	pathlibPath__file__absoluteparentsnameparentrC   rglob)r   package_dirr=   s      r   #test_strip_string_literals_py_filesz5TestStripLiterals.test_strip_string_literals_py_files   s^    ll8,557??B8+++%%X{'8'8'@Ar   c                    t        j                  t              j                         j                  d   }|dz  }g }|j                         D ]c  }|j                         s|j                  dk7  s$|j                  |j                  d             |j                  |j                  d             e | j                  ||       y )Nr   r/   errorsrF   z*.pyx)rG   rH   rI   rJ   rK   iterdiris_dirrL   extendrN   rC   )r   r=   	tests_dir
test_filestest_subdirs        r   %test_strip_string_literals_test_filesz7TestStripLiterals.test_strip_string_literals_test_files   s    <<)224<<Q?w&	
$,,. 	>K!!#(8(8H(D!!+"3"3F";<!!+"3"3G"<=	> 	Xz2r   )
__name__
__module____qualname__maxDiffstaticmethodr   r0   rC   rP   rY    r   r   r   r   	   s0    G: :f
P2 B	3r   r   )	rG   r   unittestUtilsr   Dependenciesr   TestCaser   r_   r   r   <module>rd      s(     	  % 0R3)) R3r   