a
    ze!%                     @   sd   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r`e 	  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                   @   s   e Zd ZdS )z0TestMROEntry.test_mro_entry_signature.<locals>.BN__name__
__module____qualname__ r   r   ,/usr/lib/python3.9/test/test_genericclass.pyB       r
   c                       s   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   	   s   r   c                   @   s   e Zd ZdS )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                   @   s   e Zd ZdS )z&TestMROEntry.test_mro_entry.<locals>.ANr   r   r   r   r	   A   r   r   c                   @   s   e Zd ZdS )z&TestMROEntry.test_mro_entry.<locals>.BNr   r   r   r   r	   r
      r   r
   c                       s   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      s   r   c                   @   s   e Zd ZdS )z&TestMROEntry.test_mro_entry.<locals>.DNr   r   r   r   r	   r      r   r   c                   @   s   e Zd ZdS )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                   @   s   e Zd ZdS )z+TestMROEntry.test_mro_entry_none.<locals>.ANr   r   r   r   r	   r   )   r   r   c                   @   s   e Zd ZdS )z+TestMROEntry.test_mro_entry_none.<locals>.BNr   r   r   r   r	   r
   *   r   r
   c                       s   e Zd Z fddZdS )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   +   s   r   c                   @   s   e Zd ZdS )z+TestMROEntry.test_mro_entry_none.<locals>.DNr   r   r   r   r	   r   1   r   r   r"   c                   @   s   e Zd ZdS )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                   @   s   e Zd ZdS )z4TestMROEntry.test_mro_entry_with_builtins.<locals>.ANr   r   r   r   r	   r   >   r   r   c                       s   e Zd Z fddZdS )z4TestMROEntry.test_mro_entry_with_builtins.<locals>.Cc                    s     | tfS r   )r   dictr   r!   r   r	   r   @   s    
zDTestMROEntry.test_mro_entry_with_builtins.<locals>.C.__mro_entries__Nr   r   r!   r   r	   r   ?   s   r   c                   @   s   e Zd ZdS )z4TestMROEntry.test_mro_entry_with_builtins.<locals>.DNr   r   r   r   r	   r   E   r   r   r"   )r   r%   r.   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                       s   e Zd Z fddZdS )z6TestMROEntry.test_mro_entry_with_builtins_2.<locals>.Cc                    s    |  fS r   r,   r   r   r   r	   r   N   s    
zFTestMROEntry.test_mro_entry_with_builtins_2.<locals>.C.__mro_entries__Nr   r   r   r   r	   r   M   s   r   c                   @   s   e Zd ZdS )z6TestMROEntry.test_mro_entry_with_builtins_2.<locals>.DNr   r   r   r   r	   r   S   r   r   r"   )r   r.   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 sD0    Y  G dd d}| }|  t  G dd d|}W d    n1 s0    Y  d S )Nc                   @   s   e Zd Zdd ZdS )z6TestMROEntry.test_mro_entry_errors.<locals>.C_too_manyc                 S   s   dS r+   r   )r   r    Z	somethingotherr   r   r	   r   [   s    zFTestMROEntry.test_mro_entry_errors.<locals>.C_too_many.__mro_entries__Nr   r   r   r   r	   
C_too_manyZ   s   r2   c                   @   s   e Zd ZdS z-TestMROEntry.test_mro_entry_errors.<locals>.DNr   r   r   r   r	   r   _   r   r   c                   @   s   e Zd Zdd ZdS )z5TestMROEntry.test_mro_entry_errors.<locals>.C_too_fewc                 S   s   dS r+   r   r   r   r   r	   r   a   s    zETestMROEntry.test_mro_entry_errors.<locals>.C_too_few.__mro_entries__Nr   r   r   r   r	   	C_too_few`   s   r5   c                   @   s   e Zd ZdS r3   r   r   r   r   r	   r   e   r   assertRaises	TypeError)r   r2   r   r   r5   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 sD0    Y  G dd d}| }|  t  G dd d|}W d    n1 s0    Y  d S )Nc                   @   s   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   s   r;   c                   @   s   e Zd ZdS z/TestMROEntry.test_mro_entry_errors_2.<locals>.DNr   r   r   r   r	   r   l   r   r   c                   @   s   e Zd Zdd ZdS )z9TestMROEntry.test_mro_entry_errors_2.<locals>.C_not_tuplec                 S   s   t S r   )r(   r4   r   r   r	   r   n   s    zITestMROEntry.test_mro_entry_errors_2.<locals>.C_not_tuple.__mro_entries__Nr   r   r   r   r	   C_not_tuplem   s   r=   c                   @   s   e Zd ZdS r<   r   r   r   r   r	   r   r   r   r6   )r   r;   r   r   r=   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	   r@   w   s    z;TestMROEntry.test_mro_entry_metaclass.<locals>.Meta.__new__)r   r   r   r@   __classcell__r   )rD   )r   r	   Metav   s   rF   c                   @   s   e Zd ZdS )z0TestMROEntry.test_mro_entry_metaclass.<locals>.ANr   r   r   r   r	   r   z   r   r   c                       s   e Zd Z fddZdS )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   rG   r   r	   r   {   s   r   c                   @   s   e Zd ZdZdS )z0TestMROEntry.test_mro_entry_metaclass.<locals>.Dr   N)r   r   r   xr   r   r   r	   r      s   r   	metaclassr   r         rH   )typer   r%   r&   r'   r(   r   )r   rF   r   r   r   r   )r   rD   r	   test_mro_entry_metaclasst   s    z%TestMROEntry.test_mro_entry_metaclassc                 C   sR   G dd d}| }|  td td|fi  W d    n1 sD0    Y  d S )Nc                   @   s   e Zd Zdd ZdS )z0TestMROEntry.test_mro_entry_type_call.<locals>.Cc                 S   s   dS r+   r   r   r   r   r	   r      s    z@TestMROEntry.test_mro_entry_type_call.<locals>.C.__mro_entries__Nr   r   r   r   r	   r      s   r   z+MRO entry resolution; use types.new_class()ZBad)ZassertRaisesRegexr8   rM   )r   r   r   r   r   r	   test_mro_entry_type_call   s    z%TestMROEntry.test_mro_entry_type_callN)r   r   r   r   r*   r-   r/   r0   r9   r>   rN   rO   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                       s   e Zd Z fddZdS )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   rR   r   rQ   r   r	   r      s   r   r   r   )intstrr   r   r   r   rQ   r	   test_class_getitem   s
    z#TestClassGetitem.test_class_getitemc                 C   s2   G dd d}|  |t d |  || d d S )Nc                   @   s   e Zd Zdd ZdS )z5TestClassGetitem.test_class_getitem_format.<locals>.Cc                 S   s   d|j  dS )NzC[]r   clsitemr   r   r	   rR      s    zGTestClassGetitem.test_class_getitem_format.<locals>.C.__class_getitem__NrS   r   r   r   r	   r      s   r   C[int]zC[C]r   rT   rV   r   r   r	   test_class_getitem_format   s    z*TestClassGetitem.test_class_getitem_formatc                 C   sB   G dd d}G dd d|}|  |t d |  || d d S )Nc                   @   s   e Zd Zdd ZdS )z:TestClassGetitem.test_class_getitem_inheritance.<locals>.Cc                 S   s   | j  d|j  dS N[rX   rY   rZ   r   r   r	   rR      s    zLTestClassGetitem.test_class_getitem_inheritance.<locals>.C.__class_getitem__NrS   r   r   r   r	   r      s   r   c                   @   s   e Zd ZdS )z:TestClassGetitem.test_class_getitem_inheritance.<locals>.DNr   r   r   r   r	   r      r   r   D[int]D[D]r^   r   r   r   r   r   r	   test_class_getitem_inheritance   s    z/TestClassGetitem.test_class_getitem_inheritancec                 C   sB   G dd d}G dd d|}|  |t d |  || d d S )Nc                   @   s   e Zd Zdd ZdS )z<TestClassGetitem.test_class_getitem_inheritance_2.<locals>.Cc                 S   s   dS )NzShould not see thisr   rZ   r   r   r	   rR      s    zNTestClassGetitem.test_class_getitem_inheritance_2.<locals>.C.__class_getitem__NrS   r   r   r   r	   r      s   r   c                   @   s   e Zd Zdd ZdS )z<TestClassGetitem.test_class_getitem_inheritance_2.<locals>.Dc                 S   s   | j  d|j  dS r`   rY   rZ   r   r   r	   rR      s    zNTestClassGetitem.test_class_getitem_inheritance_2.<locals>.D.__class_getitem__NrS   r   r   r   r	   r      s   r   rb   rc   r^   rd   r   r   r	    test_class_getitem_inheritance_2   s    z1TestClassGetitem.test_class_getitem_inheritance_2c                 C   sB   G dd d}G dd d|}|  |t d |  || d d S )Nc                   @   s   e Zd Zedd ZdS )z:TestClassGetitem.test_class_getitem_classmethod.<locals>.Cc                 S   s   | j  d|j  dS r`   rY   rZ   r   r   r	   rR      s    zLTestClassGetitem.test_class_getitem_classmethod.<locals>.C.__class_getitem__N)r   r   r   classmethodrR   r   r   r   r	   r      s   r   c                   @   s   e Zd ZdS )z:TestClassGetitem.test_class_getitem_classmethod.<locals>.DNr   r   r   r   r	   r      r   r   rb   rc   r^   rd   r   r   r	   test_class_getitem_classmethod   s    z/TestClassGetitem.test_class_getitem_classmethodc                 C   sB   G dd d}G dd d|}|  |t d |  || d d S )Nc                   @   s   e Zd Zdd ZdS )z6TestClassGetitem.test_class_getitem_patched.<locals>.Cc                 S   s   dd }t || _d S )Nc                 S   s   | j  d|j  dS r`   rY   rZ   r   r   r	   rR      s    zcTestClassGetitem.test_class_getitem_patched.<locals>.C.__init_subclass__.<locals>.__class_getitem__)rg   rR   )r[   rR   r   r   r	   __init_subclass__   s    zHTestClassGetitem.test_class_getitem_patched.<locals>.C.__init_subclass__N)r   r   r   ri   r   r   r   r	   r      s   r   c                   @   s   e Zd ZdS )z6TestClassGetitem.test_class_getitem_patched.<locals>.DNr   r   r   r   r	   r      r   r   rb   rc   r^   rd   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_withrZ   r   r   r	   rR      s    zNTestClassGetitem.test_class_getitem_with_builtins.<locals>.A.__class_getitem__)r   r   r   rk   rR   r   r   r   r	   r      s   r   c                   @   s   e Zd ZdS )z<TestClassGetitem.test_class_getitem_with_builtins.<locals>.BNr   r   r   r   r	   r
      s   r
   )r.   assertIsrk   rT   )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 s60    Y  G dd d}|  t |t  W d    n1 sv0    Y  d S )Nc                   @   s   e Zd Zdd ZdS )z=TestClassGetitem.test_class_getitem_errors.<locals>.C_too_fewc                 S   s   d S r   r   )r[   r   r   r	   rR      s    zOTestClassGetitem.test_class_getitem_errors.<locals>.C_too_few.__class_getitem__NrS   r   r   r   r	   r5      s   r5   c                   @   s   e Zd Zdd ZdS )z>TestClassGetitem.test_class_getitem_errors.<locals>.C_too_manyc                 S   s   d S r   r   )r[   ZoneZtwor   r   r	   rR      s    zPTestClassGetitem.test_class_getitem_errors.<locals>.C_too_many.__class_getitem__NrS   r   r   r   r	   r2      s   r2   )r7   r8   rT   )r   r5   r2   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 s80    Y  G dd d}| }dd |_|  t |t  W d    n1 s0    Y  G dd d}|  t |t  W d    n1 s0    Y  d S )	Nc                   @   s   e Zd Zdd ZdS )z7TestClassGetitem.test_class_getitem_errors_2.<locals>.Cc                 S   s   d S r   r   rZ   r   r   r	   rR      s    zITestClassGetitem.test_class_getitem_errors_2.<locals>.C.__class_getitem__NrS   r   r   r   r	   r      s   r   c                   @   s   e Zd ZdS )z7TestClassGetitem.test_class_getitem_errors_2.<locals>.ENr   r   r   r   r	   r#      r   r#   c                 S   s   dS )NzThis will not workr   rZ   r   r   r	   <lambda>   r   z>TestClassGetitem.test_class_getitem_errors_2.<locals>.<lambda>c                   @   s   e Zd ZdZdS )zDTestClassGetitem.test_class_getitem_errors_2.<locals>.C_not_callabler:   NrS   r   r   r   r	   r;      s   r;   )r7   r8   rT   rR   )r   r   r#   er;   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                   @   s   e Zd Zdd ZdS )z;TestClassGetitem.test_class_getitem_metaclass.<locals>.Metac                 S   s   | j  d|j  dS r`   rY   rZ   r   r   r	   rR      s    zMTestClassGetitem.test_class_getitem_metaclass.<locals>.Meta.__class_getitem__NrS   r   r   r   r	   rF      s   rF   z	Meta[int]rM   r   rT   )r   rF   r   r   r	   test_class_getitem_metaclass   s    z-TestClassGetitem.test_class_getitem_metaclassc                 C   s6   G dd dt }G dd d|d}| |t d d S )Nc                   @   s   e Zd ZdS )z@TestClassGetitem.test_class_getitem_with_metaclass.<locals>.MetaNr   r   r   r   r	   rF      r   rF   c                   @   s   e Zd Zdd ZdS )z=TestClassGetitem.test_class_getitem_with_metaclass.<locals>.Cc                 S   s   | j  d|j  dS r`   rY   rZ   r   r   r	   rR      s    zOTestClassGetitem.test_class_getitem_with_metaclass.<locals>.C.__class_getitem__NrS   r   r   r   r	   r      s   r   rI   r]   rr   r   rF   r   r   r   r	   !test_class_getitem_with_metaclass   s    z2TestClassGetitem.test_class_getitem_with_metaclassc                 C   s6   G dd dt }G dd d|d}| |t d d S )Nc                   @   s   e Zd Zdd ZdS )zATestClassGetitem.test_class_getitem_metaclass_first.<locals>.Metac                 S   s   dS )Nfrom metaclassr   rZ   r   r   r	   __getitem__  s    zMTestClassGetitem.test_class_getitem_metaclass_first.<locals>.Meta.__getitem__N)r   r   r   rw   r   r   r   r	   rF     s   rF   c                   @   s   e Zd Zdd ZdS )z>TestClassGetitem.test_class_getitem_metaclass_first.<locals>.Cc                 S   s   dS )Nzfrom __class_getitem__r   rZ   r   r   r	   rR     s    zPTestClassGetitem.test_class_getitem_metaclass_first.<locals>.C.__class_getitem__NrS   r   r   r   r	   r     s   r   rI   rv   rr   rt   r   r   r	   "test_class_getitem_metaclass_first  s    z3TestClassGetitem.test_class_getitem_metaclass_firstN)r   r   r   rW   r_   re   rf   rh   rj   rm   rn   rq   rs   ru   rx   r   r   r   r	   rP      s   

	
rP   c                   @   s   e Zd Zdd ZdS )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                   @   s   e Zd ZdS )z CAPITest.test_c_class.<locals>.CNr   r   r   r   r	   r     s   r   )Z	_testcapirz   r{   ZassertIsInstancerR   rT   rl   rM   r   r   r%   r&   r'   r(   )r   rz   r{   Z
IntGenericr   r   r   r	   test_c_class  s    zCAPITest.test_c_classN)r   r   r   r|   r   r   r   r	   ry     s   ry   __main__)
Zunittesttestr   ZTestCaser   rP   Zcpython_onlyry   r   mainr   r   r   r	   <module>   s    v