o
    gyf                     @   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 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                   @      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 N )kwr   r   D/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/test/test_call.pyfn      z+FunctionCalls.test_kwargs_order.<locals>.fnr   )collectionsOrderedDictmove_to_endlistitemsZassertIsInstancedictassertEqual)selfZodexpectedr   resr   r   r   test_kwargs_order   s   
zFunctionCalls.test_kwargs_orderN)__name__
__module____qualname__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#dCS )D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_varargs3)      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_varargs1min-   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_varargs2min4   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_varargs1max8      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!   r0   r#   r   r   r   test_varargs2max<   r/   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_kw@   r)   z,CFunctionCallsErrorMessages.test_varargs1_kwc                 C      d}| j t|i jddd d S )Nr<   r   r>   yr   r#   r   r   r   test_varargs2_kwD   r/   z,CFunctionCallsErrorMessages.test_varargs2_kwc                 C      d}| j t|tdd d S )Nz#bool\(\) takes no keyword argumentsr   r=   )r    r!   boolr#   r   r   r   test_varargs3_kwH   r8   z,CFunctionCallsErrorMessages.test_varargs3_kwc                 C      d}| j t|g jdd d S )Nz-^list[.]index\(\) takes no keyword arguments$r   r=   )r    r!   indexr#   r   r   r   test_varargs4_kwL   r)   z,CFunctionCallsErrorMessages.test_varargs4_kwc                 C   rD   )Nz(^hasattr\(\) takes no keyword arguments$r   r=   )r    r!   hasattrr#   r   r   r   test_varargs5_kwP   r8   z,CFunctionCallsErrorMessages.test_varargs5_kwc                 C   rD   )Nz(^getattr\(\) takes no keyword arguments$r   r=   r3   r#   r   r   r   test_varargs6_kwT   r8   z,CFunctionCallsErrorMessages.test_varargs6_kwc                 C   rD   )Nz%^next\(\) takes no keyword arguments$r   r=   )r    r!   nextr#   r   r   r   test_varargs7_kwX   r8   z,CFunctionCallsErrorMessages.test_varargs7_kwc                 C      d}| j t|tjdd d S )Nz/^_struct[.]pack\(\) takes no keyword arguments$r   r=   )r    r!   structpackr#   r   r   r   test_varargs8_kw\   r)   z,CFunctionCallsErrorMessages.test_varargs8_kwc                 C   rO   )Nz4^_struct[.]pack_into\(\) takes no keyword arguments$r   r=   )r    r!   rP   	pack_intor#   r   r   r   test_varargs9_kw`   r)   z,CFunctionCallsErrorMessages.test_varargs9_kwc                 C   s    d}| j t|t jdd d S )Nz.^deque[.]index\(\) takes no keyword arguments$r   r=   )r    r!   r   dequerH   r#   r   r   r   test_varargs10_kwd   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   r=   )r    r!   rP   StructrQ   r#   r   r   r   test_varargs11_kwh   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_kwl   r8   z-CFunctionCallsErrorMessages.test_varargs12_kwc                 C   rZ   )Nz,^classmethod\(\) takes no keyword arguments$r[   )r    r!   classmethodr^   r#   r   r   r   test_varargs13_kwp   r8   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_kwt      

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   r9   )namepathrc   )r    r!   ImportErrorr#   r   r   r   test_varargs15_kwy   rg   z-CFunctionCallsErrorMessages.test_varargs15_kwc              	   C   rh   )Nz7^min\(\) takes at most 2 keyword arguments \(3 given\)$r   r   r   r9   )defaultkeyrc   )r    r!   minr#   r   r   r   test_varargs16_kw~   rg   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   r9         )sependfileflushrc   )r    r!   printr#   r   r   r   test_varargs17_kw   s   
z-CFunctionCallsErrorMessages.test_varargs17_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   r8   z+CFunctionCallsErrorMessages.test_oldargs0_1c                 C   r'   )Nz'keys\(\) takes no arguments \(2 given\)r   r   ry   r#   r   r   r   test_oldargs0_2   r)   z+CFunctionCallsErrorMessages.test_oldargs0_2c                 C   r;   )N#keys\(\) takes no keyword argumentsr   r=   ry   r#   r   r   r   test_oldargs0_1_kw   r)   z.CFunctionCallsErrorMessages.test_oldargs0_1_kwc                 C   r@   )Nr}   r   rA   ry   r#   r   r   r   test_oldargs0_2_kw   r/   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   r)   z+CFunctionCallsErrorMessages.test_oldargs1_2c                 C   rG   N$count\(\) takes no keyword argumentsr   r=   r   r#   r   r   r   test_oldargs1_0_kw   r)   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   r/   z.CFunctionCallsErrorMessages.test_oldargs1_1_kwc                 C   s   d}| j t|g jddd d S )Nr   r   rA   r   r#   r   r   r   test_oldargs1_2_kw   r/   z.CFunctionCallsErrorMessages.test_oldargs1_2_kwN)$r   r   r   r%   r(   r.   r2   r5   r7   r:   r?   rC   rF   rI   rK   rL   rN   rR   rT   rV   rY   r_   ra   rf   rl   rp   rx   r{   r|   r~   r   r   r   r   r   r   r   r   r   r   r      sD    r   c                   @   s   e Zd 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d0d1 Zd2S )3TestCallingConventionsa  Test calling using various C calling conventions (METH_*) from Python

    Subclasses test several kinds of functions (module-level, methods,
    class methods static methods) using these attributes:
      obj: the object that contains tested functions (as attributes)
      expected_self: expected "self" argument to the C function

    The base class tests module-level functions.
    c                 C   s   t  | _| _d S r
   )	_testcapiobjexpected_selfr   r   r   r   setUp   s   zTestCallingConventions.setUpc                 C   "   |  | jddd| jdf d S Nr   r   r9   r   r   r9   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   r9   rq   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   r8   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_ext   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   r9   rq   r   r   r   r   r   r   test_fastcall_keywords_ext2  s   z1TestCallingConventions.test_fastcall_keywords_extN)r   r   r   __doc__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Zdd ZdS )TestCallingConventionsInstancez?Test calling instance methods using various calling conventionsc                 C   s   t   | _| _d S r
   )r   MethInstancer   r   r   r   r   r   r   <  s   z$TestCallingConventionsInstance.setUpNr   r   r   r   r   r   r   r   r   r   9      r   c                   @   r   )TestCallingConventionsClassz<Test calling class methods using various calling conventionsc                 C   s   t j | _| _d S r
   r   	MethClassr   r   r   r   r   r   r   C  s   z!TestCallingConventionsClass.setUpNr   r   r   r   r   r   @  r   r   c                   @   r   )#TestCallingConventionsClassInstancez&Test calling class methods on instancec                 C   s   t  | _t j| _d S r
   r   r   r   r   r   r   J  s   
