o
    GXhh                     @   s  d dl Z d dlmZ zd dlZW n ey   dZY nw d dlZd dlZd dlZd dlZd dl	Z	G dd de
ZG dd de jZeG dd de jZG d	d
 d
e jZG dd deZG dd deZG dd deZG dd deZdd Zdd ZG dd dZe Ze ZG dd de jZdZdZdd Zdd  ZG d!d" d"e jZG d#d$ d$Z eG d%d& d&e jZ!e"d'kre #  dS dS )(    N)cpython_onlyc                   @   s   e Zd Zdd Zdd ZdS )BadStrc                 C      dS )NT )selfotherr   r   8/opt/python-3.10.19/usr/lib/python3.10/test/test_call.py__eq__      zBadStr.__eq__c                 C   s   t | dA S )N   )str__hash__r   r   r   r   r      s   zBadStr.__hash__N)__name__
__module____qualname__r	   r   r   r   r   r   r      s    r   c                   @      e Zd Zdd ZdS )FunctionCallsc                 C   s^   t ddg}|d t| }dd }|di |}| |t | t| | d S )N)a   )b   r   c                  [   s   | S Nr   )kwr   r   r   fn   r
   z+FunctionCalls.test_kwargs_order.<locals>.fnr   )collectionsOrderedDictmove_to_endlistitemsZassertIsInstancedictassertEqual)r   Zodexpectedr   resr   r   r   test_kwargs_order   s   
