
    -Ph                     \    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dS )    N   )open_source_file   )strip_string_literalsc                   @    e Zd ZdZed             Zd Zd Zd Zd Z	dS )TestStripLiteralsNc                 :    fd}t          j        d||           S )Nc                 8    |                                           S N)group)matchliteralss    d/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/Cython/Build/Tests/TestStripLiterals.pylookupz1TestStripLiterals._rebuild_string.<locals>.lookup   s    EKKMM**    z__Pyx_L[0-9]+_)resub)strippedr   r   s    ` r   _rebuild_stringz!TestStripLiterals._rebuild_string   s3    	+ 	+ 	+ 	+ 	+ v&999r   c           !           f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 t          dd           D                       z   d!z   fgz   }|D ]\  }}                     |"          5   |||           d d d            n# 1 swxY w Y   |                                }|                                }                     |"          5   |||           d d d            n# 1 swxY w Y   |d#z  }|d#z  }                     |"          5   |||           d d d            n# 1 swxY w Y    |d$d%           d S )&Nc                     t          |           \  }}                    ||                               ||          }                    | |           d S r   )r   assertEqualr   )sexpectedr   r   	recoveredselfs        r   strip_equalszBTestStripLiterals.test_strip_string_literals.<locals>.strip_equals   s\    !6q!9!9HhXx000,,Xx@@IQ	*****r   ) abc123z	func(123)z '' z '''''''''''' z '''''''''''''' c                     g | ]}||fS  r"   ).0codes     r   
<listcomp>z@TestStripLiterals.test_strip_string_literals.<locals>.<listcomp>%   s    444$$444r   )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                     g | ]}d | d	S )z
{x}__Pyx_L_r"   )r#   ns     r   r%   z@TestStripLiterals.test_strip_string_literals.<locals>.<listcomp>f   s$    HHHQ0A000HHHr         z{x:{width}}__Pyx_L251_')r$   
z( print("Say something: %s' % something) z print("__Pyx_L1_)joinrangesubTeststrip)r   r   	unchangedtestsr$   r   s   `     r   test_strip_string_literalsz,TestStripLiterals.test_strip_string_literals   s   	+ 	+ 	+ 	+ 	+
 
 
	 54)444.&&"/9H#1+@H 5BGGHH%3--HHHIIILeegAB8
 B
H $ 
	- 
	-ND(4(( - -T8,,,- - - - - - - - - - - - - - -::<<D~~''H4(( - -T8,,,- - - - - - - - - - - - - - -DLDH4(( - -T8,,,- - - - - - - - - - - - - - - 	:#	
 	
 	
 	
 	
s6   BB	"B	$C==D	D	(EE	E	c           	         t          j        d          j        }t          |          D ]G}|                     t          |                    |                              5  t          t          |                    5 }|                                }d d d            n# 1 swxY w Y   t          |          \  }} ||          }	|	rct          |	                    d                    dk    r=|	                                dz   }
|                     d||
dz
  |
dz                       |                     ||          }|                     ||           d d d            n# 1 swxY w Y   Id S )Nz[^_'"}](['"]+)[^_'"{])filer,   r   zLeftover string found:    )r   compilesearchsortedr1   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 H O
++ 	2 	2I3y'<'<X'F'F#G#GHH 2 2%c)nn55 $6688D$ $ $ $ $ $ $ $ $ $ $ $ $ $ $%:4%@%@"(--h77 gSQ00A55 % 1IIIeRR[^`R`A`8aeefff 008DD	  y1112 2 2 2 2 2 2 2 2 2 2 2 2 2 2	2 	2s7   "E%?B E% B$$E%'B$(B1E%%E)	,E)	c                     t          j        t                                                    j        d         }|j        dk    sJ |j        }|                     ||                    d                     d S )Nr   Cython*.py)	pathlibPath__file__absoluteparentsnameparentrH   rglob)r   package_dirrB   s      r   #test_strip_string_literals_py_filesz5TestStripLiterals.test_strip_string_literals_py_files   sk    l8,,5577?B8++++%X{'8'8'@'@AAAAAr   c                    t          j        t                                                    j        d         }|dz  }g }|                                D ]q}|                                r[|j        dk    rP|                    |	                    d                     |                    |	                    d                     r| 
                    ||           d S )Nr   r4   errorsrK   z*.pyx)rL   rM   rN   rO   rP   iterdiris_dirrQ   extendrS   rH   )r   rB   	tests_dir
test_filestest_subdirs        r   %test_strip_string_literals_test_filesz7TestStripLiterals.test_strip_string_literals_test_files   s    <))2244<Q?w&	
$,,.. 	> 	>K!!## >(8H(D(D!!+"3"3F";";<<<!!+"3"3G"<"<===Xz22222r   )
__name__
__module____qualname__maxDiffstaticmethodr   r5   rH   rU   r^   r"   r   r   r   r   	   su        G: : \:f
 f
 f
P2 2 2 B B B	3 	3 	3 	3 	3r   r   )	rL   r   unittestUtilsr   Dependenciesr   TestCaser   r"   r   r   <module>rh      s     				  % % % % % % 0 0 0 0 0 0R3 R3 R3 R3 R3) R3 R3 R3 R3 R3r   