HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_clinic.cpython-310.opt-2.pyc
o

�i#��@s�ddlmZmZddlmZmZddlmZddlZddl	Z	ddl
ZddlZddlZe�
d�e�d��ddlZddlmZWd�n1sIwYGdd�d�ZGd	d
�d
�ZGdd�d�Zejd
dd�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd�d�ZGdd�de�ZGdd�de�ZGd d!�d!e�Ze�d"�Z Gd#d$�d$ej�Z!e"d%kr�e�#�dSdS)&�)�support�
test_tools)�
import_helper�	os_helper)�TestCaseN�clinic)�	DSLParserc@�eZdZdd�ZdS)�
FakeConvertercCs||_||_dS�N)�name�args��selfrr
�r�-/usr/local/lib/python3.10/test/test_clinic.py�__init__s
zFakeConverter.__init__N)�__name__�
__module__�__qualname__rrrrrr
�r
c@�eZdZdd�Zdd�ZdS)�FakeConverterFactorycCs
||_dSr�r�rrrrrr�
zFakeConverterFactory.__init__cKst|j|�Sr)r
r)rr�default�kwargsrrr�__call__�zFakeConverterFactory.__call__N)rrrrrrrrrr�rc@r)�FakeConvertersDictcCs
i|_dSr)�used_converters�rrrrr#rzFakeConvertersDict.__init__cCs|j�|t|��Sr)r"�
setdefaultr)rrrrrr�get&szFakeConvertersDict.getN)rrrrr%rrrrr!"r r!�C�file)�language�filenamec@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	j
Z
dS)�
FakeCliniccCs�t�|_t�|_t�d�|_d|_i|_t�d|j�|_	t
��|_t
��|_
|t_d|_d|_|_i|_|�dd�|�dd�|�dd�|jj}t
�d|d�fd|d�fd	|d�fd
|d�fd|d�fd|d�fd
|d�ff�|_dS)N�r*�block�bufferr'�suppressZdocstring_prototypeZdocstring_definitionZmethoddef_defineZimpl_prototypeZparser_prototypeZparser_definitionZimpl_definition)r!Z
convertersZlegacy_convertersr�	CLanguager(r)Zdestination_buffers�BlockParserZblock_parser�collections�OrderedDict�modulesZclassesrZline_prefixZline_suffix�destinations�add_destinationr%Zfield_destinations)r�drrrr,s2








�zFakeClinic.__init__cCs&|j�|�}|st�dt|��|S)NzDestination does not exist: )r4r%�sys�exit�repr)rrr6rrr�get_destinationGszFakeClinic.get_destinationcGs<||jvrt�dt|��tj|||g|�R�|j|<dS)NzDestination already exists: )r4r7r8r9rZDestination)rr�typer
rrrr5Ms
 zFakeClinic.add_destinationcCs|dkS)N�modulerrrrr�is_directiveRszFakeClinic.is_directivecCs||j|<dSr)Zcalled_directivesrrrr�	directiveU�zFakeClinic.directiveN)rrrrr:r5r=r>r�ClinicZ_module_and_classrrrrr*+sr*c@r	)�ClinicWholeFileTestcCsNtjt�d�dd�}d}|�|���}|d��}|�|d�|�|d�dS)Nr'�r)z/*[clinic]
foo
[clinic]*/�z[clinic]*/[clinic]*/z
[clinic]*/)rr@r/�parse�
splitlines�rstripZassertNotEqual�assertEqual)r�c�rawZcookedZend_linerrr�test_eol[s	zClinicWholeFileTest.test_eolN)rrrrJrrrrrAZrrAc@�<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ClinicGroupPermuterTestcCst�|||�}|�||�dSr)r�permute_optional_groupsrG)r�l�m�r�output�computedrrr�_testpszClinicGroupPermuterTest._testcCs|�dggdgdggd�dS)N�start�stop�step))rU)rTrU)rTrUrV�rSr#rrr�
test_rangets�z"ClinicGroupPermuterTest.test_rangecCs |�ddggdgdggd�dS)N�x�y�ch�attr))r[)r[r\)rYrZr[)rYrZr[r\rWr#rrr�test_add_window|��z'ClinicGroupPermuterTest.test_add_windowcCs.|�gd�ddggdgddggd�gd�dS)	N)�a1�a2�a3�b1�b2�c1�d1�d2)�e1�e2�e3))rd)rbrcrd)rbrcrdrerf)r_r`rarbrcrd)r_r`rarbrcrdrerf)r_r`rarbrcrdrerfrgrhrirWr#rrr�test_ludicrous�s$�z&ClinicGroupPermuterTest.test_ludicrouscCs |�ggdgdgdggd�dS)N�a�brH)r�rk�rkrl�rkrlrHrWr#rrr�test_right_only�r^z'ClinicGroupPermuterTest.test_right_onlycCsdd�}|�t|�dS)NcSst�dggg�dS)Nrk)rrMrrrr�fn�szPClinicGroupPermuterTest.test_have_left_options_but_required_is_empty.<locals>.fn)�assertRaises�AssertionError)rrqrrr�,test_have_left_options_but_required_is_empty�szDClinicGroupPermuterTest.test_have_left_options_but_required_is_emptyN)	rrrrSrXr]rjrprtrrrrrLos		rLc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ClinicLinearFormatTestcKs"tj|fi|��}|�||�dSr)rZ
linear_formatrG)r�inputrQrrRrrrrS�szClinicLinearFormatTest._testcC�|�dd�dS)Nr+rWr#rrr�test_empty_strings��z)ClinicLinearFormatTest.test_empty_stringscCrw)N�
rWr#rrr�test_solo_newline�ryz(ClinicLinearFormatTest.test_solo_newlinecCrw)Nz
          abc
          rWr#rrr�test_no_substitution�s�z+ClinicLinearFormatTest.test_no_substitutioncC�|jdddd�dS)N�8
          abc
          {name}
          def
          z'
          abc
          def
          r+rrWr#rrr�test_empty_substitution�s