zFunctionCalls.test_kwargs_orderN)r   r   r   r$   r   r   r   r   r      s    r   c                   @   s$  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGS )HCFunctionCallsErrorMessagesc                 C   s   d}|  t|i j d S )Nz7__contains__\(\) takes exactly one argument \(0 given\)assertRaisesRegex	TypeError__contains__r   msgr   r   r   test_varargs0)      z)CFunctionCallsErrorMessages.test_varargs0c                 C      d}|  t|i jdd d S )Nz7__contains__\(\) takes exactly one argument \(2 given\)r   r   r&   r*   r   r   r   test_varargs2-      z)CFunctionCallsErrorMessages.test_varargs2c                 C   s   d}|  t|tjddd d S )Nz@^from_bytes\(\) takes exactly 2 positional arguments \(3 given\)   alittleF)r'   r(   int
from_bytesr*   r   r   r   test_varargs31      z)CFunctionCallsErrorMessages.test_varargs3c                 C   s,   d}|  t|i j d}|  t|i j d S )Nz'get expected at least 1 argument, got 0zexpected 1 argument, got 0)r'   r(   get__delattr__r*   r   r   r   test_varargs1min5   s   z,CFunctionCallsErrorMessages.test_varargs1minc                 C   s   d}|  t|t d S )Nz,getattr expected at least 2 arguments, got 0r'   r(   getattrr*   r   r   r   test_varargs2min<   s   z,CFunctionCallsErrorMessages.test_varargs2minc                 C   s   d}|  t|tdd d S )Nz(input expected at most 1 argument, got 2r   r   )r'   r(   inputr*   r   r   r   test_varargs1max@      z,CFunctionCallsErrorMessages.test_varargs1maxc                 C   s   d}|  t|i jddd d S )Nz'get expected at most 2 arguments, got 3r   r   r   )r'   r(   r7   r*   r   r   r   test_varargs2maxD   r6   z,CFunctionCallsErrorMessages.test_varargs2maxc                 C      d}| j t|i jdd d S )N+__contains__\(\) takes no keyword argumentsr   xr&   r*   r   r   r   test_varargs1_kwH   r0   z,CFunctionCallsErrorMessages.test_varargs1_kwc                 C      d}| j t|i jddd d S )NrB   r   rD   yr&   r*   r   r   r   test_varargs2_kwL   r6   z,CFunctionCallsErrorMessages.test_varargs2_kwc                 C      d}| j t|tdd d S )Nz#bool\(\) takes no keyword argumentsr   rC   )r'   r(   boolr*   r   r   r   test_varargs3_kwP   r?   z,CFunctionCallsErrorMessages.test_varargs3_kwc                 C      d}| j t|g jdd d S )Nz-^list[.]index\(\) takes no keyword arguments$r   rC   )r'   r(   indexr*   r   r   r   test_varargs4_kwT   r0   z,CFunctionCallsErrorMessages.test_varargs4_kwc                 C   rJ   )Nz(^hasattr\(\) takes no keyword arguments$r   rC   )r'   r(   hasattrr*   r   r   r   test_varargs5_kwX   r?   z,CFunctionCallsErrorMessages.test_varargs5_kwc                 C   rJ   )Nz(^getattr\(\) takes no keyword arguments$r   rC   r:   r*   r   r   r   test_varargs6_kw\   r?   z,CFunctionCallsErrorMessages.test_varargs6_kwc                 C   rJ   )Nz%^next\(\) takes no keyword arguments$r   rC   )r'   r(   nextr*   r   r   r   test_varargs7_kw`   r?   z,CFunctionCallsErrorMessages.test_varargs7_kwc                 C      d}| j t|tjdd d S )Nz/^_struct[.]pack\(\) takes no keyword arguments$r   rC   )r'   r(   structpackr*   r   r   r   test_varargs8_kwd   r0   z,CFunctionCallsErrorMessages.test_varargs8_kwc                 C   rU   )Nz4^_struct[.]pack_into\(\) takes no keyword arguments$r   rC   )r'   r(   rV   	pack_intor*   r   r   r   test_varargs9_kwh   r0   z,CFunctionCallsErrorMessages.test_varargs9_kwc                 C   s    d}| j t|t jdd d S )Nz.^deque[.]index\(\) takes no keyword arguments$r   rC   )r'   r(   r   dequerN   r*   r   r   r   test_varargs10_kwl   s   z-CFunctionCallsErrorMessages.test_varargs10_kwc                 C   s&   d}| j t|tjjtddd d S )Nz.^Struct[.]pack\(\) takes no keyword arguments$ r   rC   )r'   r(   rV   StructrW   r*   r   r   r   test_varargs11_kwp   s   "z-CFunctionCallsErrorMessages.test_varargs11_kwc                 C      d}| j t|ttd d S )Nz-^staticmethod\(\) takes no keyword arguments$func)r'   r(   staticmethodidr*   r   r   r   test_varargs12_kwt   r?   z-CFunctionCallsErrorMessages.test_varargs12_kwc                 C   r`   )Nz,^classmethod\(\) takes no keyword arguments$ra   )r'   r(   classmethodrd   r*   r   r   r   test_varargs13_kwx   r?   z-CFunctionCallsErrorMessages.test_varargs13_kwc                 C   s    d}| j t|tjdddd d S )Nz:^product\(\) takes at most 1 keyword argument \(2 given\)$r   r   r   )repeatfoo)r'   r(   	itertoolsproductr*   r   r   r   test_varargs14_kw|      