z)TestCallingConventionsClassInstance.setUpNr   r   r   r   r   r   G  r   r   c                   @   r   )TestCallingConventionsStaticz=Test calling static methods using various calling conventionsc                 C   s   t  | _d | _d S r
   )r   
MethStaticr   r   r   r   r   r   r   R  s   

z"TestCallingConventionsStatic.setUpNr   r   r   r   r   r   O  r   r   c                 C   s   | |gS r
   r   arg1arg2r   r   r   pyfuncW     r   c                   C      dS Nnoargr   r   r   r   r   pyfunc_noarg[  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   method`  r   zPythonClass.methodc                 C   r   r   r   r   r   r   r   method_noargc  r   zPythonClass.method_noargc                 C   r   )Nr`   r   )clsr   r   r   class_methodf     zPythonClass.class_methodc                   C   r   )Nr]   r   r   r   r   r   static_methodj  r   zPythonClass.static_methodN)	r   r   r   r   r   r`   r   r]   r   r   r   r   r   r   _  s    
r   c                   @   s6  e Zd 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 qwdd Zdd Zdd Zdd Z dd Z!dS )FastCallTestsz0Test calling using various callables from C
    r   r   r   r   r   r`   r]   )r   r   r   N){   r   r>   rB   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    q1 s4w   Y  qd S )Nr\   args)CALLS_POSARGSsubTestr   Zpyobject_fastcallr   )r   r\   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    q1 s6w   Y  q| jD ]+\}}}}| j|||d t|||}| || W d    q?1 sew   Y  q?d S )Nr   r\   r   kwargs)r   r   r   Zpyobject_fastcalldictr   CALLS_KWARGS)r   r\   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    q1 sPw   Y  q| jD ]9\}}}}| j|||d# t| }|t|  }t|||}| || W d    qY1 sw   Y  qYd S )Nr   r   r   )	r   r   r   pyobject_vectorcallr   r   r   rz   values)r   r\   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  )dont_inheritpassrW   exec)compiler   )r   r  r>   r   r   r   test_fastcall_clearing_dict  s   z)FastCallTests.test_fastcall_clearing_dict)"r   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  s    









