
    Ae                         d dl Z d dlZd dlmZ 	 d dlmZ ddlmZ ddl	m
Z
 g fdZ G d d	e      Zy# e$ r	 d dlmZ Y *w xY w)
    N)TestCase)StringIO   )Options)parse_command_linec                     t               }| j                         D ]%  \  }}||vst        t        ||      |k7  s d|z   c S  y)z1
    returns error message of "" if check Ok
    error in option  )objectitemsgetattrr   )expected_options
white_listno_valuename
orig_values        Alib/python3.12/site-packages/Cython/Compiler/Tests/TestCmdLine.pycheck_global_optionsr      sQ     xH,224 1jz!wh/:=)D001     c                   J    e Zd Zd Zd Zg fdZg fdZd Zd Zd Z	d Z
d	 Zy
)CmdLineParserTestc                 j    i }t        t              j                         D ]
  \  }}|||<    || _        y N)varsr   r   _options_backup)selfbackupr   values       r   setUpzCmdLineParserTest.setUp   s8    =..0 	!KD% F4L	!%r   c                     t               }| j                  j                         D ]+  \  }}t        t        ||      |k7  st        t        ||       - y r   )r   r   r   r   r   setattr)r   r   r   r   s       r   tearDownzCmdLineParserTest.tearDown!   sI    8 $ 4 4 : : < 	3D*wh/:=z2	3r   c                 P    | j                  t        | j                  |      d       y )Nr
   )assertEqualr   r   )r   r   s     r   check_default_global_optionsz.CmdLineParserTest.check_default_global_options'   s!    -d.B.BJOQSTr   c                     ddl m}m}  ||      }t               }|j                  j                         D ]3  }||vs| j                  t        |||      t        ||      d|z          5 y )Nr   )CompilationOptionsdefault_optionsr	   )msg)Mainr'   r(   r   __dict__keysr$   r   )r   optionsr   r'   r(   r   r   s          r   check_default_optionsz'CmdLineParserTest.check_default_options*   sv    >,_=8#,,113 	BD:%  $!A7?\`Cagy  }A  hA   B	Br   c                 6   t        g d      \  }}| j                  |       | j                  |j                         | j                  |j                         | j                  |j
                         | j                  |j                         | j                  |j                  dk\         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  |j                  d       t        g d      \  }}| j                  |       | j                  t        |      dk(         | j                  |j                         | j                  |j                  d       y )N)z-Vz-lz-+z-t-vr0   r0   z-pz-Dz-az-3   )z-fz-2
source.pyx   r   )r   assertFalse
assertTrueshow_versionuse_listing_filecplus
timestampsverboser   embed_pos_in_docstring
docstringsannotater$   language_levellenr   r-   sourcess      r   test_short_optionsz$CmdLineParserTest.test_short_options2   s0   - /
  	!,,-001&**+1,-667++,(()//3- /
  	 G)*++,//3r   c                    t        g d      \  }}| j                  |       | j                  |j                         | j                  |j                         | j                  |j
                         | j                  t        j                  d       | j                  |j                         | j                  |j                  dk\         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         | j                  t        j                         t        ddg      \  }}| j                  |       | j                  t!        |      dk(         | j                  |j                         y )N)z	--versionz--create-listingz--cplusz--embed--timestamps	--verboserE   rE   z--embed-positionsz--no-docstringsz
--annotatez	--lenientmainr1   z--forcer2   r3   )r   r4   r5   r6   r7   r8   r$   r   embedr9   r:   r;   r<   r=   error_on_unknown_nameserror_on_uninitializedr?   r@   s      r   test_long_optionsz#CmdLineParserTest.test_long_optionsI   sE   - /
 
 	!,,-001&/**+1,-667++,(()778778-|/
  	 G)*++,r   c                    t        g d      \  }}| j                  |dg       | j                  t        j                  d       | j                  |j                  g d       | j                  |j
                  d       | j                  |j                  d       | j                  t        j                  d       | j                  t        j                  d       | j                  t        j                         | j                  t        j                  d	       | j                  |j                         | j                  |j                  d
       y )N)z--embed=huhuz-I/test/include/dir1z --include-dir=/test/include/dir2z--include-dir/test/include/dir3z--working=/work/dirr2   z--output-file=/output/dirz--pre-import=/pre/importz--cleanup=3z--annotate-coverage=cov.xmlz--gdb-outdir=/gdb/outdirz--directive=wraparound=falser2   huhu)z/test/include/dir1z/test/include/dir2rL   z	/work/dirz/output/dirz/pre/importr1   zcov.xmlz/gdb/outdir)r   r$   r   rG   include_pathworking_pathoutput_file
pre_importgenerate_cleanup_coder5   r=   annotate_coverage_xml	gdb_debug
output_dirr@   s      r   test_options_with_valuesz*CmdLineParserTest.test_options_with_valuesc   s    - /
  	<.1/--/qr--{;,,m<++];66:(()66	B))*++];r   c                 :   t        dg      \  }}| j                  |j                  d        | j                          | j	                  |       t        g d      \  }}| j                  |j                  d       | j                          | j	                  |dg       y )Nr2   )--module-namefoo.barr2   rY   module_name)r   r$   rZ   r%   r.   r@   s      r   test_module_namez"CmdLineParserTest.test_module_name}   s    -/
  	,,d3))+""7+- /
  	,,i8))+""7]O<r   c                      d fd	} |dgd        |dg        |dg        |dg        |dg        |dg        |d	g        |d
dgd        |ddg        |ddg        |g dd        |g dd       y )Nc                    t         j                  }t               x}t         _        	 j                  t        t
        t        |              |t         _        |j                         j                         }j                  |       |r.j                  t        j                  ||      d|d|d       y y # |t         _        w xY w)N"z" does not match search ")sysstderrr   assertRaises
SystemExitr   listgetvaluestripr5   research)argsregex
old_stderrr`   r)   r   s        r   errorz,CmdLineParserTest.test_errors.<locals>.error   s    J"**,FSZ(!!*.@$t*M'
//#))+COOC 		% 5!$e!-.  (
s   $B7 7Cz-1zUnknown compiler flag: -1z-Iz--version=-az--version=--annotate=truez	--workingz--verbose=1z	--cleanupz --debug-disposal-code-wrong-namez	file3.pyxz2Unknown debug flag: debug_disposal_code_wrong_namerX   foo.pyxrY   )rX   rY   rl   zbar.pyxz5Only one source file allowed when using --module-name)rX   rY   rD   rl   z*Cannot use --module-name with --timestampsr    )r   rk   s   ` r   test_errorszCmdLineParserTest.test_errors   s    	. 	tf)	+tf~*+,{m}o{m1;?B	D	*+	*+@E	GE:	<r   N)__name__
__module____qualname__r   r"   r%   r.   rB   rJ   rV   r[   rn   rm   r   r   r   r      s;    &3 79 U 9; B4.-4<4=<r   r   )r_   rf   unittestr   r   ImportErrorior
   r   CmdLiner   r   r   rm   r   r   <module>rv      sJ    
 	 !  ( 79 	P< P<'  s   3 A A