z-CFunctionCallsErrorMessages.test_varargs14_kwc              	   C       d}| j t|tddddd d S )Nz?^ImportError\(\) takes at most 2 keyword arguments \(3 given\)$r   r   r   r   )namepathri   )r'   r(   ImportErrorr*   r   r   r   test_varargs15_kw   rm   z-CFunctionCallsErrorMessages.test_varargs15_kwc              	   C   rn   )Nz7^min\(\) takes at most 2 keyword arguments \(3 given\)$r   r   r   r   )defaultkeyri   )r'   r(   minr*   r   r   r   test_varargs16_kw   rm   z-CFunctionCallsErrorMessages.test_varargs16_kwc                 C   s$   d}| j t|tddddddd	 d S )	Nz9^print\(\) takes at most 4 keyword arguments \(5 given\)$r   r   r   r         )sependfileflushri   )r'   r(   printr*   r   r   r   test_varargs17_kw   s   
z-CFunctionCallsErrorMessages.test_varargs17_kwc                 C   sL   d}|  t| tdi tddi W d    d S 1 sw   Y  d S )Nz'invalid keyword argument for print\(\)$r   r   ri   ,)r   r   )r'   r(   r}   r   r*   r   r   r   test_varargs18_kw      "z-CFunctionCallsErrorMessages.test_varargs18_kwc                 C   sL   d}|  t| tdi tddi W d    d S 1 sw   Y  d S )Nz'invalid keyword argument for round\(\)$      ?ri   r   )r   )r'   r(   roundr   r*   r   r   r   test_varargs19_kw   r   z-CFunctionCallsErrorMessages.test_varargs19_kwc                 C   s   d}|  t|i jd d S )Nz'keys\(\) takes no arguments \(1 given\)r   r'   r(   keysr*   r   r   r   test_oldargs0_1   r?   z+CFunctionCallsErrorMessages.test_oldargs0_1c                 C   r.   )Nz'keys\(\) takes no arguments \(2 given\)r   r   r   r*   r   r   r   test_oldargs0_2   r0   z+CFunctionCallsErrorMessages.test_oldargs0_2c                 C   rA   )N#keys\(\) takes no keyword argumentsr   rC   r   r*   r   r   r   test_oldargs0_1_kw   r0   z.CFunctionCallsErrorMessages.test_oldargs0_1_kwc                 C   rF   )Nr   r   rG   r   r*   r   r   r   test_oldargs0_2_kw   r6   z.CFunctionCallsErrorMessages.test_oldargs0_2_kwc                 C   s   d}|  t|g j d S )Nz0count\(\) takes exactly one argument \(0 given\)r'   r(   countr*   r   r   r   test_oldargs1_0   r-   z+CFunctionCallsErrorMessages.test_oldargs1_0c                 C   s   d}|  t|g jdd d S )Nz0count\(\) takes exactly one argument \(2 given\)r   r   r   r*   r   r   r   test_oldargs1_2   r0   z+CFunctionCallsErrorMessages.test_oldargs1_2c                 C   rM   N$count\(\) takes no keyword argumentsr   rC   r   r*   r   r   r   test_oldargs1_0_kw   r0   z.CFunctionCallsErrorMessages.test_oldargs1_0_kwc                 C   s   d}| j t|g ji dd d S r   r   r*   r   r   r   test_oldargs1_1_kw   r6   z.CFunctionCallsErrorMessages.test_oldargs1_1_kwc                 C   s   d}| j t|g jddd d S )Nr   r   rG   r   r*   r   r   r   test_oldargs1_2_kw   r6   z.CFunctionCallsErrorMessages.test_oldargs1_2_kwN)&r   r   r   r,   r/   r5   r9   r<   r>   r@   rE   rI   rL   rO   rQ   rR   rT   rX   rZ   r\   r_   re   rg   rl   rr   rv   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r%   &   sH    r%   c                   @   s   e Zd Z	 dd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1S )2TestCallingConventionsc                 C   s   t  | _| _d S r   )	_testcapiobjexpected_selfr   r   r   r   setUp   s   zTestCallingConventions.setUpc                 C   "   |  | jddd| jdf d S Nr   r   r   r   r   r   r!   r   meth_varargsr   r   r   r   r   test_varargs      z#TestCallingConventions.test_varargsc                 C      |  | jjd | jdf d S Nr   r   r   r   r   r   test_varargs_ext      
z'TestCallingConventions.test_varargs_extc                       d}  t| fdd d S )Nz+meth_varargs\(\) takes no keyword argumentsc                          j jddS Nr   )k)r   r   r   r   r   r   <lambda>       z>TestCallingConventions.test_varargs_error_kw.<locals>.<lambda>r'   r(   r*   r   r   r   test_varargs_error_kw      z,TestCallingConventions.test_varargs_error_kwc                 C   .   |  | jjddddd| jddddf d S Nr   r   r   rw   r   r   r   r   r!   r   meth_varargs_keywordsr   r   r   r   r   test_varargs_keywords      z,TestCallingConventions.test_varargs_keywordsc                 C   s6   |  | jjddgi ddd| jddddf d S r   r   r   r   r   r   test_varargs_keywords_ext   s   z0TestCallingConventions.test_varargs_keywords_extc                 C   s   |  | jd| jdf d S Nr   r!   r   meth_or   r   r   r   r   test_o   s   zTestCallingConventions.test_oc                 C   s    |  | jjdg | jdf d S r   r   r   r   r   r   
test_o_ext   s    z!TestCallingConventions.test_o_extc                 C   s   d}|  t|| jj d S )Nz1meth_o\(\) takes exactly one argument \(0 given\))r'   r(   r   r   r*   r   r   r   test_o_error_no_arg   r?   z*TestCallingConventions.test_o_error_no_argc                    r   )Nz1meth_o\(\) takes exactly one argument \(2 given\)c                          j ddS Nr   r   r   r   r   r   r   r   r      r   z>TestCallingConventions.test_o_error_two_args.<locals>.<lambda>r   r*   r   r   r   test_o_error_two_args   r   z,TestCallingConventions.test_o_error_two_argsc                    r   )Nz1meth_o\(\) takes exactly one argument \(3 given\)c                          j jd S r   r   r   r   r   r   r         z9TestCallingConventions.test_o_error_ext.<locals>.<lambda>r   r*   r   r   r   test_o_error_ext   r   z'TestCallingConventions.test_o_error_extc                    r   )N%meth_o\(\) takes no keyword argumentsc                      r   r   r   r   r   r   r   r     r   z8TestCallingConventions.test_o_error_kw.<locals>.<lambda>r   r*   r   r   r   test_o_error_kw  r   z&TestCallingConventions.test_o_error_kwc                    r   )Nr   c                      r   r   r   r   r   r   r   r     r   z<TestCallingConventions.test_o_error_arg_kw.<locals>.<lambda>r   r*   r   r   r   test_o_error_arg_kw
  r   z*TestCallingConventions.test_o_error_arg_kwc                 C   s   |  | j | j d S r   r!   r   meth_noargsr   r   r   r   r   test_noargs  s   z"TestCallingConventions.test_noargsc                 C   s   |  | jjg  | j d S r   r   r   r   r   r   test_noargs_ext  s   z&TestCallingConventions.test_noargs_extc                    r   )Nz.meth_noargs\(\) takes no arguments \(1 given\)c                      s    j dS r   r   r   r   r   r   r   r     r   z>TestCallingConventions.test_noargs_error_arg.<locals>.<lambda>r   r*   r   r   r   test_noargs_error_arg  r   z,TestCallingConventions.test_noargs_error_argc                    r   )Nz.meth_noargs\(\) takes no arguments \(2 given\)c                      r   r   r   r   r   r   r   r     r   z?TestCallingConventions.test_noargs_error_arg2.<locals>.<lambda>r   r*   r   r   r   test_noargs_error_arg2  r   z-TestCallingConventions.test_noargs_error_arg2c                    r   )Nz.meth_noargs\(\) takes no arguments \(3 given\)c                      r   r   r   r   r   r   r   r   %  r   z>TestCallingConventions.test_noargs_error_ext.<locals>.<lambda>r   r*   r   r   r   test_noargs_error_ext"  r   z,TestCallingConventions.test_noargs_error_extc                    r   )Nz*meth_noargs\(\) takes no keyword argumentsc                      r   r   r   r   r   r   r   r   +  r   z=TestCallingConventions.test_noargs_error_kw.<locals>.<lambda>r   r*   r   r   r   test_noargs_error_kw(  r   z+TestCallingConventions.test_noargs_error_kwc                 C   r   r   r!   r   meth_fastcallr   r   r   r   r   test_fastcall.  r   z$TestCallingConventions.test_fastcallc                 C   r   r   r   r   r   r   r   test_fastcall_ext4  r   z(TestCallingConventions.test_fastcall_extc                    r   )Nz,meth_fastcall\(\) takes no keyword argumentsc                      r   r   )r   r   r   r   r   r   r   =  r   z?TestCallingConventions.test_fastcall_error_kw.<locals>.<lambda>r   r*   r   r   r   test_fastcall_error_kw:  r   z-TestCallingConventions.test_fastcall_error_kwc                 C   r   r   r!   r   meth_fastcall_keywordsr   r   r   r   r   test_fastcall_keywords@  r   z-TestCallingConventions.test_fastcall_keywordsc                 C   s2   |  | jjdi ddd| jddddf d S )Nr   r   rw   r   r   r   r   r   r   test_fastcall_keywords_extF  s   z1TestCallingConventions.test_fastcall_keywords_extN)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      s4    