�z.ClinicLinearFormatTest.test_empty_substitutioncCr})Nr~z8
          abc
          GARGLE
          def
          ZGARGLErrWr#rrr�test_single_line_substitution�s
�z4ClinicLinearFormatTest.test_single_line_substitutioncCr})Nr~zJ
          abc
          bingle
          bungle

          def
          zbingle
bungle
rrWr#rrr�test_multiline_substitution�s
�z2ClinicLinearFormatTest.test_multiline_substitutionN)
rrrrSrxr{r|rr�r�rrrrru�s
ruc@r)�InertParsercC�dSrr�rrrrrr��zInertParser.__init__cCr�rr�rr,rrrrD�r�zInertParser.parseN�rrrrrDrrrrr��r r�c@r)�
CopyParsercCr�rrr�rrrr�r�zCopyParser.__init__cCs|j|_dSr)rvrQr�rrrrD�rzCopyParser.parseNr�rrrrr��r r�c@rK)�ClinicBlockParserTestcCsFt�d�}tt�||��}t�|�}|D]}|�|�q|j��}dSr)rr/�listr0ZBlockPrinterZprint_block�f�getvalue)rrvrQr(Zblocks�writerr,rrrrS�s

zClinicBlockParserTest._testcCs|�||�SrrW)rrvrrr�
round_trip�rz ClinicBlockParserTest.round_tripcC�|�d�dS)Nz(
    verbatim text here
    lah dee dah
�r�r#rrr�test_round_trip_1�r?z'ClinicBlockParserTest.test_round_trip_1cCr�)Nz�
    verbatim text here
    lah dee dah
/*[inert]
abc
[inert]*/
def
/*[inert checksum: 7b18d017f89f61cf17d47f92749ea6930a3f1deb]*/
xyz
r�r#rrr�test_round_trip_2�r?z'ClinicBlockParserTest.test_round_trip_2cCsNt�d�}tj|dd�}t|�|jd<t|�|jd<|�|�}|�||�dS)Nr'rBZinert�copy)rr/r@r��parsersr�rDrG)rrvrQr(rHrRrrr�_test_clinics

z"ClinicBlockParserTest._test_cliniccCs|�dd�dS)Nz�
    verbatim text here
    lah dee dah
/*[copy input]
def
[copy start generated code]*/
abc
/*[copy end generated code: output=03cfd743661f0797 input=7b18d017f89f61cf]*/
xyz
z�
    verbatim text here
    lah dee dah
/*[copy input]
def
[copy start generated code]*/
def
/*[copy end generated code: output=7b18d017f89f61cf input=7b18d017f89f61cf]*/
xyz
)r�r#rrr�
test_clinic_1	s	�z#ClinicBlockParserTest.test_clinic_1N)	rrrrSr�r�r�r�r�rrrrr��s
r�c@sfeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dZdUdV�Z,dWdX�Z-dYS)[�ClinicParserTestcCsHtt��}t�d�}|�|�|j\}}|�d|j�|�d|j�dS)Nzmodule os
os.access�access�os)rr*r�BlockrD�
signaturesrGr)r�parserr,r<�functionrrr�test_trivial s



zClinicParserTest.test_trivialcCs4|�d�}|j\}}|�d|j�|�d|j�dS)Nz#
module os
os.accessr�r�)rDr�rGr�rr,r<r�rrr�test_ignore_line(s

z!ClinicParserTest.test_ignore_linecCsV|�d�}|�d|j�|�dt|j��|jd}|�d|j�|�|jtj�dS)Nz module os
os.access
   path: intr�rC�path)	�parse_functionrGr�len�
parameters�assertIsInstance�	converterr�
int_converter�rr��prrr�
test_param.s

zClinicParserTest.test_paramcC�&|�d�}|jd}|�d|j�dS)Nz4module os
os.access
    follow_symlinks: bool = True�follow_symlinksT�r�r�rGrr�rrr�test_param_default6�

z#ClinicParserTest.test_param_defaultcCr�)NzCmodule os
os.access
    follow_symlinks: \
   bool \
   =\
    Truer�Tr�r�rrr�test_param_with_continuations;r�z.ClinicParserTest.test_param_with_continuationscCsN|�d�}|jd}|�tj|j�|�d|jj�|�d�}|�|d�dS)NzOmodule os
