o
    HXh!%                     @   sh   d dl Z d dlmZ G dd de jZG dd de jZejG dd de jZed	kr2e 	  dS dS )
    N)supportc                   @   sT   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S )TestMROEntryc                    st   g G dd d}G  fddd   }|  g  G dd d||}|  d ||ff |  d i  d S )	Nc                   @      e Zd ZdS )z0TestMROEntry.test_mro_entry_signature.<locals>.BN__name__
__module____qualname__ r	   r	   @/opt/python-3.10.19/usr/lib/python3.10/test/test_genericclass.pyB       r   c                          e Zd Z fddZdS )z0TestMROEntry.test_mro_entry_signature.<locals>.Cc                    s    ||g  fS Nextend)selfargskwargsCtestedr	   r
   __mro_entries__
   s   z@TestMROEntry.test_mro_entry_signature.<locals>.C.__mro_entries__Nr   r   r   r   r	   r   r	   r
   r   	       r   c                   @   r   )z0TestMROEntry.test_mro_entry_signature.<locals>.DNr   r	   r	   r	   r
   D   r   r   r      )assertEqual)r   r   cr   r	   r   r
   test_mro_entry_signature   s   z%TestMROEntry.test_mro_entry_signaturec                    s   g  G dd d}G dd d}G  fddd}| }|   g  G dd d|||}|   d	 |||f |  |j|||f |  |j|||f |  |j||||tf | }G d
d d|}|   d	 |f |  |j|f d S )Nc                   @   r   )z&TestMROEntry.test_mro_entry.<locals>.ANr   r	   r	   r	   r
   A   r   r   c                   @   r   )z&TestMROEntry.test_mro_entry.<locals>.BNr   r	   r	   r	   r
   r      r   r   c                          e Zd Z fddZdS )z&TestMROEntry.test_mro_entry.<locals>.Cc                    s     | | jfS r   )append	__class__r   basesr   r	   r
   r      s   
z6TestMROEntry.test_mro_entry.<locals>.C.__mro_entries__Nr   r	   r%   r	   r
   r          r   c                   @   r   )z&TestMROEntry.test_mro_entry.<locals>.DNr   r	   r	   r	   r
   r      r   r   c                   @   r   )z&TestMROEntry.test_mro_entry.<locals>.ENr   r	   r	   r	   r
   E#   r   r(   r   	__bases____orig_bases____mro__object)r   r   r   r   r   r   dr(   r	   r%   r
   test_mro_entry   s   zTestMROEntry.test_mro_entryc                    s  g  G dd d}G dd d}G  fddd}| }|   g  G dd d|||}|   d	 |||f |  |j||f |  |j|||f |  |j|||tf G d
d d|}|   d	 |f |  |jtf |  |j|f |  |j|tf d S )Nc                   @   r   )z+TestMROEntry.test_mro_entry_none.<locals>.ANr   r	   r	   r	   r
   r   )   r   r   c                   @   r   )z+TestMROEntry.test_mro_entry_none.<locals>.BNr   r	   r	   r	   r
   r   *   r   r   c                       r    )z+TestMROEntry.test_mro_entry_none.<locals>.Cc                    s     | dS Nr	   r!   r#   r%   r	   r
   r   ,   s   
z;TestMROEntry.test_mro_entry_none.<locals>.C.__mro_entries__Nr   r	   r%   r	   r
   r   +   r&   r   c                   @   r   )z+TestMROEntry.test_mro_entry_none.<locals>.DNr   r	   r	   r	   r
   r   1   r   r   r'   c                   @   r   )z+TestMROEntry.test_mro_entry_none.<locals>.ENr   r	   r	   r	   r
   r(   6   r   r(   r)   )r   r   r   r   r   r   r(   r	   r%   r
   test_mro_entry_none'   s    z TestMROEntry.test_mro_entry_nonec                    s   g  G dd d}G  fddd}| }|   g  G dd d||}|   d ||f |  |j|tf |  |j||f |  |j||ttf d S )Nc                   @   r   )z4TestMROEntry.test_mro_entry_with_builtins.<locals>.ANr   r	   r	   r	   r
   r   >   r   r   c                       r    )z4TestMROEntry.test_mro_entry_with_builtins.<locals>.Cc                    s     | tfS r   )r!   dictr#   r%   r	   r
   r   @      