r   c                   @      e Zd Z	 dd ZdS )TestCallingConventionsInstancec                 C   s   t   | _| _d S r   )r   MethInstancer   r   r   r   r   r   r   P  s   z$TestCallingConventionsInstance.setUpNr   r   r   r   r   r   r   r   r   M      r   c                   @   r   )TestCallingConventionsClassc                 C   s   t j | _| _d S r   r   	MethClassr   r   r   r   r   r   r   W  s   z!TestCallingConventionsClass.setUpNr   r   r   r   r   r   T  r   r   c                   @   r   )#TestCallingConventionsClassInstancec                 C   s   t  | _t j| _d S r   r   r   r   r   r   r   ^  s   
z)TestCallingConventionsClassInstance.setUpNr   r   r   r   r   r   [  r   r   c                   @   r   )TestCallingConventionsStaticc                 C   s   t  | _d | _d S r   )r   
MethStaticr   r   r   r   r   r   r   f  s   

z"TestCallingConventionsStatic.setUpNr   r   r   r   r   r   c  r   r   c                 C   s   | |gS r   r   arg1arg2r   r   r   pyfunck     r   c                   C   r   Nnoargr   r   r   r   r   pyfunc_noargo  r
   r   c                   @   s4   e Zd Zdd Zdd Zedd Zedd Zd	S )