os.access
    follow_symlinks: int(c_default='MAXSIZE') = sys.maxsizer�ZMAXSIZEz:module os
os.access
    follow_symlinks: int = sys.maxsizez~Error on line 0:
When you specify a named constant ('sys.maxsize') as your default value,
you MUST specify a valid c_default.
)	r�r�rGr7�maxsizerr�Z	c_default�parse_function_should_fail)rr�r��srrr�test_param_default_expression@s


z.ClinicParserTest.test_param_default_expressioncCs@|�d�}|jd}|�dt|j��|�|jdjtj�dS)NzR
module os
os.access
    follow_symlinks: bool = True
    something_else: str = ''r��Zsomething_else)r�r�rGr�r�r�r�
str_converterr�rrr�test_param_no_docstringIs

z(ClinicParserTest.test_param_no_docstringcC�|�d�}|�|d�dS)NzM
module os
os.access
    follow_symlinks: bool = True
    something_else: strzoError on line 0:
Can't have a parameter without a default ('something_else')
after a parameter with a default!
�r�rG�rr�rrr�*test_param_default_parameters_out_of_orderSs
z;ClinicParserTest.test_param_default_parameters_out_of_ordercCs,|�d�}|jd}|�d|jjd�dS)Nz0module os
os.access
    path: path_t(allow_fd=1)r��Zallow_fd)r�r�rGr�r
r�rrr�!disabled_test_converter_arguments^s

z2ClinicParserTest.disabled_test_converter_argumentscC� |�d�}|�d��|j�dS)Nzx
module os
os.stat as os_stat_fn

   path: str
       Path to be examined

Perform a stat system call on the given path.zj
stat($module, /, path)
--

Perform a stat system call on the given path.

  path
    Path to be examined
�r�rG�strip�	docstring�rr�rrr�test_function_docstringcs
�z(ClinicParserTest.test_function_docstringcCr�)Nz|
module foo
foo.bar
  x: int
     Documentation for x.
  y: int

This is the documentation for foo.

Okay, we're done here.
zt
bar($module, /, x, y)
--

This is the documentation for foo.

  x
    Documentation for x.

Okay, we're done here.
r�r�rrr�%test_explicit_parameters_in_docstringvs

�z6ClinicParserTest.test_explicit_parameters_in_docstringcC�|�d�}|�d|j�dS)Nz<
module os
os.stat
    path: str
This/used to break Clinic!
z5stat($module, /, path)
--

This/used to break Clinic!)r�rGr�r�rrr�Ttest_parser_regression_special_character_in_parameter_column_of_docstring_first_line�s
zeClinicParserTest.test_parser_regression_special_character_in_parameter_column_of_docstring_first_linecCr�)Nzmodule os
os.stat as os_stat_fnZ
os_stat_fn)r�rGZ
c_basenamer�rrr�test_c_name�s
zClinicParserTest.test_c_namecCs|�d�}|�|jtj�dS)Nzmodule os
os.stat -> int)r�r�Zreturn_converterrZint_return_converterr�rrr�test_return_converter�s
z&ClinicParserTest.test_return_convertercCs8|�d�}|jd}|�tjj|j�|�d|j�dS)Nz:module os
os.access
    *
    follow_symlinks: bool = Truer�r)r�r�rG�inspect�	ParameterZKEYWORD_ONLY�kind�groupr�rrr�	test_star�s

zClinicParserTest.test_starcCr�)Nz/module window
window.border
 [
 ls : int
 ]
 /
Zlsr�)r�r�rGr�r�rrr�
test_group�r�zClinicParserTest.test_groupcC�\|�d�}dD]\}}|j|}|�|j|�|�|jtjj�q|�|j�	�d�	��dS)Nz�
module curses
curses.addch
   [
   y: int
     Y-coordinate.
   x: int
     X-coordinate.
   ]
   ch: char
     Character to add.
   [
   attr: long
     Attributes for the character.
   ]
   /
))rZ���)rYr��r[r)r\r�z�
addch([y, x,] ch, [attr])


  y
    Y-coordinate.
  x
    X-coordinate.
  ch
    Character to add.
  attr
    Attributes for the character.
            �
r�r�rGr�r�r�r�ZPOSITIONAL_ONLYr�r��rr�rr�r�rrr�test_left_group�s

�z ClinicParserTest.test_left_groupcCr�)Na
module curses
curses.imaginary
   [
   [
   y1: int
     Y-coordinate.
   y2: int
     Y-coordinate.
   ]
   x1: int
     X-coordinate.
   x2: int
     X-coordinate.
   ]
   ch: char
     Character to add.
   [
   attr1: long
     Attributes for the character.
   attr2: long
     Attributes for the character.
   attr3: long
     Attributes for the character.
   [
   attr4: long
     Attributes for the character.
   attr5: long
     Attributes for the character.
   attr6: long
     Attributes for the character.
   ]
   ]
   /
))Zy1���)Zy2r�)Zx1r�)Zx2r�r�)Zattr1r�)Zattr2r�)Zattr3r�)Zattr4rC)Zattr5rC)Zattr6rCa�
imaginary([[y1, y2,] x1, x2,] ch, [attr1, attr2, attr3, [attr4, attr5,
          attr6]])


  y1
    Y-coordinate.
  y2
    Y-coordinate.
  x1
    X-coordinate.
  x2
    X-coordinate.
  ch
    Character to add.
  attr1
    Attributes for the character.
  attr2
    Attributes for the character.
  attr3
    Attributes for the character.
  attr4
    Attributes for the character.
  attr5
    Attributes for the character.
  attr6
    Attributes for the character.
                r�r�rrr�test_nested_groups�s