zDTestMROEntry.test_mro_entry_with_builtins.<locals>.C.__mro_entries__Nr   r	   r%   r	   r
   r   ?   r&   r   c                   @   r   )z4TestMROEntry.test_mro_entry_with_builtins.<locals>.DNr   r	   r	   r	   r
   r   E   r   r   r'   )r   r*   r3   r+   r,   r-   )r   r   r   r   r   r	   r%   r
   test_mro_entry_with_builtins<   s   z)TestMROEntry.test_mro_entry_with_builtinsc                    s   g G  fddd   }|  g  G dd d|t}|  d |tf |  |j tf |  |j|tf |  |j| ttf d S )Nc                       r   )z6TestMROEntry.test_mro_entry_with_builtins_2.<locals>.Cc                    s    |  fS r   r1   r#   r   r	   r
   r   N   r4   zFTestMROEntry.test_mro_entry_with_builtins_2.<locals>.C.__mro_entries__Nr   r	   r   r	   r
   r   M   r   r   c                   @   r   )z6TestMROEntry.test_mro_entry_with_builtins_2.<locals>.DNr   r	   r	   r	   r
   r   S   r   r   r'   )r   r3   r*   r+   r,   r-   )r   r   r   r	   r   r
   test_mro_entry_with_builtins_2K   s   z+TestMROEntry.test_mro_entry_with_builtins_2c                 C   s   G dd d}| }|  t G dd d|}W d    n1 s"w   Y  G dd d}| }|  t G dd d|}W d    d S 1 sJw   Y  d S )Nc                   @      e Zd Zdd ZdS )z6TestMROEntry.test_mro_entry_errors.<locals>.C_too_manyc                 S      dS r0   r	   )r   r$   Z	somethingotherr	   r	   r
   r   [      zFTestMROEntry.test_mro_entry_errors.<locals>.C_too_many.__mro_entries__Nr   r	   r	   r	   r
   
C_too_manyZ       r;   c                   @   r   z-TestMROEntry.test_mro_entry_errors.<locals>.DNr   r	   r	   r	   r
   r   _   r   r   c                   @   r7   )z5TestMROEntry.test_mro_entry_errors.<locals>.C_too_fewc                 S   r8   r0   r	   r   r	   r	   r
   r   a   r:   zETestMROEntry.test_mro_entry_errors.<locals>.C_too_few.__mro_entries__Nr   r	   r	   r	   r
   	C_too_few`   r<   r?   c                   @   r   r=   r   r	   r	   r	   r
   r   e   r   assertRaises	TypeError)r   r;   r   r   r?   r.   r	   r	   r
   test_mro_entry_errorsY   s   "z"TestMROEntry.test_mro_entry_errorsc                 C   s   G dd d}| }|  t G dd d|}W d    n1 s"w   Y  G dd d}| }|  t G dd d|}W d    d S 1 sJw   Y  d S )Nc                   @      e Zd ZdZdS )z<TestMROEntry.test_mro_entry_errors_2.<locals>.C_not_callable	Surprise!Nr   r	   r	   r	   r
   C_not_callableh       rF   c                   @   r   z/TestMROEntry.test_mro_entry_errors_2.<locals>.DNr   r	   r	   r	   r
   r   l   r   r   c                   @   r7   )z9TestMROEntry.test_mro_entry_errors_2.<locals>.C_not_tuplec                 S   s   t S r   )r-   r>   r	   r	   r
   r   n   r:   zITestMROEntry.test_mro_entry_errors_2.<locals>.C_not_tuple.__mro_entries__Nr   r	   r	   r	   r
   C_not_tuplem   r<   rI   c                   @   r   rH   r   r	   r	   r	   r
   r   r   r   r@   )r   rF   r   r   rI   r	   r	   r
   test_mro_entry_errors_2g   s   "z$TestMROEntry.test_mro_entry_errors_2c                    s   g G fdddt }G dd d G  fddd}| }G dd d||d	}| d
 | | d d | d  f | d d d | |j f | |j|f | |j| tf | |j| d S )Nc                       s   e Zd Z fddZ  ZS )z3TestMROEntry.test_mro_entry_metaclass.<locals>.Metac                    s$    | |||g t | |||S r   )r   super__new__)mclsnamer$   ns)r"   	meta_argsr	   r
   rL   w   s   z;TestMROEntry.test_mro_entry_metaclass.<locals>.Meta.__new__)r   r   r   rL   __classcell__r	   )rP   )r"   r
   Metav   s    rR   c                   @   r   )z0TestMROEntry.test_mro_entry_metaclass.<locals>.ANr   r	   r	   r	   r
   r   z   r   r   c                       r    )z0TestMROEntry.test_mro_entry_metaclass.<locals>.Cc                    s    fS r   r	   r#   r   r	   r
   r   |   s   z@TestMROEntry.test_mro_entry_metaclass.<locals>.C.__mro_entries__Nr   r	   rS   r	   r
   r   {   r&   r   c                   @   rD   )z0TestMROEntry.test_mro_entry_metaclass.<locals>.Dr   N)r   r   r   xr	   r	   r	   r
   r      rG   r   	metaclassr   r         rT   )typer   r*   r+   r,   r-   r"   )r   rR   r   r   r   r	   )r   rP   r
   test_mro_entry_metaclasst   s   z%TestMROEntry.test_mro_entry_metaclassc                 C   sT   G dd d}| }|  td td|fi  W d    d S 1 s#w   Y  d S )Nc                   @   r7   )z0TestMROEntry.test_mro_entry_type_call.<locals>.Cc                 S   r8   r0   r	   r#   r	   r	   r
   r      r:   z@TestMROEntry.test_mro_entry_type_call.<locals>.C.__mro_entries__Nr   r	   r	   r	   r
   r      r<   r   z+MRO entry resolution; use types.new_class()ZBad)ZassertRaisesRegexrB   rY   )r   r   r   r	   r	   r
   test_mro_entry_type_call   s   "z%TestMROEntry.test_mro_entry_type_callN)r   r   r   r   r/   r2   r5   r6   rC   rJ   rZ   r[   r	   r	   r	   r
   r      s    r   c                   @   sl   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S )TestClassGetitemc                    sN   g  G  fddd}|t tf  |  d |t tff |  d i  d S )Nc                       r    )z.TestClassGetitem.test_class_getitem.<locals>.Cc                     s     | |g d S r   r   )r   r   Zgetitem_argsr	   r
   __class_getitem__   s   z@TestClassGetitem.test_class_getitem.<locals>.C.__class_getitem__Nr   r   r   r^   r	   r]   r	   r
   r      r&   r   r   r   )intstrr   r   r   r	   r]   r
   test_class_getitem   s
   z#TestClassGetitem.test_class_getitemc                 C   s2   G dd d}|  |t d |  || d d S )Nc                   @   r7   )z5TestClassGetitem.test_class_getitem_format.<locals>.Cc                 S   s   d|j  dS )NzC[]r   clsitemr	   r	   r
   r^      s   zGTestClassGetitem.test_class_getitem_format.<locals>.C.__class_getitem__Nr_   r	   r	   r	   r
   r      r<   r   C[int]zC[C]r   r`   rb   r	   r	   r
   test_class_getitem_format   s   z*TestClassGetitem.test_class_getitem_formatc                 C   B   G dd d}G dd d|}|  |t d |  || d d S )Nc                   @   r7   )z:TestClassGetitem.test_class_getitem_inheritance.<locals>.Cc                 S      | j  d|j  dS N[rd   re   rf   r	   r	   r
   r^         zLTestClassGetitem.test_class_getitem_inheritance.<locals>.C.__class_getitem__Nr_   r	   r	   r	   r
   r      r<   r   c                   @   r   )z:TestClassGetitem.test_class_getitem_inheritance.<locals>.DNr   r	   r	   r	   r
   r      r   r   D[int]D[D]rj   r   r   r   r	   r	   r
   test_class_getitem_inheritance   s   z/TestClassGetitem.test_class_getitem_inheritancec                 C   rl   )Nc                   @   r7   )z<TestClassGetitem.test_class_getitem_inheritance_2.<locals>.Cc                 S   r8   )NzShould not see thisr	   rf   r	   r	   r
   r^      r:   zNTestClassGetitem.test_class_getitem_inheritance_2.<locals>.C.__class_getitem__Nr_   r	   r	   r	   r
   r      r<   r   c                   @   r7   )z<TestClassGetitem.test_class_getitem_inheritance_2.<locals>.Dc                 S   rm   rn   re   rf   r	   r	   r
   r^      rp   zNTestClassGetitem.test_class_getitem_inheritance_2.<locals>.D.__class_getitem__Nr_   r	   r	   r	   r
   r      r<   r   rq   rr   rj   rs   r	   r	   r
    test_class_getitem_inheritance_2   s   z1TestClassGetitem.test_class_getitem_inheritance_2c                 C   rl   )Nc                   @   s   e Zd Zedd ZdS )z:TestClassGetitem.test_class_getitem_classmethod.<locals>.Cc                 S   rm   rn   re   rf   r	   r	   r
   r^      s   zLTestClassGetitem.test_class_getitem_classmethod.<locals>.C.__class_getitem__N)r   r   r   classmethodr^   r	   r	   r	   r
   r      s    r   c                   @   r   )z:TestClassGetitem.test_class_getitem_classmethod.<locals>.DNr   r	   r	   r	   r
   r      r   r   rq   rr   rj   rs   r	   r	   r
   test_class_getitem_classmethod   s   z/TestClassGetitem.test_class_getitem_classmethodc                 C   rl   )Nc                   @   r7   )z6TestClassGetitem.test_class_getitem_patched.<locals>.Cc                 S   s   dd }t || _d S )Nc                 S   rm   rn   re   rf   r	   r	   r
   r^      rp   zcTestClassGetitem.test_class_getitem_patched.<locals>.C.__init_subclass__.<locals>.__class_getitem__)rv   r^   )rg   r^   r	   r	   r
   __init_subclass__   s   zHTestClassGetitem.test_class_getitem_patched.<locals>.C.__init_subclass__N)r   r   r   rx   r	   r	   r	   r
   r      r<   r   c                   @   r   )z6TestClassGetitem.test_class_getitem_patched.<locals>.DNr   r	   r	   r	   r
   r      r   r   rq   rr   rj   rs   r	   r	   r
   test_class_getitem_patched   s   z+TestClassGetitem.test_class_getitem_patchedc                 C   sH   G dd dt }G dd d|}| |jd  |t  | |jt d S )Nc                   @   s   e Zd ZdZdd ZdS )z<TestClassGetitem.test_class_getitem_with_builtins.<locals>.ANc                 S   s
   || _ d S r   )called_withrf   r	   r	   r
   r^      s   