PythonClassc                 C   s   ||gS r   r   )r   r   r   r   r   r   methodt  r   zPythonClass.methodc                 C   r   r   r   r   r   r   r   method_noargw  r
   zPythonClass.method_noargc                 C   r   )Nrf   r   )clsr   r   r   class_methodz     zPythonClass.class_methodc                   C   r   )Nrc   r   r   r   r   r   static_method~  r   zPythonClass.static_methodN)	r   r   r   r   r   rf   r   rc   r   r   r   r   r   r   s  s    
r   c                   @   s4  e Zd Z	 edddgfeddfejddfejddfej	dddgfej
ddfejddfejddfgZedd	diddgfedddd
ddgfej	dd	diddgfej	dddd
ddgfgZe Zeefeefejejfe ejfejdffD ]\ZZeejdedffejdedeffejdedffejdedffejdedeffejdedeffejdefejdedffg eejdddiedddiffejdddiedddiffejdi edeffejdddiedddiffejdddiedddiffejdi edeffg qvdd Zdd Zdd Zdd Zdd Z dS )FastCallTestsr   r   r   r   r   rf   rc   )r   r   r   N){   r   rD   rH   c                 C   sP   t |tr |d tu r |d i d fv r g |d d |d R }| || d S )N)
isinstancetupleNULL_OR_EMPTYr!   )r   resultr"   r   r   r   check_result  s   zFastCallTests.check_resultc              	   C   sx   | j D ]6\}}}| j||d" t||}| || |s*t|d }| || W d    n1 s4w   Y  qd S )Nrb   args)CALLS_POSARGSsubTestr   Zpyobject_fastcallr   )r   rb   r   r"   r   r   r   r   r     s   zFastCallTests.test_fastcallc              	   C   s   | j D ]8\}}}| j||d$ t||d }| || |s,t|d d }| || W d    n1 s6w   Y  q| jD ]+\}}}}| j|||d t|||}| || W d    n1 sew   Y  q?d S )Nr   rb   r   kwargs)r   r   r   Zpyobject_fastcalldictr   CALLS_KWARGS)r   rb   r   r"   r   r   r   r   r   test_vectorcall_dict  s"   
z"FastCallTests.test_vectorcall_dictc              	   C   s*  | j D ]R\}}}| j||d> t||d }| || t||d}| || |sFt|d d }| || t|d d}| || W d    n1 sPw   Y  q| jD ]9\}}}}| j|||d# t| }|t|  }t|||}| || W d    n1 sw   Y  qYd S )Nr   r   r   )	r   r   r   pyobject_vectorcallr   r  r   r   values)r   rb   r   r"   r   r   kwnamesr   r   r   test_vectorcall  s.   zFastCallTests.test_vectorcallc                 C   s6   G dd d}|| d}t ddd|fi |j d S )Nc                   @   s"   e Zd ZdgZdd Zdd ZdS )z>FastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDictr   c                 [   s
   || _ d S r   )r   )r   r   r   r   r   __init__  s   
zGFastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDict.__init__c                 S   s   | j   t  dS )Nr   )r   cleargcZcollectr   r   r   r   	__index__!  s   
zHFastCallTests.test_fastcall_clearing_dict.<locals>.IntWithDict.__index__N)r   r   r   	__slots__r  r
  r   r   r   r   IntWithDict  s    r  )optimizepassr]   exec)compiler   )r   r  rD   r   r   r   test_fastcall_clearing_dict  s   z)FastCallTests.test_fastcall_clearing_dict)!r   r   r   r   r   r   r   r   PYTHON_INSTANCEr   r   r   r  r   r   Z	_instancer   r   r   r   extendr   r   r   r   r   r   r   r   r   r  r  r  r   r   r   r   r     s    









r   i   i   c                 C      	 | S r   r   r   r   r   r   testfunction0     r  c                C   r  r   r   )r   r   r   r   r   testfunction_kw5  r  r  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )

TestPEP590c                 C   s   dd l }|dt}| ttjt@  | tt	j
jt@  | tt	jjt@  | ttjt@  | t|jt@  | tjjt@  | tjjt@  | tjjt@  G dd dtj}| |jt@  d S )Nr   r   c                   @      e Zd ZdS )zDTestPEP590.test_method_descriptor_flag.<locals>.MethodDescriptorHeapNr   r   r   r   r   r   r   MethodDescriptorHeapK      r  )	functools	lru_cacher  assertFalsetyperepr	__flags__Py_TPFLAGS_METHOD_DESCRIPTOR
assertTruer   append__add__r   MethodDescriptorBaseMethodDescriptorDerivedMethodDescriptorNopGet)r   r  cachedr  r   r   r   test_method_descriptor_flag<  s   z&TestPEP590.test_method_descriptor_flagc                 C   sn   |  tjjt@  |  tjjt@  | tjjt@  |  tjjt@  G dd dtj}| |jt@  d S )Nc                   @   r  )z=TestPEP590.test_vectorcall_flag.<locals>.MethodDescriptorHeapNr  r   r   r   r   r  V  r  r  )	r$  r   r'  r"  Py_TPFLAGS_HAVE_VECTORCALLr(  r  r)  MethodDescriptor2)r   r  r   r   r   test_vectorcall_flagO  s   zTestPEP590.test_vectorcall_flagc                 C   s(   t td}t }| || | d S )Nrx   )r   ranger   r)  ZassertIs)r   r   fr   r   r   test_vectorcall_overrideZ  s   z#TestPEP590.test_vectorcall_overridec                    s  t tdfi dftjg dfi d fg jdi d ftdgfddidftdi dftddd idft di d	ft	 di d	ft
 di d
fg	}ddlm m} ddlm} ddlm}  fdd}|D ]2\}}}}	| t| |sw| |	||| | |	|||| W d    n1 sw   Y  q^G dd dtj}
G dd dtj}G dd d}G dd d|tj}|tji fdd	id fi ji fdd	id f|
 di d	f| di df| di d	fg7 }|D ]\}}}}	| t|i |dd  }|||d }||}|s"| |	||  | |	 ||d  | |	||  | |	||  | |	||i | | |	|||| | |	||i | | |	||i | W d    n	1 sXw   Y  qd S )N*   r   )r   $   start   )r2  r   TF)r  pyvectorcall_call)