#
�z#ClinicParserTest.test_nested_groupsc	Cs~t���/}|�t��
|�|�Wd�n1swYWd�|��SWd�|��S1s6wY|��Sr)r�captured_stdoutrr�
SystemExitr�r�)rr��stdoutrrrr�s
�
��
��z+ClinicParserTest.parse_function_should_failcCr�)Nz|
module foo
foo.two_top_groups_on_left
    [
    group1 : int
    ]
    [
    group2 : int
    ]
    param: int
            zpError on line 0:
Function two_top_groups_on_left has an unsupported group configuration. (Unexpected state 2.b)
r�r�rrr�0test_disallowed_grouping__two_top_groups_on_left$s
�zAClinicParserTest.test_disallowed_grouping__two_top_groups_on_leftcCr�)Nz}
module foo
foo.two_top_groups_on_right
    param: int
    [
    group1 : int
    ]
    [
    group2 : int
    ]
            �r�r#rrr�1test_disallowed_grouping__two_top_groups_on_right4r?zBClinicParserTest.test_disallowed_grouping__two_top_groups_on_rightcCr�)Nz�
module foo
foo.parameter_after_group_on_right
    param: int
    [
    [
    group1 : int
    ]
    group2 : int
    ]
            r�r#rrr�8test_disallowed_grouping__parameter_after_group_on_rightAr?zIClinicParserTest.test_disallowed_grouping__parameter_after_group_on_rightcCr�)Nz�
module foo
foo.group_after_parameter_on_left
    [
    group2 : int
    [
    group1 : int
    ]
    ]
    param: int
            r�r#rrr�7test_disallowed_grouping__group_after_parameter_on_leftNr?zHClinicParserTest.test_disallowed_grouping__group_after_parameter_on_leftcCr�)Nz`
module foo
foo.empty_group
    [
    [
    ]
    group2 : int
    ]
    param: int
            r�r#rrr�-test_disallowed_grouping__empty_group_on_left[r?z>ClinicParserTest.test_disallowed_grouping__empty_group_on_leftcCr�)Nz`
module foo
foo.empty_group
    param: int
    [
    [
    ]
    group2 : int
    ]
            r�r#rrr�.test_disallowed_grouping__empty_group_on_rightgr?z?ClinicParserTest.test_disallowed_grouping__empty_group_on_rightcCs.|�d�}|�d|j�|�dt|j��dS)Nz 
module foo
foo.bar

Docstring

zbar($module, /)
--

Docstringr��r�rGr�r�r�r�rrr�test_no_parametersss
z#ClinicParserTest.test_no_parameterscCs4|jdddd�}|�d|j�|�dt|j��dS)NzL
module foo
class foo.Bar "unused" "notneeded"
foo.Bar.__init__

Docstring

r�rC)�signatures_in_block�function_indexzBar()
--

Docstringr�r�r�rrr�test_init_with_no_parameters~s
�	z-ClinicParserTest.test_init_with_no_parameterscCr�)Nz!
module foo
foo.bar => int
    /
r�r#rrr�test_illegal_module_line�r?z)ClinicParserTest.test_illegal_module_linecCr�)Nz!
module foo
foo.bar as 935
    /
r�r#rrr�test_illegal_c_basename�r?z(ClinicParserTest.test_illegal_c_basenamecCr�)Nz 
module foo
foo.bar
    *
    *
r�r#rrr�test_single_star�r?z!ClinicParserTest.test_single_starcCr�)Nz
module foo
foo.bar
    *
r�r#rrr�Ktest_parameters_required_after_star_without_initial_parameters_or_docstring�r?z\ClinicParserTest.test_parameters_required_after_star_without_initial_parameters_or_docstringcCr�)Nz*
module foo
foo.bar
    *
Docstring here.
r�r#rrr�Mtest_parameters_required_after_star_without_initial_parameters_with_docstring�r?z^ClinicParserTest.test_parameters_required_after_star_without_initial_parameters_with_docstringcCr�)Nz(
module foo
foo.bar
    this: int
    *
r�r#rrr�Mtest_parameters_required_after_star_with_initial_parameters_without_docstring�r?z^ClinicParserTest.test_parameters_required_after_star_with_initial_parameters_without_docstringcCr�)Nz3
module foo
foo.bar
    this: int
    *
Docstring.
r�r#rrr�Itest_parameters_required_after_star_with_initial_parameters_and_docstring�r?zZClinicParserTest.test_parameters_required_after_star_with_initial_parameters_and_docstringcCr�)Nz 
module foo
foo.bar
    /
    /
r�r#rrr�test_single_slash�r?z"ClinicParserTest.test_single_slashcCr�)Nz<
module foo
foo.bar
   x: int
   y: int
   *
   z: int
   /