zNTestClassGetitem.test_class_getitem_with_builtins.<locals>.A.__class_getitem__)r   r   r   rz   r^   r	   r	   r	   r
   r      s    r   c                   @   r   )z<TestClassGetitem.test_class_getitem_with_builtins.<locals>.BNr   r	   r	   r	   r
   r          r   )r3   assertIsrz   r`   )r   r   r   r	   r	   r
    test_class_getitem_with_builtins   s
   z1TestClassGetitem.test_class_getitem_with_builtinsc                 C   s   G dd d}|  t |t  W d    n1 sw   Y  G dd d}|  t |t  W d    d S 1 s<w   Y  d S )Nc                   @   r7   )z=TestClassGetitem.test_class_getitem_errors.<locals>.C_too_fewc                 S      d S r   r	   )rg   r	   r	   r
   r^      r:   zOTestClassGetitem.test_class_getitem_errors.<locals>.C_too_few.__class_getitem__Nr_   r	   r	   r	   r
   r?      r<   r?   c                   @   r7   )z>TestClassGetitem.test_class_getitem_errors.<locals>.C_too_manyc                 S   r~   r   r	   )rg   ZoneZtwor	   r	   r
   r^      r:   zPTestClassGetitem.test_class_getitem_errors.<locals>.C_too_many.__class_getitem__Nr_   r	   r	   r	   r
   r;      r<   r;   )rA   rB   r`   )r   r?   r;   r	   r	   r
   test_class_getitem_errors   s   