r   i   i   c                 C   r	   zsome docNr   r   r   r   r   testfunction  r   r  c                C   r	   r  r   )r   r   r   r   r   testfunction_kw!  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   MethodDescriptorHeap7      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  B  r  r  )	r  r   r  r  Py_TPFLAGS_HAVE_VECTORCALLr  r  r  MethodDescriptor2)r   r  r   r   r   test_vectorcall_flag;  s   zTestPEP590.test_vectorcall_flagc                 C   s(   t td}t }| || | d S )Nrr   )r   ranger   r  ZassertIs)r   r   fr   r   r   test_vectorcall_overrideF  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    q^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    q1 sXw   Y  qd S )N*   r   )r   $   start   )r(  r   TF)r   pyvectorcall_call)
MethodType)partialc                    s&   g ||  R }t|} | ||S r
   )r   r   )r\   r   r   r   r   r   r   
vectorcallh  s   z.TestPEP590.test_vectorcall.<locals>.vectorcallc                   @   r  )z8TestPEP590.test_vectorcall.<locals>.MethodDescriptorHeapNr  r   r   r   r   r  v  r  r  c                   @   r   )z>TestPEP590.test_vectorcall.<locals>.MethodDescriptorOverriddenc                 S   r   )Nnewr   )r   nr   r   r   __call__z  r   zGTestPEP590.test_vectorcall.<locals>.MethodDescriptorOverridden.__call__N)r   r   r   r3  r   r   r   r   MethodDescriptorOverriddeny  s    r4  c                          e Zd Z fddZ  ZS )z-TestPEP590.test_vectorcall.<locals>.SuperBasec                       t  j| S r
   superr3  r   r   	__class__r   r   r3  ~     z6TestPEP590.test_vectorcall.<locals>.SuperBase.__call__r   r   r   r3  __classcell__r   r   r:  r   	SuperBase}      r?  c                       r5  )z9TestPEP590.test_vectorcall.<locals>.MethodDescriptorSuperc                    r6  r
   r7  r9  r:  r   r   r3    r<  zBTestPEP590.test_vectorcall.<locals>.MethodDescriptorSuper.__call__r=  r   r   r:  r   MethodDescriptorSuper  r@  rA  rn   r1  r   )lenr%  r   r  sumr  r  r   r  r  r#  r   r,  typesr-  r  r.  r   strr   r   update)r   Zcallsr,  r-  r.  r0  r\   r   r   r   r  r4  r?  rA  Zargs1methwrappedr   r/  r   r   P  s^   


 zTestPEP590.test_vectorcallN)r   r   r   r!  r$  r'  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   r>   rB   r   r   r   method_two_args  r   zA.method_two_argsc                   C   rJ  r
   r   r   r   r   r   static_no_args  r   zA.static_no_argsc                C   rJ  r
   r   argr   r   r   positional_only  r   zA.positional_onlyN)r   r   r   rK  r]   rL  rO  r   r   r   r   rI    s    
rI  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   rE  	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'r>   rT  rI  rK  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)rT  rI  rL  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'r>   rM  )rT  rI  rO  r#   r   r   r   &test_positional_only_passed_as_keyword  rW  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'r>   )ZbadrU  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'r>   rB   Zoopsr=   rU  r#   r   r   r   test_multiple_values  s   "z6TestErrorMessagesUseQualifiedName.test_multiple_valuesN)r   r   r   
contextlibcontextmanagerrT  rV  rX  rY  rZ  r[  r   r   r   r   rP    s    
rP  __main__)"ZunittestZtest.supportr   r   rk   rP   r   rd   r   r\  ZTestCaser   r   r   r   r   r   r   r   r   r   r	  objectr   r   r"  r  r  r  r  rI  rP  r   mainr   r   r   r   <module>   sP       &w"