r�r#rrr�test_mix_star_and_slash�r?z(ClinicParserTest.test_mix_star_and_slashcCr�)Nz%
module foo
foo.bar
    /
    x: int
r�r#rrr�1test_parameters_not_permitted_after_slash_for_now�r?zBClinicParserTest.test_parameters_not_permitted_after_slash_for_nowcCr�)Nzk
  module foo
  foo.bar
    x: int
      Nested docstring here, goeth.
    *
    y: str
  Not at column 0!
zV
bar($module, /, x, *, y)
--

Not at column 0!

  x
    Nested docstring here, goeth.
r�r�rrr�test_function_not_at_column_0�s
	�z.ClinicParserTest.test_function_not_at_column_0csJt�}t|��d�_�fdd��jd<t�d�}��|�|��j�dS)NFcst�dd�S)N�flagT)�setattrr�r�rr�<lambda>�sz1ClinicParserTest.test_directive.<locals>.<lambda>Zsetflag)r*rr�Z
directivesrr�rDZ
assertTrue)rrHr,rr�r�test_directive�s

zClinicParserTest.test_directivecCs.|�d�}|j\}}|�|jdjtj�dS)Nz module os
os.access
   path: "s"r�)rDr�r�r�r�rr�r�rrr�test_legacy_converters�s

z'ClinicParserTest.test_legacy_converterscCs&t�}t|�}t�|�}|�|�|Sr)r*rrr�rD)r�textrHr�r,rrrrD�s


zClinicParserTest.parserCr�cCs(|�|�}|j}|�t|�|�||Sr)rDr�rGr�)rr�r�r�r,r�rrrr�s
zClinicParserTest.parse_functionc	Cs�|�ttj�d�|�ttj�d�t���%}|�t��tj	dddd�Wd�n1s/wYWd�n1s>wY|�|�
�d�dS)Nz
<Unspecified>z<Null>zThe igloos are melting!z	clown.txt�E)r)Zline_numberz>Error in file "clown.txt" on line 69:
The igloos are melting!
)rGr9r�unspecifiedZNULLrr�rrr�Zfailr�)rr�rrr�test_scaffoldings
���z!ClinicParserTest.test_scaffoldingN)rCr�).rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rDr�r�rrrrr�sX	
	(L


		
r�c@seZdZdZdd�ZdS)�ClinicExternalTestNc		Cs"t�d�}t|ddd��}|��}Wd�n1swYt���W}tj�|d�}t|ddd��
}|�	|�Wd�n1sCwYt�
|�j}t�
|�t|ddd��}|��}Wd�n1siwYt�
|�j}Wd�n1s~wY|�||�|�||�dS)Nzclinic.testrPzutf-8)�encodingz
clinic.test.c�w)rZfindfile�open�readrZtemp_dirr�r��join�write�stat�st_mtime_nsrZ
parse_filerG)	r�sourcer�Z
orig_contentsZtmp_dirZtestfileZold_mtime_nsZnew_contentsZnew_mtime_nsrrr�
test_externals$

�
�

��z ClinicExternalTest.test_external)rrrZmaxDiffrrrrrr�sr�Z_testclinicc@sneZdZe��dd�ee�D��dd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z d7d8�Z!d9d:�Z"d;d<�Z#d=d>�Z$d?d@�Z%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)dIdJ�Z*dKdL�Z+dMdN�Z,dOdP�Z-dQdR�Z.dSdT�Z/dUS)V�ClinicFunctionalTestccs(�|]}|�d�r|tt|�fVqdS)Ztest_N)�
startswith�getattr�	ac_tester)�.0rrrr�	<genexpr>;s�
�zClinicFunctionalTest.<genexpr>cCst|�t��t��Wd�n1swY|�t�dd�d�|�t�gd�gdf�|�t�d�d�dS)Nr�rC�r�rCzwhatever class)r�N)rr�	TypeErrorr	Zobjects_converterrGr#rrr�test_objects_converter>s
�z+ClinicFunctionalTest.test_objects_convertercC�J|�t��
t�d�Wd�n1swY|�t�d�d�dS)Nr��BytesObject)r)rrr
r	Zbytes_object_converterrGr#rrr�test_bytes_object_converterE��z0ClinicFunctionalTest.test_bytes_object_convertercCsT|�t��
t�d�Wd�n1swYtd�}|�t�|�|f�dS)Nr�sByteArrayObject)rrr
r	Zbyte_array_object_converter�	bytearrayrG)rZbyte_arrrrr� test_byte_array_object_converterJs
�z5ClinicFunctionalTest.test_byte_array_object_convertercCr)Nr��unicode)r)rrr
r	Zunicode_converterrGr#rrr�test_unicode_converterPrz+ClinicFunctionalTest.test_unicode_convertercCs||�t��t�ddd�Wd�n1swY|�t��d�|�t�dgd�d�|�t�ddd	id
�d�dS)NFz	not a int)TTTr+�)FFT)z	not emptyr�rCr)TTF)rrr
r	Zbool_converterrGr#rrr�test_bool_converterUs�z(ClinicFunctionalTest.test_bool_convertercCs�|�t��
t�d�Wd�n1swY|�t��
t�d�Wd�n1s/wYgd�}tdd�|D��}|�t��|�gd�}tdd�|D��}|�tj|�|�dS)Nr�sab)�A���	�
���
�"�'�?�\���cs��|]}t|�VqdSr��ord�r
rHrrrrb��z;ClinicFunctionalTest.test_char_converter.<locals>.<genexpr>)�1�2�3�4�5�6�7�8�9�0�a�b�c�dcsr'rr(r*rrrrer+)rrr
r	Zchar_converter�tuplerG)r�charsZexpectedrrr�test_char_converter\s��z(ClinicFunctionalTest.test_char_convertercCs6ddlm}|�t��
t�d�Wd�n1swY|�t��t�|d�Wd�n1s7wY|�t��t�d|d�Wd�n1sTwY|�t��
t�g�Wd�n1snwY|�t��d�|�t�dd|d�d�|�t�dd|ddd�d	�dS)
Nr)�	UCHAR_MAXr�r����"�8�rrrr��{�rrrC)�	_testcapir=rr�
OverflowErrorr	Zunsigned_char_converterr
rG)rr=rrr�test_unsigned_char_converterh� ����&z1ClinicFunctionalTest.test_unsigned_char_convertercCs�ddlm}m}|�t��t�|d�Wd�n1swY|�t��t�|d�Wd�n1s;wY|�t��
t�g�Wd�n1sUwY|�t�d�d�|�t�d�d�dS)Nr)�SHRT_MIN�SHRT_MAXr��.����rK��)rM)	rErIrJrrrFr	Zshort_converterr
rG)rrIrJrrr�test_short_convertervs���z)ClinicFunctionalTest.test_short_convertercC�6ddlm}|�t��
t�d�Wd�n1swY|�t��t�|d�Wd�n1s7wY|�t��t�d|d�Wd�n1sTwY|�t��
t�g�Wd�n1snwY|�t��d�|�t�dd|d�d�|�t�dd|ddd�d	�dS)
Nr)�	USHRT_MAXr�r�r>rBr�rCrD)	rErPrr�
ValueErrorr	Zunsigned_short_converterrFr
rG)rrPrrr�test_unsigned_short_converter�rHz2ClinicFunctionalTest.test_unsigned_short_convertercCs ddlm}m}|�t��t�|d�Wd�n1swY|�t��t�|d�Wd�n1s;wY|�t��t�ddd�Wd�n1sWwY|�t��
t�g�Wd�n1sqwY|�t��d�|�t�ddd�ddt	d�f�dS)Nr)�INT_MIN�INT_MAXr�rCr�)r?r@�-�3)
rErSrTrrrFr	r�r
rGr))rrSrTrrr�test_int_converter�s����$z'ClinicFunctionalTest.test_int_convertercCrO)
Nr)�UINT_MAXr�r�r>rBr�rCrD)	rErXrrrQr	Zunsigned_int_converterrFr
rG)rrXrrr�test_unsigned_int_converter�rHz0ClinicFunctionalTest.test_unsigned_int_convertercC��ddlm}m}|�t��t�|d�Wd�n1swY|�t��t�|d�Wd�n1s;wY|�t��
t�g�Wd�n1sUwY|�t��d�|�t�d�d�dS)Nr)�LONG_MIN�LONG_MAXr��r?rKrL)	rEr[r\rrrFr	Zlong_converterr
rG)rr[r\rrr�test_long_converter�����z(ClinicFunctionalTest.test_long_convertercCrO)
Nr)�	ULONG_MAXr�r�r>rBr�rCrD)	rEr`rrrQr	Zunsigned_long_converterrFr
rG)rr`rrr�test_unsigned_long_converter�rHz1ClinicFunctionalTest.test_unsigned_long_convertercCrZ)Nr)�	LLONG_MIN�	LLONG_MAXr�r]rKrL)	rErbrcrrrFr	Zlong_long_converterr
rG)rrbrcrrr�test_long_long_converter�r_z-ClinicFunctionalTest.test_long_long_convertercCrO)
Nr)�
ULLONG_MAXr�r�r>rBr�rCrD)	rErerrrQr	Zunsigned_long_long_converterrFr
rG)rrerrr�!test_unsigned_long_long_converter�rHz6ClinicFunctionalTest.test_unsigned_long_long_convertercCs�ddlm}m}|�t��t�|d�Wd�n1swY|�t��t�|d�Wd�n1s;wY|�t��
t�g�Wd�n1sUwY|�t��d�|�t�ddd�d�dS)Nr��PY_SSIZE_T_MIN�PY_SSIZE_T_MAXr�r>rC�r�rCrA)	rErhrirrrFr	Zpy_ssize_t_converterr
rG�rrhrirrr�test_py_ssize_t_converter�s���z.ClinicFunctionalTest.test_py_ssize_t_convertercCs�ddlm}m}|�t��
t�g�Wd�n1swY|�t��d�|�t�ddd�d�|�t�||d|d�|||f�|�t�||d|d�|||f�dS)Nrrgr>r�rCrji�)rErhrirrr
r	Zslice_index_converterrGrkrrr�test_slice_index_converter�s���z/ClinicFunctionalTest.test_slice_index_convertercCs||�t��
t�d�Wd�n1swY|�t��
t�g�Wd�n1s/wY|�t��d�dS)Nr�r])rrrQr	Zsize_t_converterr
rGr#rrr�test_size_t_converter�s��z*ClinicFunctionalTest.test_size_t_convertercC�Z|�t��
t�g�Wd�n1swY|�t��d�|�t�d�d�dS�N)g)@�࿩rq)rrr
r	Zfloat_converterrGr#rrr�test_float_converter��
�z)ClinicFunctionalTest.test_float_convertercCrorp)rrr
r	Zdouble_converterrGr#rrr�test_double_converter�rtz*ClinicFunctionalTest.test_double_convertercCs�|�t��
t�g�Wd�n1swY|�t�tdd��tdd�f�|�t�td��td�f�|�t�d�d�|�t�d�d�dS)Nr�rCz-1-2jrqrr�
)rv)rrr
r	Zpy_complex_converterrG�complexr#rrr�test_py_complex_converters� z.ClinicFunctionalTest.test_py_complex_convertercCs�|�t��
t�d�Wd�n1swY|�t��t�ddd�Wd�n1s1wY|�t��t�ddd�Wd�n1sMwY|�t�ddd�d�|�t�ddd�d�|�t�ddd	�d
�dS)Nr�rkrlrH�bbr7ror8�cc�rkrlrz)rrr
r	r�rQrGr#rrr�test_str_converter
s���z'ClinicFunctionalTest.test_str_convertercCs�|�t��
t�d�Wd�n1swY|�t�ddd�d�|�t��t�ddd�Wd�n1s<wY|�t�ddttd�g��d�|�t�ddttd�dtd�g��d	�|�t�ddd
�d	�dS)Nr�rkrlrHroryr7rr{scc)rrr
r	Zstr_converter_encodingrGrr)r#rrr�test_str_converter_encodings�� "�z0ClinicFunctionalTest.test_str_converter_encodingcCsV|�t��t�dd�Wd�n1swY|�t�dtgd���d�dS)Nrkrl�abc�r�rCr�)sabcs)rrr
r	Zpy_buffer_converterrGrr#rrr�test_py_buffer_converter#s� z-ClinicFunctionalTest.test_py_buffer_convertercCsD|�t�dd�d�|�tjddd�d�|�tjddd�d�dS)Nr�rCr�rlrn)rGr	�keywordsr#rrr�
test_keywords(sz"ClinicFunctionalTest.test_keywordscCsf|�t��t�dd�Wd�n1swY|�tjddd�d�|�tjddd�d�dS)Nr�rCr�rrn)rrr
r	Zkeywords_kwonlyrGr#rrr�test_keywords_kwonly-s
�z)ClinicFunctionalTest.test_keywords_kwonlycCs�|�t�d�d�|�t�dd�d�|�t�ddd�d�|�tjddd�d�|�tjdddd�d�|�tjddd	�d
�|�tjdddd�d�dS)Nr��r�NNrC�r�rCNr�rr��rH�rkrH�r�Nr�ro)rGr	Zkeywords_optr#rrr�test_keywords_opt3sz&ClinicFunctionalTest.test_keywords_optcCs�|�t�d�d�|�t�dd�d�|�t��t�ddd�Wd�n1s*wY|�tjddd�d�|�tjdddd�d�|�tjddd	�d
�|�tjddddd�d
�dS)Nr��r�NNNrC�r�rCNNr�r�r��r�rCr�Nr�)r�Nr�N��rkrlrHr6�r�rCr�r�)rGr	Zkeywords_opt_kwonlyrrr
r#rrr�test_keywords_opt_kwonly<s�z-ClinicFunctionalTest.test_keywords_opt_kwonlycCs�|�t�d�d�|�t��t�dd�Wd�n1swY|�tjddd�d�|�tjddd�d�|�tjdddd	�d
�dS)Nr�r�rCr�r�r�r�r�ror)rGr	Zkeywords_kwonly_optrrr
r#rrr�test_keywords_kwonly_optFs�z-ClinicFunctionalTest.test_keywords_kwonly_optcCs�|�t��
t�d�Wd�n1swY|�t��tjddd�Wd�n1s1wY|�t�dd�d�|�tjddd�d�dS)Nr�rCrnrr�)rrr
r	Zposonly_keywordsrGr#rrr�test_posonly_keywordsNs��z*ClinicFunctionalTest.test_posonly_keywordscCs�|�t��
t�d�Wd�n1swY|�t��t�dd�Wd�n1s0wY|�t��tjddd�Wd�n1sLwY|�tjddd�d�dS)Nr�rCrnr�r)rrr
r	Zposonly_kwonlyrGr#rrr�test_posonly_kwonlyVs���z(ClinicFunctionalTest.test_posonly_kwonlycCs�|�t��
t�d�Wd�n1swY|�t��t�ddd�Wd�n1s1wY|�t��tjdddd�Wd�n1sNwY|�tjdddd�d�|�tjdddd�d�dS)Nr�rCr�ror�r�rlrH)rrr
r	Zposonly_keywords_kwonlyrGr#rrr�test_posonly_keywords_kwonly_s���z1ClinicFunctionalTest.test_posonly_keywords_kwonlycCs�|�t��
t�d�Wd�n1swY|�t�dd�d�|�t�ddd�d�|�t�dddd�d�|�tjddd�d�|�tjdddd	�d�|�t��tjddddd
�Wd�n1skwY|�tjddddd�d�dS)Nr�rCr�r�r�r�r�r�r�r��rlrHr6)rrr
r	Zposonly_keywords_optrGr#rrr�test_posonly_keywords_optis��z.ClinicFunctionalTest.test_posonly_keywords_optcCs|�t�d�d�|�t�dd�d�|�t�ddd�d�|�t�dddd�d�|�t��tjddd	�Wd�n1sAwY|�tjdddd
�d�|�tjddddd�d�|�t��tjddddd�Wd�dS1sywYdS)
Nr�r�rCr�r�r�r�r�r�r��rHr6r�)rGr	Zposonly_opt_keywords_optrrr
r#rrr�test_posonly_opt_keywords_optus�"�z2ClinicFunctionalTest.test_posonly_opt_keywords_optcCs�|�t��
t�d�Wd�n1swY|�t��t�dd�Wd�n1s0wY|�tjddd�d�|�tjdddd�d�|�tjddddd	�d
�|�t��tjddddd�Wd�dS1sswYdS)Nr�rCr�r�r�r�r�r�r�r�r�)rrr
r	Zposonly_kwonly_optrGr#rrr�test_posonly_kwonly_opt�s��"�z,ClinicFunctionalTest.test_posonly_kwonly_optcCs�|�t�d�d�|�t�dd�d�|�t��t�ddd�Wd�n1s*wY|�t��tjddd�Wd�n1sFwY|�tjdddd�d�|�tjdddd	d
�d�dS)Nr�r�rCr�r�r�r�r�r�r�r�)rGr	Zposonly_opt_kwonly_optrrr
r#rrr�test_posonly_opt_kwonly_opt�s��z0ClinicFunctionalTest.test_posonly_opt_kwonly_optc	Cs~|�t��
t�d�Wd�n1swY|�t��t�dd�Wd�n1s0wY|�t��tjddd�Wd�n1sLwY|�t��t�ddd�Wd�n1shwY|�t��tjdddd�Wd�n1s�wY|�tjdddd�d�|�tjdddd�d�|�tjdddd	d
�d�|�tjdddd	dd
�d�dS)Nr�rCr�r�ror��r�rCr�NNr�r�r��r�rCr�r�Nr�rHr6�e�r�rCr�r�r)rrr
r	Zposonly_keywords_kwonly_optrGr#rrr� test_posonly_keywords_kwonly_opt�s&����� z5ClinicFunctionalTest.test_posonly_keywords_kwonly_optc	Csp|�t��
t�d�Wd�n1swY|�t�dd�d�|�tjddd�d�|�t��t�dddd�Wd�n1sGwY|�t��tjddd�Wd�n1scwY|�tjdddd�d	�|�tjdddd
�d	�|�tjddddd�d�|�tjddddd
�d�|�tjdddddd�d�|�tjdddddd�d�dS)Nr�rC)r�rCNNNr�r�r�rnr�r�r��r6r�r�r)r6r�r�r�)rrr
r	Zposonly_keywords_opt_kwonly_optrGr#rrr�$test_posonly_keywords_opt_kwonly_opt�s"��� z9ClinicFunctionalTest.test_posonly_keywords_opt_kwonly_optcCs|�t�d�d�|�t�dd�d�|�t��tjddd�Wd�n1s*wY|�t�ddd�d�|�tjdddd�d�|�tjdddd	d
�d�|�tjdddd	d�d�|�t��t�dddd	�Wd�dS1sywYdS)
Nr�r�rCr�r�r�r�r�r�r�r�r�)rGr	Z#posonly_opt_keywords_opt_kwonly_optrrr
r#rrr�(test_posonly_opt_keywords_opt_kwonly_opt�s�"�z=ClinicFunctionalTest.test_posonly_opt_keywords_opt_kwonly_optcCs~|�t��t��Wd�n1swY|�t��
t�d�Wd�n1s.wY|�tjdd�d�dS)Nr�rm)r�)rrr
r	Zkeyword_only_parameterrGr#rrr�test_keyword_only_parameter�s
��z0ClinicFunctionalTest.test_keyword_only_parametercCsBd}|�t|��t�dd�Wd�dS1swYdS)NzVgh_99240_double_free\(\) argument 2 must be encoded string without null bytes, not strrkzb)ZassertRaisesRegexr
r	Zgh_99240_double_free)rZexpected_errorrrr�test_gh_99240_double_free�s"�z.ClinicFunctionalTest.test_gh_99240_double_freeN)0rrr�locals�update�dirr	rrrrrr<rGrNrRrWrYr^rardrfrlrmrnrsrurxr|r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr:sZ�
	
	

r�__main__)$�testrrZtest.supportrrZunittestrr1r�Zos.pathr�r7Zskip_if_missingZimports_under_toolrrr
rr!r@rHr*rArLrur�r�r�r�r��
import_moduler	rr�mainrrrr�<module>sJ
�/04=~