"z*TestClassGetitem.test_class_getitem_errorsc                 C   s   G dd d}|  t | t  W d    n1 sw   Y  G dd d}| }dd |_|  t |t  W d    n1 sDw   Y  G dd d}|  t |t  W d    d S 1 sew   Y  d S )	Nc                   @   r7   )z7TestClassGetitem.test_class_getitem_errors_2.<locals>.Cc                 S   r~   r   r	   rf   r	   r	   r
   r^      r:   zITestClassGetitem.test_class_getitem_errors_2.<locals>.C.__class_getitem__Nr_   r	   r	   r	   r
   r      r<   r   c                   @   r   )z7TestClassGetitem.test_class_getitem_errors_2.<locals>.ENr   r	   r	   r	   r
   r(      r   r(   c                 S   r8   )NzThis will not workr	   rf   r	   r	   r
   <lambda>   s    z>TestClassGetitem.test_class_getitem_errors_2.<locals>.<lambda>c                   @   rD   )zDTestClassGetitem.test_class_getitem_errors_2.<locals>.C_not_callablerE   Nr_   r	   r	   r	   r
   rF      rG   rF   )rA   rB   r`   r^   )r   r   r(   erF   r	   r	   r
   test_class_getitem_errors_2   s   


"z,TestClassGetitem.test_class_getitem_errors_2c                 C   s$   G dd dt }| |t d d S )Nc                   @   r7   )z;TestClassGetitem.test_class_getitem_metaclass.<locals>.Metac                 S   rm   rn   re   rf   r	   r	   r
   r^      rp   zMTestClassGetitem.test_class_getitem_metaclass.<locals>.Meta.__class_getitem__Nr_   r	   r	   r	   r
   rR      r<   rR   z	Meta[int]rY   r   r`   )r   rR   r	   r	   r
   test_class_getitem_metaclass   s   z-TestClassGetitem.test_class_getitem_metaclassc                 C   6   G dd dt }G dd d|d}| |t d d S )Nc                   @   r   )z@TestClassGetitem.test_class_getitem_with_metaclass.<locals>.MetaNr   r	   r	   r	   r
   rR      r   rR   c                   @   r7   )z=TestClassGetitem.test_class_getitem_with_metaclass.<locals>.Cc                 S   rm   rn   re   rf   r	   r	   r
   r^      rp   zOTestClassGetitem.test_class_getitem_with_metaclass.<locals>.C.__class_getitem__Nr_   r	   r	   r	   r
   r      r<   r   rU   ri   r   r   rR   r   r	   r	   r
   !test_class_getitem_with_metaclass   s   z2TestClassGetitem.test_class_getitem_with_metaclassc                 C   r   )Nc                   @   r7   )zATestClassGetitem.test_class_getitem_metaclass_first.<locals>.Metac                 S   r8   )Nfrom metaclassr	   rf   r	   r	   r
   __getitem__  r:   zMTestClassGetitem.test_class_getitem_metaclass_first.<locals>.Meta.__getitem__N)r   r   r   r   r	   r	   r	   r
   rR     r<   rR   c                   @   r7   )z>TestClassGetitem.test_class_getitem_metaclass_first.<locals>.Cc                 S   r8   )Nzfrom __class_getitem__r	   rf   r	   r	   r
   r^     r:   zPTestClassGetitem.test_class_getitem_metaclass_first.<locals>.C.__class_getitem__Nr_   r	   r	   r	   r
   r     r<   r   rU   r   r   r   r	   r	   r
   "test_class_getitem_metaclass_first  s   z3TestClassGetitem.test_class_getitem_metaclass_firstN)r   r   r   rc   rk   rt   ru   rw   ry   r}   r   r   r   r   r   r	   r	   r	   r
   r\      s    

	
r\   c                   @   r7   )CAPITestc                 C   s   ddl m}m} | |t| |t }| t|| | |	dtf G dd d|}| |j
tf | |j|f | |j|ttf d S )Nr   )GenericGenericAliasr	   c                   @   r   )z CAPITest.test_c_class.<locals>.CNr   r	   r	   r	   r
   r     r{   r   )Z	_testcapir   r   ZassertIsInstancer^   r`   r|   rY   r   r   r*   r+   r,   r-   )r   r   r   Z
IntGenericr   r	   r	   r
   test_c_class  s   zCAPITest.test_c_classN)r   r   r   r   r	   r	   r	   r
   r     s    r   __main__)
Zunittesttestr   ZTestCaser   r\   Zcpython_onlyr   r   mainr	   r	   r	   r
   <module>   s     v