MethodType)partialc                    s&   g ||  R }t|} | ||S r   )r  r   )rb   r   r   r  r  r   r   
vectorcall|  s   z.TestPEP590.test_vectorcall.<locals>.vectorcallc                   @   r  )z8TestPEP590.test_vectorcall.<locals>.MethodDescriptorHeapNr  r   r   r   r   r    r  r  c                   @   r   )z>TestPEP590.test_vectorcall.<locals>.MethodDescriptorOverriddenc                 S   r   )Nnewr   )r   nr   r   r   __call__  r
   zGTestPEP590.test_vectorcall.<locals>.MethodDescriptorOverridden.__call__N)r   r   r   r=  r   r   r   r   MethodDescriptorOverridden  s    r>  c                          e Zd Z fddZ  ZS )z-TestPEP590.test_vectorcall.<locals>.SuperBasec                       t  j| S r   superr=  r   r   	__class__r   r   r=       z6TestPEP590.test_vectorcall.<locals>.SuperBase.__call__r   r   r   r=  __classcell__r   r   rD  r   	SuperBase      rI  c                       r?  )z9TestPEP590.test_vectorcall.<locals>.MethodDescriptorSuperc                    r@  r   rA  rC  rD  r   r   r=    rF  zBTestPEP590.test_vectorcall.<locals>.MethodDescriptorSuper.__call__rG  r   r   rD  r   MethodDescriptorSuper  rJ  rK  rt   r;  r   )lenr/  r   r%  sumr  r  r   r'  r(  r-  r  r6  typesr7  r  r8  r   r   r!   r    update)r   Zcallsr6  r7  r8  r:  rb   r   r   r"   r  r>  rI  rK  Zargs1methwrappedr   r9  r   r  d  sb   


zTestPEP590.test_vectorcallN)r   r   r   r+  r.  r1  r  r   r   r   r   r  :  s
    
r  c                   @   s,   e Zd Zdd Zedd Zedd ZdS )Ac                 C      d S r   r   )r   rD   rH   r   r   r   method_two_args  r
   zA.method_two_argsc                   C   rS  r   r   r   r   r   r   static_no_args  r   zA.static_no_argsc                C   rS  r   r   argr   r   r   positional_only  r   zA.positional_onlyN)r   r   r   rT  rc   rU  rX  r   r   r   r   rR    s    
rR  c                   @   sB   e Zd Zejdd Zdd Zdd Zdd Zd	d
 Z	dd Z
dS )!TestErrorMessagesUseQualifiedNamec                 c   sH    |  t}d V  W d    n1 sw   Y  | t|j| d S r   )ZassertRaisesr(   r!   r   	exception)r   messagecmr   r   r   check_raises_type_error  s
   z9TestErrorMessagesUseQualifiedName.check_raises_type_errorc                 C   s@   d}|  | t d W d    d S 1 sw   Y  d S )Nz?A.method_two_args() missing 1 required positional argument: 'y'rD   r]  rR  rT  r*   r   r   r   test_missing_arguments     "z8TestErrorMessagesUseQualifiedName.test_missing_argumentsc                 C   s>   d}|  | td W d    d S 1 sw   Y  d S )Nz?A.static_no_args() takes 0 positional arguments but 1 was givenzoops it's an arg)r]  rR  rU  r*   r   r   r   test_too_many_positional  s   "z:TestErrorMessagesUseQualifiedName.test_too_many_positionalc                 C   s@   d}|  | tjdd W d    d S 1 sw   Y  d S )NzYA.positional_only() got some positional-only arguments passed as keyword arguments: 'arg'rD   rV  )r]  rR  rX  r*   r   r   r   &test_positional_only_passed_as_keyword  r`  zHTestErrorMessagesUseQualifiedName.test_positional_only_passed_as_keywordc                 C   sB   d}|  | t jdd W d    d S 1 sw   Y  d S )Nz<A.method_two_args() got an unexpected keyword argument 'bad'rD   )Zbadr^  r*   r   r   r   test_unexpected_keyword  s   "z9TestErrorMessagesUseQualifiedName.test_unexpected_keywordc                 C   sF   d}|  | t jdddd W d    d S 1 sw   Y  d S )Nz8A.method_two_args() got multiple values for argument 'x'rD   rH   ZoopsrC   r^  r*   r   r   r   test_multiple_values  s   "z6TestErrorMessagesUseQualifiedName.test_multiple_valuesN)r   r   r   
contextlibcontextmanagerr]  r_  ra  rb  rc  rd  r   r   r   r   rY    s    
rY  __main__)$ZunittestZtest.supportr   r   rq   rV   r   rj   r	  re  r   r   ZTestCaser   r%   r   r   r   r   r   r   r   r   r  objectr   r   r,  r#  r  r  r  rR  rY  r   mainr   r   r   r   <module>   sR       &w"