
    2h                        S SK r S SKrS SKrS SKJr  S SKJr  S SKrS SKJ	r	  \R                  " S5      r/ \l         S$S jrS$S jrS rS	 rS
 rS r\ R&                  R(                  S 5       r\ R&                  R(                  S 5       r\ R&                  R(                  S 5       r\ R&                  R(                  S 5       r\R2                  R5                  \5      rSrSrSr\R2                  RA                  \SS5      r!Sr"\R2                  RA                  \SS5      r# S r$\ R&                  R(                  S 5       r%\ R&                  R(                  S 5       r&\ R&                  R(                  S 5       r'\ R&                  R(                  S 5       r(\ R&                  R(                  S 5       r)\ R&                  R(                  S 5       r*\ R&                  R(                  S 5       r+\ R&                  R(                  S 5       r,\ R&                  R(                  S  5       r-\ R&                  R(                  S! 5       r.\/S":X  a  \ R`                  " S#\/5        gg)%    N)	CliRunner)tts_cli)
LogCapturegttsc                 >    [        5       R                  [        X5      $ Nr   invoker   argsinputs     K/var/www/auris/envauris/lib/python3.13/site-packages/gtts/tests/test_cli.pyrunnerr      s    ;gt33    c                 H    [        5       R                  [        U S/-   U5      $ )Nz--debugr	   r   s     r   runner_debugr      s     ;gtyk'95AAr   c                  b    [        / 5      n SU R                  ;   d   eU R                  S:w  d   eg)z2One of <test> (arg) and <file> <opt> should be setz<file> requiredr   Nr   output	exit_coderesults    r   test_text_no_text_or_filer      s2    "F---q   r   c                     U S-  nUR                  5         [        S[        U5      S/5      nSUR                  ;   d   eUR                  S:w  d   eg)z8<test> (arg) and <file> <opt> should not be set togetherztest_and_file.txt--filetestz<file> can't be used togetherr   Ntouchr   strr   r   tmp_pathfilenamer   s      r   test_text_text_and_filer#   &   sR    --HNN8S]F;<F*fmm;;;q   r   c                     U S-  nUR                  5         [        S[        U5      /5      nSUR                  ;   d   eUR                  S:w  d   eg)z%Exit on no text to speak (via <file>)ztext_empty.txtr   zNo text to speakr   Nr   r    s      r   test_text_emptyr%   1   sP    **HNN8S]34F...q   r   c                  f    [        / SQ5      n SU R                  ;   d   eU R                  S:w  d   eg)z<file> should exist)r   znotexist.txtr   zNo such file or directoryr   Nr   r   s    r   test_file_not_existsr'   =   s3    <=F&&--777q   r   c                      [        S/5      n [        R                  " SU R                  5      (       d   eU R                  S:X  d   eg)z.Option <all> should return a list of languagesz--allz(\s{2}[\w-]{2,5}: .+\n?)r   N)r   rematchr   r   r   s    r   test_allr+   F   sB     WIF
 88/????q   r   c                  f    [        / SQ5      n SU R                  ;   d   eU R                  S:w  d   eg)z&Invalid <lang> should display an error)--langxxr   z&xx' not in list of supported languagesr   N)r   r   r   r   s    r   test_lang_not_validr/   S   s5     ,-F3v}}DDDq   r   c                      [        5        n [        / SQ5      n[        U 5      nSSS5        SW;   d   eSU;   d   eSWR                  ;   d   eUR                  S:w  d   eg! , (       d  f       NC= f)zIInvalid <lang> (with <nocheck>) should display an error message from gtts)r-   r.   	--nocheckr   Nzlang: xxlang_check: FalsezUnsupported language 'xx'r   )r   r   r   r   r   lcr   logs      r   test_lang_nocheckr6   \   sp     
CD"g 

 #%%%&&--777q    
s   A!!
A/c                      [        5        n [        / SQ5      n[        U 5      nSSS5        SW;   d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   eWR                  S:X  d   eg! , (       d  f       NI= f)	z@Options should set gTTS instance arguments (read from debug log))r-   frz--tldesz--slowr1   r   Nzlang: frztld: esr2   z
slow: Truez
text: testr   )r   r   r   r   r3   s      r   test_params_setr:   k   s     
J
 "g 
 #%%%33q    
s   A''
A5zstdin
test
123uP   你吃饭了吗？
你最喜欢哪部电影？
我饿了，我要去做饭了。zCan you make pink a little more pinkish can you make pink a little more pinkish, nor can you make the font bigger?
How much will it cost the website doesn't have the theme i was going for.input_filesztest_cli_test_ascii.txtu   这是一个三岁的小孩
在讲述她从一系列照片里看到的东西。
对这个世界， 她也许还有很多要学的东西，
但在一个重要的任务上， 她已经是专家了：
去理解她所看到的东西。ztest_cli_test_utf8.txtc                     U R                   (       d  gSR                  U R                  5        Vs/ s H  nSU-  PM
     sn5      $ s  snf )NzNo logging captured
z
%s %s
  %s)recordsjoinactual)r4   rs     r   logcapture_strrB      s8    ::$99"))+>+Qnq(+>??>s   Ac                      [        5        n [        S/[        5      n[        U 5      nS S S 5        S[        -  W;   d   eWR                  S:X  d   eg ! , (       d  f       N0= fN-text: %sr   r   r   	textstdinrB   r   r3   s      r   test_stdin_textrI      sW    	seY/R  
 	!S(((q    
   A
A c                      [        5        n [        S/[        5      n[        U 5      nS S S 5        S[        -  W;   d   eWR                  S:X  d   eg ! , (       d  f       N0= frD   r   r   textstdin_unicoderB   r   r3   s      r   test_stdin_text_unicoderN      sY    	se%67R  
 ))S000q    
rJ   c                      [        5        n [        SS/[        5      n[        U 5      nS S S 5        S[        -  W;   d   eWR                  S:X  d   eg ! , (       d  f       N0= fNr   rE   rF   r   rG   r3   s      r   test_stdin_filerQ      sY    	xoy9R  
 	!S(((q    
   A
A!c                      [        5        n [        SS/[        5      n[        U 5      nS S S 5        S[        -  W;   d   eWR                  S:X  d   eg ! , (       d  f       N0= frP   rL   r3   s      r   test_stdin_file_unicoderT      s[    	xo/@AR  
 ))S000q    
rR   c                      [        5        n [        [        /5      n[        U 5      nS S S 5        S[        -  W;   d   eWR                  S:X  d   eg ! , (       d  f       N0= fNrF   r   )r   r   textrB   r   r3   s      r   	test_textrX      sU    	tf%R  
 ###q    
   A
Ac                      [        5        n [        [        /5      n[        U 5      nS S S 5        S[        -  W;   d   eWR                  S:X  d   eg ! , (       d  f       N0= frV   )r   r   text_unicoderB   r   r3   s      r   test_text_unicoder\      sU    	|n-R  
 $+++q    
rY   c                      [        5        n [        S[        /5      n[        U 5      nS S S 5        S[        -  W;   d   eWR
                  S:X  d   eg ! , (       d  f       N0= fNr   rF   r   )r   r   textfile_asciirB   rW   r   r3   s      r   test_file_asciir`      sX    	x89R  
 ###q    
rJ   c                      [        5        n [        S[        /5      n[        U 5      nS S S 5        S[        -  W;   d   eWR
                  S:X  d   eg ! , (       d  f       N0= fr^   )r   r   textfile_utf8rB   r[   r   r3   s      r   test_file_utf8rc      sX    	x78R  
 $+++q    
rJ   c                  @    [        S/5      n U R                  S:X  d   eg )Nr   r   )r   r   r   s    r   test_stdoutre      s$    VHF q   r   c                     U S-  n[        SS[        U5      /5      nUR                  5       R                  S:  d   eUR                  S:X  d   eg )Nzout.mp3r   z--outputi  r   )r   r   statst_sizer   r    s      r   	test_fileri      sQ    )#HVZX78F ==?""T)))q   r   __main__z-xr   )1pytestr)   osclick.testingr   gtts.clir   loggingtestfixturesr   	getLoggerloggerhandlersr   r   r   r#   r%   r'   marknetr+   r/   r6   r:   pathdirname__file__pwdrH   rM   rW   r?   r_   r[   rb   rB   rI   rN   rQ   rT   rX   r\   r`   rc   re   ri   __name__main r   r   <module>r}      sn    	 	 # 
  #			6	" !4B
!!!! ! ! ! ! 
! 
! ! !$ 	ggooh	
% 
M c=2KL% S-1IJ@ ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! z
KKx ! r   