o
    HXh                 
   @   s@  d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZm	Z	 d dl
m
Z
mZ d dlmZmZ d dlmZmZ d dlmZmZmZ d dlmZmZmZ d dlmZmZmZmZ d d	lmZ d d
lmZmZmZmZm Z  d dlm!Z!m"Z" d dlm#Z# d dlm$Z$m%Z% d dlm&Z& d dlm'Z'm(Z( d dlm)Z) d dlm*Z* d dlm+Z+m,Z, d dlm-Z-m.Z.m/Z/ d dlm0Z0m1Z1 d dlm2Z2m3Z3 d dlm4Z4 d dlm5Z5m6Z6m7Z7m8Z8 d dlm9Z9 d dl:Z:d dlZd dl;Z;d dl<Z<d dl=m>Z> d dl=m?Z? G dd deZ@G dd dZAG dd  d eAZBG d!d" d"eAZCG d#d$ d$eBeCZDG d%d& d&e@ZEG d'd( d(e@ZFG d)d* d*e@ZGG d+d, d,e@ZHG d-d. d.e@ZIG d/d0 d0ZJG d1d2 d2eJe@ZKG d3d4 d4eJe@ZLG d5d6 d6e@ZMed7eNeOZPed8ZQG d9d: d:eePeQf ZRG d;d< d<eRePeQf ZSG d=d> d>e ZTe"G d?d@ d@eTe ZUG dAdB dBZVG dCdD dDe ZWG dEdF dFe ZXe"G dGdH dHeWeXe ZYe"G dIdJ dJe ZZG dKdL dLeZZ[G dMdN dNZ\G dOdP dPe+Z]e"G dQdR dRe Z^G dSdT dTe@Z_G dUdV dVe@Z`G dWdX dXe@ZaG dYdZ dZe@ZbG d[d\ d\e@ZcG d]d^ d^e@ZdG d_d` d`e@ZedaZfzegef W n ehy2   dbZiY nw dcZid ddl=mjZjmkZkmlZlmmZmmnZn d delmoZo G dfdg dgZpG dhdi diepZqG djdk dkeqZrG dldm dmee ZsG dndo doZtG dpdq dqZuG drds dse+ZvG dtdu due+ZwG dvdw dwe+ZxG dxdy dye+Zye,dzd{eNfgZzG d|d} d}e,Z{G d~d de?j|dbdZ}G dd de{ezZ~G dd de,dbdZG dd de>jpZdeoe fddZz
ee d W n ey Z zW Y dZ[ndZ[ww e#ZG dd dZG dd de@ZG dd deZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@ZG dd de@Ze5dZedeeeZG dd de@ZG dd de@Zedkre  dS dS )    N)TestCasemain
skipUnlessskip)copydeepcopy)AnyNoReturn)TypeVarAnyStr)TKTVT)UnionOptionalLiteral)TupleListDictMutableMapping)Callable)GenericClassVarFinalfinalProtocol)castruntime_checkable)get_type_hints)
get_originget_args)is_typeddict)no_type_checkno_type_check_decoratorType)NewType)
NamedTuple	TypedDictIOTextIOBinaryIO)PatternMatch)	Annotated
ForwardRef)	TypeAlias)	ParamSpecConcatenateParamSpecArgsParamSpecKwargs)	TypeGuard)mod_generics_cache)_typed_dict_helperc                   @   s(   e Zd ZdddZdddZdd ZdS )	BaseTestCaseNc                 C   s8   t ||sd||f }|d ur|d| 7 }| |d S )Nz%r is not a subclass of %r : %s
issubclassZfailureExceptionselfclsZclass_or_tuplemsgmessage rB   :/opt/python-3.10.19/usr/lib/python3.10/test/test_typing.pyassertIsSubclass)      

zBaseTestCase.assertIsSubclassc                 C   s8   t ||rd||f }|d ur|d| 7 }| |d S )Nz%r is a subclass of %rr:   r;   r=   rB   rB   rC   assertNotIsSubclass0   rE   z BaseTestCase.assertNotIsSubclassc                 C   s   t jD ]}|  qd S N)typingZ	_cleanupsr>   frB   rB   rC   clear_caches7   s   
zBaseTestCase.clear_cachesrG   )__name__
__module____qualname__rD   rF   rK   rB   rB   rB   rC   r9   '   s    

r9   c                   @      e Zd ZdS )EmployeeNrL   rM   rN   rB   rB   rB   rC   rP   <       rP   c                   @   rO   )ManagerNrQ   rB   rB   rB   rC   rS   @   rR   rS   c                   @   rO   )FounderNrQ   rB   rB   rB   rC   rT   D   rR   rT   c                   @   rO   )ManagingFounderNrQ   rB   rB   rB   rC   rU   H   rR   rU   c                   @   sD   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S )AnyTestsc                 C   :   |  t tdt W d    d S 1 sw   Y  d S N*   )assertRaises	TypeError
isinstancer   r>   rB   rB   rC   test_any_instance_type_errorN      "z%AnyTests.test_any_instance_type_errorc                 C   n   |  t ttt W d    n1 sw   Y  |  t ttt W d    d S 1 s0w   Y  d S rG   )rZ   r[   r<   rP   r   r]   rB   rB   rC   test_any_subclass_type_errorR      "z%AnyTests.test_any_subclass_type_errorc                 C      |  ttd d S )Nz
typing.Any)assertEqualreprr   r]   rB   rB   rC   	test_reprX      zAnyTests.test_reprc                 C   sl   |  t tdt W d    n1 sw   Y  |  t tt  W d    d S 1 s/w   Y  d S rX   )rZ   r[   r<   r   intr]   rB   rB   rC   test_errors[   s   
"zAnyTests.test_errorsc                 C   ~   |  t G dd dt}W d    n1 sw   Y  |  t G dd dtt}W d    d S 1 s8w   Y  d S )Nc                   @   rO   z(AnyTests.test_cannot_subclass.<locals>.ANrQ   rB   rB   rB   rC   Ac   rR   rl   c                   @   rO   rk   rQ   rB   rB   rB   rC   rl   f   rR   rZ   r[   r   typer>   rl   rB   rB   rC   test_cannot_subclassa      "zAnyTests.test_cannot_subclassc                 C   j   |  t t  W d    n1 sw   Y  |  t tt  W d    d S 1 s.w   Y  d S rG   rm   r]   rB   rB   rC   test_cannot_instantiatei      "z AnyTests.test_cannot_instantiatec                 C   s"   t jt  t jt  t jt  d S rG   )rH   r.   r   r-   r*   r]   rB   rB   rC   test_any_works_with_aliaso   s   

z"AnyTests.test_any_works_with_aliasN)
rL   rM   rN   r^   ra   rf   ri   rp   rs   ru   rB   rB   rB   rC   rV   L   s    rV   c                   @   <   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )NoReturnTestsc                 C   rW   rX   )rZ   r[   r\   r	   r]   rB   rB   rC   !test_noreturn_instance_type_errorx   r_   z/NoReturnTests.test_noreturn_instance_type_errorc                 C   r`   rG   )rZ   r[   r<   rP   r	   r]   rB   rB   rC   !test_noreturn_subclass_type_error|   rb   z/NoReturnTests.test_noreturn_subclass_type_errorc                 C   rc   )Nztyping.NoReturn)rd   re   r	   r]   rB   rB   rC   rf      rg   zNoReturnTests.test_reprc                 C   8   |  t tt  W d    d S 1 sw   Y  d S rG   )rZ   r[   r	   rh   r]   rB   rB   rC   test_not_generic      
"zNoReturnTests.test_not_genericc                 C   rj   )Nc                   @   rO   z-NoReturnTests.test_cannot_subclass.<locals>.ANrQ   rB   rB   rB   rC   rl      rR   rl   c                   @   rO   r}   rQ   rB   rB   rB   rC   rl      rR   rZ   r[   r	   rn   ro   rB   rB   rC   rp      rq   z"NoReturnTests.test_cannot_subclassc                 C   rr   rG   r~   r]   rB   rB   rC   rs      rt   z%NoReturnTests.test_cannot_instantiateN)	rL   rM   rN   rx   ry   rf   r{   rp   rs   rB   rB   rB   rC   rw   v   s    rw   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!S )"TypeVarTestsc                 C   $   t d}| || | |t  d S Nr   )r
   rd   assertIsInstancer>   r   rB   rB   rC   test_basic_plain   s   zTypeVarTests.test_basic_plainc                 C   sB   t d}| t td| W d    d S 1 sw   Y  d S )Nr   rY   )r
   rZ   r[   r\   r   rB   rB   rC    test_typevar_instance_type_error   s   "z-TypeVarTests.test_typevar_instance_type_errorc                 C   sv   t d}| t tt| W d    n1 sw   Y  | t t|t W d    d S 1 s4w   Y  d S r   )r
   rZ   r[   r<   rh   r   rB   rB   rC    test_typevar_subclass_type_error   s   "z-TypeVarTests.test_typevar_subclass_type_errorc                 C   s>   |  t tdt}| W d    d S 1 sw   Y  d S )NX)rZ   r[   r
   rh   r>   r   rB   rB   rC   test_constrained_error   s   
"z#TypeVarTests.test_constrained_errorc                 C   s   t d}t d}| || | t| | | t| t||f  | t||f | | t|tf t|  | t|tf tt  | t|tf j|tf | t|tf j|f | t|tf jt d S )Nr   Y)	r
   assertNotEqualrd   r   rh   __args____parameters__assertIs
__origin__)r>   r   r   rB   rB   rC   test_union_unique   s   zTypeVarTests.test_union_uniquec                 C   st   t d}| |dB t|df  | d|B td|f  | t|dB |tdf | td|B td|f d S )Nr   x)r
   rd   r   r    r0   r   rB   rB   rC   test_or   s
    zTypeVarTests.test_orc                 C   s(   t dtt}| t|tf t|  d S Nrl   )r
   strbytesr   r   ro   rB   rB   rC   test_union_constrained   s   z#TypeVarTests.test_union_constrainedc                 C   s|   |  ttd |  ttd |  ttd |  ttd tddd}|  t|d td	dd
}|  t|d d S )Nz~Tz~KTz~VTz~AnyStrT_coT	covariantz+T_coT_contra)contravariantz	-T_contra)rd   re   r   r   r   r   r
   )r>   r   r   rB   rB   rC   rf      s   zTypeVarTests.test_reprc                 C   s4   |  tdtd |  tdtttdtt d S r   )r   r
   rh   r   r]   rB   rB   rC   test_no_redefinition   s    z!TypeVarTests.test_no_redefinitionc                 C   sD   |  t G dd dtd}W d    d S 1 sw   Y  d S )Nc                   @   rO   )z1TypeVarTests.test_cannot_subclass_vars.<locals>.VNrQ   rB   rB   rB   rC   V   rR   r   r   rZ   r[   r
   r>   r   rB   rB   rC   test_cannot_subclass_vars   s   "z&TypeVarTests.test_cannot_subclass_varsc                 C   s@   |  t G dd dt}W d    d S 1 sw   Y  d S )Nc                   @   rO   )z7TypeVarTests.test_cannot_subclass_var_itself.<locals>.VNrQ   rB   rB   rB   rC   r      rR   r   r   r   rB   rB   rC   test_cannot_subclass_var_itself   s   "z,TypeVarTests.test_cannot_subclass_var_itselfc                 C   s:   |  t td  W d    d S 1 sw   Y  d S r   r   r]   rB   rB   rC   test_cannot_instantiate_vars   r_   z)TypeVarTests.test_cannot_instantiate_varsc                 C   sv   |  t tddd W d    n1 sw   Y  |  t tdtttd W d    d S 1 s4w   Y  d S )Nr   rY   Zbound)rZ   r[   r
   r   floatrP   r]   rB   rB   rC   test_bound_errors   s   "zTypeVarTests.test_bound_errorsc                 C      d}t |i  d S )Nz&import typing
T = typing.TypeVar('T')
execr>   coderB   rB   rC   test_missing__name__   s   z!TypeVarTests.test_missing__name__c                 C   s>   |  t tdddd W d    d S 1 sw   Y  d S )Nr   T)r   r   )rZ   
ValueErrorr
   r]   rB   rB   rC   test_no_bivariant      "zTypeVarTests.test_no_bivariantc              
   C   s   t d}dttffD ]N}| j|d> | t t| |  W d    n1 s)w   Y  | t t| |  W d    n1 sDw   Y  W d    n1 sSw   Y  q
d S )Nr   rB   arg)r
   rh   r   subTestrZ   r[   r   list)r>   r   r   rB   rB   rC   test_bad_var_substitution   s   z&TypeVarTests.test_bad_var_substitutionN)rL   rM   rN   r   r   r   r   r   r   r   rf   r   r   r   r   r   r   r   r   rB   rB   rB   rC   r      s"    

r   c                   @      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'S )(
UnionTestsc                 C   s   t ttf }| |t  d S rG   )r   rh   r   r   r>   urB   rB   rC   test_basics     zUnionTests.test_basicsc                 C   s   |  t ttt W d    n1 sw   Y  |  t ttt W d    n1 s/w   Y  |  t ttttf t W d    d S 1 sNw   Y  d S rG   )rZ   r[   r<   rh   r   r   r]   rB   rB   rC   test_subclass_error
  s   "zUnionTests.test_subclass_errorc                 C   sl   t t }| |t t ttf }t ttf }t ttf }| || | |t | |t | |t d S rG   )r   r   rd   rh   objectr   )r>   r   u1u2u3rB   rB   rC   test_union_any  s   zUnionTests.test_union_anyc                 C   sT   t t }| |t t ttf }t ttf }| || | |t | |t d S rG   )r   r   rd   rh   r   )r>   r   r   r   rB   rB   rC   test_union_object  s   zUnionTests.test_union_objectc                 C   s(   t ttf }t ttf }| || d S rG   )r   rh   r   rd   )r>   r   r   rB   rB   rC   test_unordered&  s   zUnionTests.test_unorderedc                 C   s   t t }| |t d S rG   )r   rP   r   )r>   trB   rB   rC   test_single_class_disappears+  s   z'UnionTests.test_single_class_disappearsc                 C   s8   t ttf }| |t | t|j | t|j d S rG   )r   rP   rS   r   assertInr   r   rB   rB   rC   test_base_class_kept/  s   zUnionTests.test_base_class_keptc                 C   s2   t ttf }t |tf }| |t tttf  d S rG   )r   rh   r   rP   rd   )r>   r   vrB   rB   rC   test_union_union5  s   zUnionTests.test_union_unionc                 C   sR  |  ttd tttf }|  t|dt  tttf }|  t|dt  td}t|tf t }|  t|tt ttt tf }|  t|d ttt t	t
tf f }|  t|d tttB  }|  t|d td t
f }|  t|d tt
d f }|  t|d td t
tf }|  t|d	 tt
 }|  t|d d S )
Nztyping.Unionztyping.Union[%s.Employee, int]ztyping.Union[int, %s.Employee]r   z#typing.Union[typing.List[int], int]z)typing.Union[list[int], dict[str, float]]ztyping.Union[int, float]ztyping.Optional[str]z typing.Union[NoneType, str, int])rd   re   r   rP   rh   rL   r
   r   r   dictr   r   r   )r>   r   r   rB   rB   rC   rf   :  s,   zUnionTests.test_reprc                 C   s   |  t G dd dt}W d    n1 sw   Y  |  t G dd dtt}W d    n1 s7w   Y  |  t G dd dtttf }W d    d S 1 sYw   Y  d S )Nc                   @   rO   z*UnionTests.test_cannot_subclass.<locals>.CNrQ   rB   rB   rB   rC   CU  rR   r   c                   @   rO   r   rQ   rB   rB   rB   rC   r   X  rR   c                   @   rO   r   rQ   rB   rB   rB   rC   r   [  rR   )rZ   r[   r   rn   rh   r   r>   r   rB   rB   rC   rp   S  s   "zUnionTests.test_cannot_subclassc                 C   s   |  t t  W d    n1 sw   Y  |  t tt  W d    n1 s-w   Y  tttf }|  t |  W d    n1 sKw   Y  |  t t|  W d    d S 1 sfw   Y  d S rG   )rZ   r[   r   rn   rh   r   r   rB   rB   rC   rs   ^  s   "z"UnionTests.test_cannot_instantiatec                 C   s   |  tttjt f tk |  tttjt f tjt k | ttttjt f j | tjt tttjt f j d S rG   )assertFalser   r   rH   Iterablerh   r   r   r]   rB   rB   rC   test_union_generalizationi  s   "&z$UnionTests.test_union_generalizationc                 C   sb   |  tt |  tt |  tt |  tt |  d gt |  ttj |  ttj t d S rG   )	r   r   r   r   r   r   rH   Mappingr   r]   rB   rB   rC   test_union_compare_othero  s   z#UnionTests.test_union_compare_otherc                 C   s$   t t }ttd f }| || d S rG   )r   rh   r   rd   )r>   or   rB   rB   rC   test_optionalx     zUnionTests.test_optionalc                 C   8   |  t td  W d    d S 1 sw   Y  d S NrB   )rZ   r[   r   r]   rB   rB   rC   
test_empty}  r|   zUnionTests.test_emptyc                 C   s2   t ttf }d|fdd}| t|d | d S )Nr   c                 S      d S rG   rB   r   rB   rB   rC   rJ         z(UnionTests.test_no_eval_union.<locals>.f)r   rh   r   r   r   )r>   r   rJ   rB   rB   rC   test_no_eval_union  s   zUnionTests.test_no_eval_unionc                 C   s*   dt fdd}| tt|t f d d S )Nreturnc                   S   r   rG   rB   rB   rB   rB   rC   fun  r   z0UnionTests.test_function_repr_union.<locals>.funztyping.Union[fun, int])rh   rd   re   r   )r>   r   rB   rB   rC   test_function_repr_union  s   z#UnionTests.test_function_repr_unionc                 C   s   t ttf }| d S rG   )r   r   r-   ro   rB   rB   rC   test_union_str_pattern  s   z!UnionTests.test_union_str_patternc                    s4   ddl m  t tf   fdd}t|tf  d S )Nr   Elementc                     s    |  S rG   rB   )argsr   rB   rC   Elem     z#UnionTests.test_etree.<locals>.Elem)Zxml.etree.ElementTreer   r   r   )r>   r   rB   r   rC   
test_etree  s   zUnionTests.test_etreeN)rL   rM   rN   r   r   r   r   r   r   r   r   rf   rp   rs   r   r   r   r   r   r   r   r   rB   rB   rB   rC   r     s(    		r   c                   @   rv   )
TupleTestsc                 C   s   |  t tttttf  W d    n1 sw   Y  |  t tttttf  W d    n1 s7w   Y  G dd dt}| tt | |t d S )Nc                   @   rO   )z"TupleTests.test_basics.<locals>.TPNrQ   rB   rB   rB   rC   TP      r   )rZ   r[   r<   r   rh   r   tuplerD   )r>   r   rB   rB   rC   r     s   zTupleTests.test_basicsc                 C   sd   |  tt tt  |  ttdf ttdf  | tt tttf  | tt ttdf  d S N.)rd   r   rh   r   r]   rB   rB   rC   test_equality  s   zTupleTests.test_equalityc                 C   s8   G dd dt }| |t | tt | t t d S )Nc                   @   rO   )z/TupleTests.test_tuple_subclass.<locals>.MyTupleNrQ   rB   rB   rB   rC   MyTuple  rR   r   )r   rD   r   )r>   r   rB   rB   rC   test_tuple_subclass  s   zTupleTests.test_tuple_subclassc                 C   sL   |  t tdtttf  W d    n1 sw   Y  | dt d S )N)r   r   )rZ   r[   r\   r   rh   r   r]   rB   rB   rC   test_tuple_instance_type_error  s   z)TupleTests.test_tuple_instance_type_errorc                 C   sp   |  ttd |  ttd d |  ttttf d |  tttdf d |  tttt  d d S )Nztyping.TuplerB   ztyping.Tuple[()]ztyping.Tuple[int, float].ztyping.Tuple[int, ...]ztyping.Tuple[list[int]])rd   re   r   rh   r   r   r]   rB   rB   rC   rf     s
   zTupleTests.test_reprc                 C   sr   |  t tdt W d    n1 sw   Y  |  t tdtt  W d    d S 1 s2w   Y  d S rX   )rZ   r[   r<   r   rh   r]   rB   rB   rC   ri     s   "zTupleTests.test_errorsN)	rL   rM   rN   r   r   r   r   rf   ri   rB   rB   rB   rC   r     s    
r   c                   @   r   )(BaseCallableTestsc                 C   sd   | j }| t ttj|tgtf  W d    n1 sw   Y  | tj| | || d S rG   )r   rZ   r[   r<   typesFunctionTyperh   rD   r>   r   rB   rB   rC   test_self_subclass  s   z$BaseCallableTests.test_self_subclassc                 C   s   | j }|tgtf }| ||tgtf  | t||tgtf hd | ||tgtf  | ||tgtf  | ||ttgtf  | ||g tf  | ||dtf  | || d S )N   .)r   rh   rd   lenr   r   )r>   r   r   rB   rB   rC   test_eq_hash  s   zBaseCallableTests.test_eq_hashc                 C   s   | j }| t |  W d    n1 sw   Y  | t t|  W d    n1 s0w   Y  |tgtf }| t |  W d    n1 sOw   Y  | t t|  W d    d S 1 sjw   Y  d S rG   )r   rZ   r[   rn   rh   r   )r>   r   crB   rB   rC   rs     s   "z)BaseCallableTests.test_cannot_instantiatec                 C   s>   | j }| t |t  W d    d S 1 sw   Y  d S rG   )r   rZ   r[   rh   r   rB   rB   rC   test_callable_wrong_forms  s   
"z+BaseCallableTests.test_callable_wrong_formsc                 C   s*   | j }dd }| || | d | d S )Nc                   S   r   rG   rB   rB   rB   rB   rC   rJ        z9BaseCallableTests.test_callable_instance_works.<locals>.f)r   r   assertNotIsInstancer>   r   rJ   rB   rB   rC   test_callable_instance_works  s   z.BaseCallableTests.test_callable_instance_worksc                 C   s  | j }dd }| t | ||g d f  W d    n1 s!w   Y  | t | ||g tf  W d    n1 s@w   Y  | t | d |g d f  W d    n1 s_w   Y  | t | d |g tf  W d    d S 1 sw   Y  d S )Nc                   S   r   rG   rB   rB   rB   rB   rC   rJ     r   z>BaseCallableTests.test_callable_instance_type_error.<locals>.f)r   rZ   r[   r   r   r   r   rB   rB   rC   !test_callable_instance_type_error  s   "z3BaseCallableTests.test_callable_instance_type_errorc                 C   s   | j }|j d}|g tf }| t|| d |ttgtf }| t|| d |dtf }| t|| d |ttgtt f }| t|| d d S )N	.Callablez
[[], bool]z[[str, float], int].z
[..., str]z[[str, float], list[int]])	r   rM   boolrd   re   r   r   rh   r   )r>   r   fullnameZct0Zct2ZctvZct3rB   rB   rC   rf     s   zBaseCallableTests.test_reprc                 C   sD   | j }d|dtf fdd}| t|t t d|dtf i d S )Na.c                 S   r   rG   rB   r   rB   rB   rC   foo  r   z:BaseCallableTests.test_callable_with_ellipsis.<locals>.foo)r   r   rd   r   globalslocals)r>   r   r  rB   rB   rC   test_callable_with_ellipsis  s
   z-BaseCallableTests.test_callable_with_ellipsisc                 C   s   | j }tj|dtf   d S r   )r   rH   r   r   r   rB   rB   rC   test_ellipsis_in_generic  s   z*BaseCallableTests.test_ellipsis_in_genericc                 C   s:   | j }| |tB t|tf  | t|B tt|f  d S rG   )r   rd   r   r   r   rB   rB   rC   test_or_and_ror  s   z!BaseCallableTests.test_or_and_rorc                 C   sh   | j }|ttgtf }|tjj u r| |tj | 	|j
tjj  | |jtttf | |jd d S r   )r   rh   r   r   collectionsabcr   r   GenericAliasr   r   rd   r   r   r>   r   aliasrB   rB   rC   
test_basic   s   zBaseCallableTests.test_basicc                 C   s.   | j }|ttgtf }| t| | d S rG   )r   rh   r   r   rd   weakrefrefr  rB   rB   rC   test_weakref)  s   zBaseCallableTests.test_weakrefc              
   C   s   | j }tdatda|ttgtf |ttf |ttf |tttf tf g}|D ]F}t	t
jd D ]<}| j||d+ t
||}t
|}| |j|j | |j|j | |j|j W d    n1 siw   Y  q2q)bbd S )NT_pickleP_pickler   )r  proto)r   r
   r  r2   r  rh   r   r   r3   rangepickleHIGHEST_PROTOCOLr   dumpsloadsrd   r   r   r   )r>   r   samplesr  r  sloadedrB   rB   rC   test_pickle.  s(   


zBaseCallableTests.test_picklec                 C   s  | j }|j d}|ttgtf }|ttgtf }|dtf }| |t |ttgtf  |tj u rD| |d  |tt	d gt	d f  | |tt
tf |tt
gtf  | |t |dtf  | |t |dtf  |tttf }| t|| d | t|t | d | |t |ttgtf  |tjt tttf tgtf }| |ttt
f |tjt tttf t
gtf  d S )Nr   .z[[int, ~VT], str]z[[int, dict], str])r   rM   rh   r   r   r   rd   r   rH   rn   r   r	   re   r   r   r   )r>   r   r   C1C2C3C4ZC5rB   rB   rC   test_var_substitutionE  s&   
$" z'BaseCallableTests.test_var_substitutionc                 C   s`   | j }td}td}d}| t| |||f dtf  W d    d S 1 s)w   Y  d S )NPr   zAExpected a list of types, an ellipsis, ParamSpec, or Concatenate.r   )r   r2   r
   assertRaisesRegexr[   rh   )r>   r   r"  r   patrB   rB   rC   test_type_subst_error^  s   "z'BaseCallableTests.test_type_subst_errorc                 C   sR   | j }G dd d|}|tgtf }| | j| | | j|tgtf  d S )Nc                   @      e Zd Zdd ZdS )z/BaseCallableTests.test_type_erasure.<locals>.C1c                 S   r   rG   rB   r]   rB   rB   rC   __call__k  r   z8BaseCallableTests.test_type_erasure.<locals>.C1.__call__N)rL   rM   rN   r'  rB   rB   rB   rC   r  j      r  )r   rh   r   r   	__class__rd   __orig_class__)r>   r   r  r   rB   rB   rC   test_type_erasureh  s
   z#BaseCallableTests.test_type_erasurec                 C   s  | j }|j d}td}td}||tf }| |tgtf |tgtf  | |ttgtf |ttgtf  | |g tf |g tf  | |dtf |dtf  | ||tf ||tf  | |tt|f tf |tt|f tf  | t|| d | t|ttgtf | d | 	t
 |ttf  W d    n1 sw   Y  ||tf }| |tg |tgtf  | |ttg |ttgtf  | |g  |g tf  | |d |dtf  | || ||tf  | |tt|f  |tt|f tf  | |t |tgtf  | |ttf |ttgtf  | t|| d | t|ttf | d d S )	Nr   r"  P2.z[~P, ~T]z[[int, str], str]z	[~P, int]z[[int, str], int])r   rM   r2   r   rd   rh   r   r3   re   rZ   r[   )r>   r   r   r"  r,  r  r  rB   rB   rC   test_paramspecq  s>    $"  "z BaseCallableTests.test_paramspecc                 C   s,  | j }|j d}td}td}td}|tt|f |f }| t|| d | ||tf |tt|f tf  | |tt	gtf |ttt	gtf  | |g tf |tgtf  | |tt|f tf |ttt|f tf  | 
t |dtf  W d    n1 sw   Y  |tt|f tf }| t|| d | || |tt|f tf  | |tt	g |ttt	gtf  | |tt	f |ttt	gtf  | |g  |tgtf  | |tt|f  |ttt|f tf  | 
t |d  W d    d S 1 sw   Y  d S )Nr   r   r"  r,  z![typing.Concatenate[int, ~P], ~T].z"[typing.Concatenate[int, ~P], int])r   rM   r
   r2   r3   rh   rd   re   r   r   rZ   r[   )r>   r   r   r   r"  r,  r   rB   rB   rC   test_concatenate  s@   
$&
 ""
$z"BaseCallableTests.test_concatenatec                 C   s   | j }|ttgtf }| td |t  W d    n1 s w   Y  td}||tf }| td |tttf  W d    n1 sGw   Y  | td |t  W d    d S 1 sbw   Y  d S )Nzis not a generic classr"  many arguments forfew arguments for)r   rh   r   r   r#  r[   r2   r   )r>   r   r  r"  r  rB   rB   rC   ri     s   

"zBaseCallableTests.test_errorsN)rL   rM   rN   r   r   rs   r   r   r   rf   r  r  r  r  r  r  r!  r%  r+  r-  r.  ri   rB   rB   rB   rC   r     s(    	
	"r   c                   @   s   e Zd ZejZdd ZdS )TypingCallableTestsc                 C   sR   t jttgtf }tjjttgtf }| |j|j | t	|jt	|j d S rG   )
rH   r   rh   r   r   r  r	  rd   r   hash)r>   c1c2rB   rB   rC   test_consistency  s   z$TypingCallableTests.test_consistencyN)rL   rM   rN   rH   r   r5  rB   rB   rB   rC   r1    s    r1  c                   @   s   e Zd ZejjZdS )CollectionsCallableTestsN)rL   rM   rN   r  r	  r   rB   rB   rB   rC   r6    r(  r6  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 )LiteralTestsc                 C   sP   t d  t d  t d  t d   t d  t d  t t d t d f  t d  d S )	Nr   r         )r   yzT)r   2Fr   r9        )s   foobar)r   r]   rB   rB   rC   r     s   zLiteralTests.test_basicsc                 C   s*   t t  t d  t ddd  t t  d S )N)y       @      @.rB   r:  r@  r  rB  )r   rh   r   r]   rB   rB   rC   3test_illegal_parameters_do_not_raise_runtime_errors  s   z@LiteralTests.test_illegal_parameters_do_not_raise_runtime_errorsc                 C   s   t td   t td   d S )Nr8  )r  rB  baz)r   r   r]   rB   rB   rC    test_literals_inside_other_types  r   z-LiteralTests.test_literals_inside_other_typesc                 C   sx   |  ttd d |  ttd d |  ttt d |  ttd |  ttd  d |  ttd d	 d S )
Nr   ztyping.Literal[1])r   Tr  ztyping.Literal[1, True, 'foo']ztyping.Literal[int]ztyping.Literalztyping.Literal[None]r   r9  r:  r:  ztyping.Literal[1, 2, 3])rd   re   r   rh   r]   rB   rB   rC   rf     s   zLiteralTests.test_reprc                 C   s   |  t t  W d    n1 sw   Y  |  t td   W d    n1 s-w   Y  |  t tt  W d    n1 sGw   Y  |  t ttd   W d    d S 1 sdw   Y  d S Nr   )rZ   r[   r   rn   r]   rB   rB   rC   test_cannot_init  s   "zLiteralTests.test_cannot_initc                 C   s   |  t tdtd  W d    n1 sw   Y  |  t tttd  W d    n1 s3w   Y  |  t tdtd  W d    n1 sOw   Y  |  t tttd  W d    d S 1 slw   Y  d S rH  )rZ   r[   r\   r   rh   r<   r]   rB   rB   rC    test_no_isinstance_or_issubclass  s   "z-LiteralTests.test_no_isinstance_or_issubclassc                 C   s~   |  t G dd dtd }W d    n1 sw   Y  |  t G dd dt}W d    d S 1 s8w   Y  d S )Nc                   @   rO   )z-LiteralTests.test_no_subclassing.<locals>.FooNrQ   rB   rB   rB   rC   Foo  r   rK  r   c                   @   rO   )z-LiteralTests.test_no_subclassing.<locals>.BarNrQ   rB   rB   rB   rC   Bar  r   rL  rZ   r[   r   )r>   rK  rL  rB   rB   rC   test_no_subclassing   s   "z LiteralTests.test_no_subclassingc                 C   s<   |  t td d  W d    d S 1 sw   Y  d S rH  rM  r]   rB   rB   rC   test_no_multiple_subscripts  s   "z(LiteralTests.test_no_multiple_subscriptsc                 C   s   |  td td  |  td td  |  td td  |  td td  |  td td  |  td td	  | td td  | td td
  | td td  d S )Nr   FTr   r9  )r   T)r   r   r>  Tr9  r9  r   r8  rG  )r   r   rd   r]   rB   rB   rC   
test_equal
  s   zLiteralTests.test_equalc                 C   sX   |  ttd ttd  |  ttd ttd  |  ttd ttd  d S )Nr   r>  rQ  r8  rG  )rd   r2  r   r]   rB   rB   rC   	test_hash  s    zLiteralTests.test_hashc                 C   sb   |  td jd |  td jd |  tdtd td f jd |  tg g f jg g f d S )Nr8  rG  r   r9  )r:  r@  )r   r9  r:  r@  )rd   r   r   r]   rB   rB   rC   	test_args  s    zLiteralTests.test_argsc                 C   sh   t t d t d t d f }t t d df }t t d  }|||fD ]}| |t d  | |jd q d S )Nr   r9  r:  r>  r8  )r   rd   r   )r>   l1l2l3lrB   rB   rC   test_flatten!  s   zLiteralTests.test_flattenN)rL   rM   rN   r   rD  rF  rf   rI  rJ  rN  rO  rR  rS  rT  rY  rB   rB   rB   rC   r7    s    

r7  XKXVc                   @   sH   e Zd ZdedefddZdedefddZdded	edefd
dZdS )SimpleMappingkeyr   c                 C   r   rG   rB   r>   r]  rB   rB   rC   __getitem__0  r   zSimpleMapping.__getitem__valuec                 C   r   rG   rB   r>   r]  r`  rB   rB   rC   __setitem__3  r   zSimpleMapping.__setitem__Ndefaultc                 C   r   rG   rB   r>   r]  rc  rB   rB   rC   get6  r   zSimpleMapping.getrG   )rL   rM   rN   rZ  r[  r_  rb  re  rB   rB   rB   rC   r\  .  s    r\  c                   @   s@   e Zd Zdd ZdefddZdefddZddefd	d
ZdS )MySimpleMappingc                 C   s
   i | _ d S rG   storer]   rB   rB   rC   __init__<     
zMySimpleMapping.__init__r]  c                 C   s
   | j | S rG   rg  r^  rB   rB   rC   r_  ?  rj  zMySimpleMapping.__getitem__c                 C   s   || j |< d S rG   rg  ra  rB   rB   rC   rb  B     zMySimpleMapping.__setitem__Nc                 C   s$   z| j | W S  ty   | Y S w rG   )rh  KeyErrorrd  rB   rB   rC   re  E  s
   zMySimpleMapping.getrG   )rL   rM   rN   ri  r   r_  rb  re  rB   rB   rB   rC   rf  :  s
    rf  c                   @      e Zd ZU eed< eed< dS )
Coordinater   r;  NrL   rM   rN   rh   __annotations__rB   rB   rB   rC   rn  L     
 rn  c                   @      e Zd ZU eed< dS )PointlabelNrL   rM   rN   r   rp  rB   rB   rB   rC   rs  P     
 rs  c                   @   s&   e Zd ZU eed< eed< eed< dS )MyPointr   r;  rt  NrL   rM   rN   rh   rp  r   rB   rB   rB   rC   rw  T  s   
 rw  c                   @   rr  )XAxisr   Nro  rB   rB   rB   rC   ry  Y     
 ry  c                   @   rr  )YAxisr;  Nro  rB   rB   rB   rC   r{  \  rz  r{  c                   @   rO   )PositionNrQ   rB   rB   rB   rC   r|  _      r|  c                   @   s(   e Zd ZU eed< dedefddZdS )Protoattrr   r   c                 C   r   rG   rB   r>   r   rB   rB   rC   methf  r   z
Proto.methN)rL   rM   rN   rh   rp  r   r  rB   rB   rB   rC   r~  c  s   
 r~  c                   @   rO   )ConcreteNrQ   rB   rB   rB   rC   r  i  rR   r  c                   @   s,   e Zd ZU dZeed< dedefddZdS )Otherr   r  r   r   c                 C   s   |dkrdS dS )Nthisr   r   rB   r  rB   rB   rC   r  n  s   z
Other.methN)rL   rM   rN   r  rh   rp  r   r  rB   rB   rB   rC   r  l  s   
 r  c                   @   rm  )NTr   r;  Nro  rB   rB   rB   rC   r  s  rq  r  c                   @   s   e Zd ZU ejed< dS )HasCallProtocolr'  N)rL   rM   rN   rH   r   rp  rB   rB   rB   rC   r  w  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%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWdX Z.dYdZ Z/d[d\ Z0d]d^ Z1d_d` Z2daS )bProtocolTestsc                 C   s   t G dd dt}G dd d}G dd d}dd }| || | | | | || | | | | tj| | || d S )	Nc                   @   r&  )z,ProtocolTests.test_basic_protocol.<locals>.Pc                 S   r   rG   rB   r]   rB   rB   rC   r    r   z1ProtocolTests.test_basic_protocol.<locals>.P.methNrL   rM   rN   r  rB   rB   rB   rC   r"  ~      r"  c                   @   rO   )z,ProtocolTests.test_basic_protocol.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   c                   @   r&  )z,ProtocolTests.test_basic_protocol.<locals>.Dc                 S   r   rG   rB   r]   rB   rB   rC   r    r   z1ProtocolTests.test_basic_protocol.<locals>.D.methNr  rB   rB   rB   rC   D  r(  r  c                   S   r   rG   rB   rB   rB   rB   rC   rJ     r   z,ProtocolTests.test_basic_protocol.<locals>.f)r   r   rD   r   rF   r   r   r   )r>   r"  r   r  rJ   rB   rB   rC   test_basic_protocol}  s   z!ProtocolTests.test_basic_protocolc                 C   sr   t G dd dt}G dd d}dd }ttt|tjfD ]}| || qt ddt|fD ]}| 	|| q.d S )	Nc                   @   rO   )zFProtocolTests.test_everything_implements_empty_protocol.<locals>.EmptyNrQ   rB   rB   rB   rC   Empty  r}  r  c                   @   rO   )zBProtocolTests.test_everything_implements_empty_protocol.<locals>.CNrQ   rB   rB   rB   rC   r     rR   r   c                   S   r   rG   rB   rB   rB   rB   rC   rJ     r   zBProtocolTests.test_everything_implements_empty_protocol.<locals>.fr   rB   )
r   r   r   rn   r   r   r   rD   rH   r   )r>   r  r   rJ   thingrB   rB   rC   )test_everything_implements_empty_protocol  s   z7ProtocolTests.test_everything_implements_empty_protocolc                 C   s   dd }|  |t d S )Nc                   S   r   rG   rB   rB   rB   rB   rC   rJ     r   z:ProtocolTests.test_function_implements_protocol.<locals>.f)r   r  rI   rB   rB   rC   !test_function_implements_protocol  s   z/ProtocolTests.test_function_implements_protocolc                 C   s  G dd d}G dd dt }| t G dd d|t }W d    n1 s(w   Y  | t G dd dt |}W d    n1 sFw   Y  | t G dd d||t }W d    n1 sew   Y  G d	d
 d
||}G dd d||}| | | | | | d S )Nc                   @   rO   )z9ProtocolTests.test_no_inheritance_from_nominal.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   c                   @   rO   )z:ProtocolTests.test_no_inheritance_from_nominal.<locals>.BPNrQ   rB   rB   rB   rC   BP  r   r  c                   @   rO   z9ProtocolTests.test_no_inheritance_from_nominal.<locals>.PNrQ   rB   rB   rB   rC   r"    rR   r"  c                   @   rO   r  rQ   rB   rB   rB   rC   r"    rR   c                   @   rO   r  rQ   rB   rB   rB   rC   r"    rR   c                   @   rO   )z9ProtocolTests.test_no_inheritance_from_nominal.<locals>.DNrQ   rB   rB   rB   rC   r    r   r  c                   @   rO   )z9ProtocolTests.test_no_inheritance_from_nominal.<locals>.ENrQ   rB   rB   rB   rC   E  r   r  )r   rZ   r[   r   )r>   r   r  r"  r  r  rB   rB   rC    test_no_inheritance_from_nominal  s   z.ProtocolTests.test_no_inheritance_from_nominalc                 C   s  G dd dt }| t |  W d    n1 sw   Y  G dd d|}| | | | t |d W d    n1 sCw   Y  td}G dd dt | }| t |  W d    n1 siw   Y  | t |t   W d    n1 sw   Y  | t ||   W d    n1 sw   Y  G d	d
 d
|| }| |t  | | t |t d W d    d S 1 sw   Y  d S )Nc                   @   rO   )z.ProtocolTests.test_no_instantiation.<locals>.PNrQ   rB   rB   rB   rC   r"    r   r"  c                   @   rO   )z.ProtocolTests.test_no_instantiation.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   rY   r   c                   @   rO   )z/ProtocolTests.test_no_instantiation.<locals>.PGNrQ   rB   rB   rB   rC   PG  r   r  c                   @   rO   )z/ProtocolTests.test_no_instantiation.<locals>.CGNrQ   rB   rB   rB   rC   CG  r   r  )r   rZ   r[   r   r
   rh   )r>   r"  r   r   r  r  rB   rB   rC   test_no_instantiation  s2   
"z#ProtocolTests.test_no_instantiationc                 C   sv   t G dd dt}G dd d|}G dd d|}| t |  W d    n1 s-w   Y  | | | d S )Nc                   @   s    e Zd ZejdefddZdS )z9ProtocolTests.test_cannot_instantiate_abstract.<locals>.Pr   c                 S   s   t rG   )NotImplementedErrorr]   rB   rB   rC   ameth     z?ProtocolTests.test_cannot_instantiate_abstract.<locals>.P.amethN)rL   rM   rN   r	  abstractmethodrh   r  rB   rB   rB   rC   r"    s    r"  c                   @   rO   )z9ProtocolTests.test_cannot_instantiate_abstract.<locals>.BNrQ   rB   rB   rB   rC   B  rR   r  c                   @      e Zd ZdefddZdS )z9ProtocolTests.test_cannot_instantiate_abstract.<locals>.Cr   c                 S      dS )N   rB   r]   rB   rB   rC   r    r   z?ProtocolTests.test_cannot_instantiate_abstract.<locals>.C.amethN)rL   rM   rN   rh   r  rB   rB   rB   rC   r         r   )r   r   rZ   r[   r   )r>   r"  r  r   rB   rB   rC    test_cannot_instantiate_abstract  s   z.ProtocolTests.test_cannot_instantiate_abstractc                 C   s   G dd dt }tG dd d|t }G dd d}G dd d}G d	d
 d
}| | | | | | | || | || | | | | || d S )Nc                   @   r&  )z5ProtocolTests.test_subprotocols_extending.<locals>.P1c                 S   r   rG   rB   r]   rB   rB   rC   meth1  r   z;ProtocolTests.test_subprotocols_extending.<locals>.P1.meth1NrL   rM   rN   r  rB   rB   rB   rC   P1  r(  r  c                   @   r&  )z5ProtocolTests.test_subprotocols_extending.<locals>.P2c                 S   r   rG   rB   r]   rB   rB   rC   meth2  r   z;ProtocolTests.test_subprotocols_extending.<locals>.P2.meth2NrL   rM   rN   r  rB   rB   rB   rC   r,    r  r,  c                   @      e Zd Zdd Zdd ZdS )z4ProtocolTests.test_subprotocols_extending.<locals>.Cc                 S   r   rG   rB   r]   rB   rB   rC   r    r   z:ProtocolTests.test_subprotocols_extending.<locals>.C.meth1c                 S   r   rG   rB   r]   rB   rB   rC   r    r   z:ProtocolTests.test_subprotocols_extending.<locals>.C.meth2NrL   rM   rN   r  r  rB   rB   rB   rC   r         r   c                   @   r&  )z5ProtocolTests.test_subprotocols_extending.<locals>.C1c                 S   r   rG   rB   r]   rB   rB   rC   r     r   z;ProtocolTests.test_subprotocols_extending.<locals>.C1.meth1Nr  rB   rB   rB   rC   r    r(  r  c                   @   r&  )z5ProtocolTests.test_subprotocols_extending.<locals>.C2c                 S   r   rG   rB   r]   rB   rB   rC   r    r   z;ProtocolTests.test_subprotocols_extending.<locals>.C2.meth2Nr  rB   rB   rB   rC   r    r(  r  r   r   r   rF   r   rD   )r>   r  r,  r   r  r  rB   rB   rC   test_subprotocols_extending  s   z)ProtocolTests.test_subprotocols_extendingc                 C   s   G dd dt }G dd dt }tG dd d||t }G dd d}G d	d
 d
}G dd d}| | | | | | | || | || | | | | || d S )Nc                   @   r&  )z3ProtocolTests.test_subprotocols_merging.<locals>.P1c                 S   r   rG   rB   r]   rB   rB   rC   r    r   z9ProtocolTests.test_subprotocols_merging.<locals>.P1.meth1Nr  rB   rB   rB   rC   r    r(  r  c                   @   r&  )z3ProtocolTests.test_subprotocols_merging.<locals>.P2c                 S   r   rG   rB   r]   rB   rB   rC   r    r   z9ProtocolTests.test_subprotocols_merging.<locals>.P2.meth2Nr  rB   rB   rB   rC   r,    r(  r,  c                   @   rO   )z2ProtocolTests.test_subprotocols_merging.<locals>.PNrQ   rB   rB   rB   rC   r"    r}  r"  c                   @   r  )z2ProtocolTests.test_subprotocols_merging.<locals>.Cc                 S   r   rG   rB   r]   rB   rB   rC   r    r   z8ProtocolTests.test_subprotocols_merging.<locals>.C.meth1c                 S   r   rG   rB   r]   rB   rB   rC   r    r   z8ProtocolTests.test_subprotocols_merging.<locals>.C.meth2Nr  rB   rB   rB   rC   r     r  r   c                   @   r&  )z3ProtocolTests.test_subprotocols_merging.<locals>.C1c                 S   r   rG   rB   r]   rB   rB   rC   r  #  r   z9ProtocolTests.test_subprotocols_merging.<locals>.C1.meth1Nr  rB   rB   rB   rC   r  "  r(  r  c                   @   r&  )z3ProtocolTests.test_subprotocols_merging.<locals>.C2c                 S   r   rG   rB   r]   rB   rB   rC   r  '  r   z9ProtocolTests.test_subprotocols_merging.<locals>.C2.meth2Nr  rB   rB   rB   rC   r  &  r(  r  r  )r>   r  r,  r"  r   r  r  rB   rB   rC   test_subprotocols_merging  s   z'ProtocolTests.test_subprotocols_mergingc                 C   s  t d}tG dd dt}tG dd dt| }G dd dt}G dd	 d	t| }G d
d d}| || | || | || | t t|||  W d    n1 s\w   Y  | t t|||  W d    n1 sxw   Y  | t t|| W d    n1 sw   Y  | t t|| W d    n1 sw   Y  | t t|||  W d    n1 sw   Y  | t t||t  W d    d S 1 sw   Y  d S )Nr   c                   @   r&  )z2ProtocolTests.test_protocols_issubclass.<locals>.Pc                 S   r   rG   rB   r]   rB   rB   rC   r   6  r   z4ProtocolTests.test_protocols_issubclass.<locals>.P.xNrL   rM   rN   r   rB   rB   rB   rC   r"  4  r  r"  c                   @   r&  )z3ProtocolTests.test_protocols_issubclass.<locals>.PGc                 S   r   rG   rB   r]   rB   rB   rC   r   :  r   z5ProtocolTests.test_protocols_issubclass.<locals>.PG.xNr  rB   rB   rB   rC   r  8  r  r  c                   @   r&  )z5ProtocolTests.test_protocols_issubclass.<locals>.BadPc                 S   r   rG   rB   r]   rB   rB   rC   r   =  r   z7ProtocolTests.test_protocols_issubclass.<locals>.BadP.xNr  rB   rB   rB   rC   BadP<  r(  r  c                   @   r&  )z6ProtocolTests.test_protocols_issubclass.<locals>.BadPGc                 S   r   rG   rB   r]   rB   rB   rC   r   @  r   z8ProtocolTests.test_protocols_issubclass.<locals>.BadPG.xNr  rB   rB   rB   rC   BadPG?  r(  r  c                   @   r&  )z2ProtocolTests.test_protocols_issubclass.<locals>.Cc                 S   r   rG   rB   r]   rB   rB   rC   r   C  r   z4ProtocolTests.test_protocols_issubclass.<locals>.C.xNr  rB   rB   rB   rC   r   B  r(  r   )r
   r   r   rD   rZ   r[   r<   rh   r>   r   r"  r  r  r  r   rB   rB   rC   test_protocols_issubclass1  s:   "z'ProtocolTests.test_protocols_issubclassc                 C   s8  G dd d}t G dd dt}| t t|| W d    n1 s&w   Y  | | | || | t t|| W d    n1 sLw   Y  | | | G dd d|}| || | | | || | 	|| | | | | t t|| W d    d S 1 sw   Y  d S )Nc                   @      e Zd ZdZdS )z?ProtocolTests.test_protocols_issubclass_non_callable.<locals>.Cr   Nr  rB   rB   rB   rC   r   W      r   c                   @   r  )zFProtocolTests.test_protocols_issubclass_non_callable.<locals>.PNonCallr   Nr  rB   rB   rB   rC   PNonCallZ      r  c                   @   rO   )z?ProtocolTests.test_protocols_issubclass_non_callable.<locals>.DNrQ   rB   rB   rB   rC   r  g  r   r  )
r   r   rZ   r[   r<   r   registerrF   r   rD   )r>   r   r  r  rB   rB   rC   &test_protocols_issubclass_non_callableV  s*   

"z4ProtocolTests.test_protocols_issubclass_non_callablec                 C   sh  t d}tG dd dt}tG dd dt| }G dd dt}G dd	 d	t| }G d
d d}| | | | | | | t t| ||  W d    n1 sYw   Y  | t t| ||  W d    n1 svw   Y  | t t| | W d    n1 sw   Y  | t t| | W d    d S 1 sw   Y  d S )Nr   c                   @   r&  )z2ProtocolTests.test_protocols_isinstance.<locals>.Pc                 S   r   rG   rB   r   rB   rB   rC   r  v  r   z7ProtocolTests.test_protocols_isinstance.<locals>.P.methNr  rB   rB   rB   rC   r"  t  r  r"  c                   @   r&  )z3ProtocolTests.test_protocols_isinstance.<locals>.PGc                 S   r   rG   rB   r   rB   rB   rC   r  z  r   z8ProtocolTests.test_protocols_isinstance.<locals>.PG.methNr  rB   rB   rB   rC   r  x  r  r  c                   @   r&  )z5ProtocolTests.test_protocols_isinstance.<locals>.BadPc                 S   r   rG   rB   r   rB   rB   rC   r  }  r   z:ProtocolTests.test_protocols_isinstance.<locals>.BadP.methNr  rB   rB   rB   rC   r  |  r(  r  c                   @   r&  )z6ProtocolTests.test_protocols_isinstance.<locals>.BadPGc                 S   r   rG   rB   r   rB   rB   rC   r    r   z;ProtocolTests.test_protocols_isinstance.<locals>.BadPG.methNr  rB   rB   rB   rC   r    r(  r  c                   @   r&  )z2ProtocolTests.test_protocols_isinstance.<locals>.Cc                 S   r   rG   rB   r   rB   rB   rC   r    r   z7ProtocolTests.test_protocols_isinstance.<locals>.C.methNr  rB   rB   rB   rC   r     r(  r   )r
   r   r   r   rZ   r[   r\   r  rB   rB   rC   test_protocols_isinstanceq  s,   "z'ProtocolTests.test_protocols_isinstancec                    sZ  G dd d}G dd d G  fddd}G dd d|}G d	d
 d
|}G dd d}t dtG dd dt}tG dd dt}tG dd dt }tG fdddt }	||||	fD ]J}
||||fD ]"}| j|j|
jd | | |
 W d    n1 sw   Y  qn| jd|
jd | | |
 W d    n1 sw   Y  qfG dd dt}G dd dt}G dd dt }G fdddt }| || |	 |	| ||||fD ]A}|||||fD ]7}| j|j|d$ | t t	| | W d    n	1 sw   Y  W d    n	1 s$w   Y  qqd S ) Nc                   @      e Zd Zedd ZdS )zMProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.Cc                 S   r  rX   rB   r]   rB   rB   rC   r    r  zRProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.C.attrNrL   rM   rN   propertyr  rB   rB   rB   rC   r         r   c                   @   s   e Zd ZdddZdS )z\ProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.CustomDescriptorNc                 S   r  rX   rB   )r>   objZobjtyperB   rB   rC   __get__  r   zdProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.CustomDescriptor.__get__rG   )rL   rM   rN   r  rB   rB   rB   rC   CustomDescriptor      r  c                       s   e Zd Z  ZdS )zMProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.DN)rL   rM   rN   r  rB   )r  rB   rC   r        
r  c                   @   rO   )zMProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.ENrQ   rB   rB   rB   rC   r    r   r  c                   @   rO   )zMProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.FNrQ   rB   rB   rB   rC   F  r   r  c                   @   rO   )zQProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.EmptyNrQ   rB   rB   rB   rC   r    r   r  r   c                   @   r  )zMProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.Pc                 S   r   rG   rB   r]   rB   rB   rC   r    r   zRProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.P.attrNr  rB   rB   rB   rC   r"        r"  c                   @   rr  )zNProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.P1r  Nro  rB   rB   rB   rC   r    rv  r  c                   @   r  )zNProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.PGc                 S   r   rG   rB   r]   rB   rB   rC   r    r   zSProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.PG.attrNr  rB   rB   rB   rC   r    r  r  c                          e Zd ZU  ed< dS )zOProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.PG1r  NrL   rM   rN   rp  rB   r   rB   rC   PG1  rv  r  )klassprotocol_classc                   @   r  )zPProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.BadPc                 S   r   rG   rB   r]   rB   rB   rC   r    r   zUProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.BadP.attrNr  rB   rB   rB   rC   r    r  r  c                   @   rr  )zQProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.BadP1r  Nro  rB   rB   rB   rC   BadP1  rz  r  c                   @   r  )zQProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.BadPGc                 S   r   rG   rB   r]   rB   rB   rC   r    r   zVProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.BadPG.attrNr  rB   rB   rB   rC   r    r  r  c                       r  )zRProtocolTests.test_protocols_isinstance_properties_and_descriptors.<locals>.BadPG1r  Nr  rB   r  rB   rC   BadPG1  rz  r  )r  r  )
r
   r   r   r   rL   r   r   rZ   r[   r\   )r>   r   r  r  r  r  r"  r  r  r  r  r  r  r  r  r  r  rB   )r  r   rC   4test_protocols_isinstance_properties_and_descriptors  sV   (zBProtocolTests.test_protocols_isinstance_properties_and_descriptorsc                 C   sP   t G dd dt}G dd d}G dd d}| | | | | | d S )Nc                   @   rr  )zNProtocolTests.test_protocols_isinstance_not_fooled_by_custom_dir.<locals>.HasXr   Nro  rB   rB   rB   rC   HasX  rv  r  c                   @      e Zd ZdZdd ZdS )zXProtocolTests.test_protocols_isinstance_not_fooled_by_custom_dir.<locals>.CustomDirWithX
   c                 S      g S rG   rB   r]   rB   rB   rC   __dir__  r   z`ProtocolTests.test_protocols_isinstance_not_fooled_by_custom_dir.<locals>.CustomDirWithX.__dir__N)rL   rM   rN   r   r  rB   rB   rB   rC   CustomDirWithX  s    r  c                   @   r&  )z[ProtocolTests.test_protocols_isinstance_not_fooled_by_custom_dir.<locals>.CustomDirWithoutXc                 S   s   dgS )Nr   rB   r]   rB   rB   rC   r       zcProtocolTests.test_protocols_isinstance_not_fooled_by_custom_dir.<locals>.CustomDirWithoutX.__dir__N)rL   rM   rN   r  rB   rB   rB   rC   CustomDirWithoutX  r(  r  )r   r   r   r   )r>   r  r  r  rB   rB   rC   2test_protocols_isinstance_not_fooled_by_custom_dir  s   z@ProtocolTests.test_protocols_isinstance_not_fooled_by_custom_dirc                 C   s  G dd d}G dd d}G dd d}G dd d}|  |d	d
dt |  |d	d
t | t t |  |d	d
t |  t t |  t t |  |dt | | t | | t | | t | | t | t t |  td	d
t d S )Nc                   @   r&  )z<ProtocolTests.test_protocols_isinstance_py36.<locals>.APointc                 S      || _ || _|| _d S rG   r   r;  rt  )r>   r   r;  rt  rB   rB   rC   ri    s   
zEProtocolTests.test_protocols_isinstance_py36.<locals>.APoint.__init__NrL   rM   rN   ri  rB   rB   rB   rC   APoint  r(  r  c                   @   r  )z<ProtocolTests.test_protocols_isinstance_py36.<locals>.BPointr  c                 S      || _ || _d S rG   r   r;  )r>   r   r;  rB   rB   rC   ri    s   
zEProtocolTests.test_protocols_isinstance_py36.<locals>.BPoint.__init__N)rL   rM   rN   rt  ri  rB   rB   rB   rC   BPoint      r  c                   @   r  )z7ProtocolTests.test_protocols_isinstance_py36.<locals>.Cc                 S   
   || _ d S rG   r  r>   r  rB   rB   rC   ri    rj  z@ProtocolTests.test_protocols_isinstance_py36.<locals>.C.__init__c                 S   r  Nr   rB   r  rB   rB   rC   r    r   z<ProtocolTests.test_protocols_isinstance_py36.<locals>.C.methN)rL   rM   rN   ri  r  rB   rB   rB   rC   r     r  r   c                   @   rO   )z9ProtocolTests.test_protocols_isinstance_py36.<locals>.BadNrQ   rB   rB   rB   rC   Bad  r   r  r   r9  rl   rY   )	r   rs  r   rw  r|  r  r~  r  r  )r>   r  r  r   r  rB   rB   rC   test_protocols_isinstance_py36  s"   z,ProtocolTests.test_protocols_isinstance_py36c                 C   sf   t d}tG dd dt}tG dd dt| }G dd d}| |d| | |d| d S )	Nr   c                   @   r  )z7ProtocolTests.test_protocols_isinstance_init.<locals>.Pr   Nr  rB   rB   rB   rC   r"    r  r"  c                   @   r  )z8ProtocolTests.test_protocols_isinstance_init.<locals>.PGr   Nr  rB   rB   rB   rC   r    r  r  c                   @   r&  )z7ProtocolTests.test_protocols_isinstance_init.<locals>.Cc                 S   r  rG   r   r>   r   rB   rB   rC   ri    rj  z@ProtocolTests.test_protocols_isinstance_init.<locals>.C.__init__Nr  rB   rB   rB   rC   r     r(  r   r   )r
   r   r   r   )r>   r   r"  r  r   rB   rB   rC   test_protocols_isinstance_init  s   z,ProtocolTests.test_protocols_isinstance_initc           	      C   s   G dd dt t }G dd d|t }G dd d}G dd d}|t }| | | | || G d	d
 d
|t }G dd d|t }|t }| | | | || d S )Nc                   @   rO   )z=ProtocolTests.test_protocol_checks_after_subscript.<locals>.PNrQ   rB   rB   rB   rC   r"     r   r"  c                   @   rO   )z=ProtocolTests.test_protocol_checks_after_subscript.<locals>.CNrQ   rB   rB   rB   rC   r   !  r   r   c                   @   rO   )zBProtocolTests.test_protocol_checks_after_subscript.<locals>.Other1NrQ   rB   rB   rB   rC   Other1"  r   r  c                   @   rO   )zBProtocolTests.test_protocol_checks_after_subscript.<locals>.Other2NrQ   rB   rB   rB   rC   Other2#  r   r  c                   @   rO   )z>ProtocolTests.test_protocol_checks_after_subscript.<locals>.D1NrQ   rB   rB   rB   rC   D1)  r   r  c                   @   rO   )z>ProtocolTests.test_protocol_checks_after_subscript.<locals>.D2NrQ   rB   rB   rB   rC   D2*  r   r  )r   r   r   r   rF   rh   r   rD   )	r>   r"  r   r  r  ZCAr  r  CIrB   rB   rC   $test_protocol_checks_after_subscript  s   z2ProtocolTests.test_protocol_checks_after_subscriptc                 C   sv   t G dd dt}G dd dt}G dd d|}G dd d}|| || | | | | | | d S )	Nc                   @   r  )z8ProtocolTests.test_protocols_support_register.<locals>.Pr   Nr  rB   rB   rB   rC   r"  1  r  r"  c                   @   r&  )z9ProtocolTests.test_protocols_support_register.<locals>.PMc                 S   r   rG   rB   r]   rB   rB   rC   r  6  r   z>ProtocolTests.test_protocols_support_register.<locals>.PM.methNr  rB   rB   rB   rC   PM5  r(  r  c                   @   rO   )z8ProtocolTests.test_protocols_support_register.<locals>.DNrQ   rB   rB   rB   rC   r  8  r   r  c                   @   rO   )z8ProtocolTests.test_protocols_support_register.<locals>.CNrQ   rB   rB   rB   rC   r   :  r   r   )r   r   r  r   )r>   r"  r  r  r   rB   rB   rC   test_protocols_support_register0  s   

z-ProtocolTests.test_protocols_support_registerc                 C   `   t G dd dt}G dd d}G dd d|}G dd d}| | | | | | d S )	Nc                   @   r  )zNProtocolTests.test_none_on_non_callable_doesnt_block_implementation.<locals>.Pr   Nr  rB   rB   rB   rC   r"  B  r  r"  c                   @   r  )zNProtocolTests.test_none_on_non_callable_doesnt_block_implementation.<locals>.Ar   Nr  rB   rB   rB   rC   rl   F  r  rl   c                   @      e Zd ZdZdS )zNProtocolTests.test_none_on_non_callable_doesnt_block_implementation.<locals>.BNr  rB   rB   rB   rC   r  I  r  r  c                   @   r&  )zNProtocolTests.test_none_on_non_callable_doesnt_block_implementation.<locals>.Cc                 S   
   d | _ d S rG   r   r]   rB   rB   rC   ri  M  rj  zWProtocolTests.test_none_on_non_callable_doesnt_block_implementation.<locals>.C.__init__Nr  rB   rB   rB   rC   r   L  r(  r   )r   r   r   r>   r"  rl   r  r   rB   rB   rC   5test_none_on_non_callable_doesnt_block_implementationA     zCProtocolTests.test_none_on_non_callable_doesnt_block_implementationc                 C   r  )	Nc                   @   r&  )zDProtocolTests.test_none_on_callable_blocks_implementation.<locals>.Pc                 S   r   rG   rB   r]   rB   rB   rC   r   V  r   zFProtocolTests.test_none_on_callable_blocks_implementation.<locals>.P.xNr  rB   rB   rB   rC   r"  T  r  r"  c                   @   r&  )zDProtocolTests.test_none_on_callable_blocks_implementation.<locals>.Ac                 S   r   rG   rB   r]   rB   rB   rC   r   Y  r   zFProtocolTests.test_none_on_callable_blocks_implementation.<locals>.A.xNr  rB   rB   rB   rC   rl   X  r(  rl   c                   @   r  )zDProtocolTests.test_none_on_callable_blocks_implementation.<locals>.BNr  rB   rB   rB   rC   r  [  r  r  c                   @   r&  )zDProtocolTests.test_none_on_callable_blocks_implementation.<locals>.Cc                 S   r  rG   r   r]   rB   rB   rC   ri  _  rj  zMProtocolTests.test_none_on_callable_blocks_implementation.<locals>.C.__init__Nr  rB   rB   rB   rC   r   ^  r(  r   )r   r   r   r  rB   rB   rC   +test_none_on_callable_blocks_implementationS  r  z9ProtocolTests.test_none_on_callable_blocks_implementationc                 C   s   G dd dt }tG dd dt }G dd d|}G dd d|}G d	d
 d
}G dd d}| | | | | | | || | || | | | | || d S )Nc                   @   r  )z5ProtocolTests.test_non_protocol_subclasses.<locals>.Pr   Nr  rB   rB   rB   rC   r"  f  r  r"  c                   @   r&  )z6ProtocolTests.test_non_protocol_subclasses.<locals>.PRc                 S   r   rG   rB   r]   rB   rB   rC   r  k  r   z;ProtocolTests.test_non_protocol_subclasses.<locals>.PR.methNr  rB   rB   rB   rC   PRi  r  r  c                   @   r  )z8ProtocolTests.test_non_protocol_subclasses.<locals>.NonPr   Nr  rB   rB   rB   rC   NonPm  r  r  c                   @   rO   )z9ProtocolTests.test_non_protocol_subclasses.<locals>.NonPRNrQ   rB   rB   rB   rC   NonPRp  r   r  c                   @   r  )z5ProtocolTests.test_non_protocol_subclasses.<locals>.Cr   Nr  rB   rB   rB   rC   r   r  r  r   c                   @   r&  )z5ProtocolTests.test_non_protocol_subclasses.<locals>.Dc                 S   r   rG   rB   r]   rB   rB   rC   r  v  r   z:ProtocolTests.test_non_protocol_subclasses.<locals>.D.methNr  rB   rB   rB   rC   r  u  r(  r  r  )r>   r"  r  r  r  r   r  rB   rB   rC   test_non_protocol_subclassese  s   z*ProtocolTests.test_non_protocol_subclassesc                 C   st   G dd dt }G dd d}G dd d}G dd d|}| | | | | | | || | || d S )	Nc                   @   r  )z1ProtocolTests.test_custom_subclasshook.<locals>.Pr   Nr  rB   rB   rB   rC   r"    r  r"  c                   @   rO   )z7ProtocolTests.test_custom_subclasshook.<locals>.OKClassNrQ   rB   rB   rB   rC   OKClass  r   r  c                   @   r  )z8ProtocolTests.test_custom_subclasshook.<locals>.BadClassr   Nr  rB   rB   rB   rC   BadClass  r  r  c                   @   r  )z1ProtocolTests.test_custom_subclasshook.<locals>.Cc                 S   s   |j dS NOK)rL   
startswithr?   otherrB   rB   rC   __subclasshook__  s   zBProtocolTests.test_custom_subclasshook.<locals>.C.__subclasshook__NrL   rM   rN   classmethodr  rB   rB   rB   rC   r     r  r   )r   r   r   rD   rF   )r>   r"  r  r  r   rB   rB   rC   test_custom_subclasshook  s   z&ProtocolTests.test_custom_subclasshookc                 C   s^   t G dd dt}G dd d}| t t| | W d    d S 1 s(w   Y  d S )Nc                   @   r  )z8ProtocolTests.test_issubclass_fails_correctly.<locals>.Pr   Nr  rB   rB   rB   rC   r"    r  r"  c                   @   rO   )z8ProtocolTests.test_issubclass_fails_correctly.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   )r   r   rZ   r[   r<   r>   r"  r   rB   rB   rC   test_issubclass_fails_correctly  s   "z-ProtocolTests.test_issubclass_fails_correctlyc                 C   s   t d}t d}tG dd dt||f }G dd d|t|f t| }| t |t  W d    n1 s9w   Y  | t |ttf  W d    n1 sTw   Y  G dd d|t|f }| |t  | d S )	Nr   Sc                   @   r&  )z9ProtocolTests.test_defining_generic_protocols.<locals>.PRc                 S   r   rG   rB   r]   rB   rB   rC   r    r   z>ProtocolTests.test_defining_generic_protocols.<locals>.PR.methNr  rB   rB   rB   rC   r    r  r  c                   @   r  )z8ProtocolTests.test_defining_generic_protocols.<locals>.Pr   NrL   rM   rN   r;  rB   rB   rB   rC   r"    r  r"  c                   @   rO   )z8ProtocolTests.test_defining_generic_protocols.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   )r
   r   r   rh   rZ   r[   r   r   )r>   r   r  r  r"  r   rB   rB   rC   test_defining_generic_protocols  s   
z-ProtocolTests.test_defining_generic_protocolsc                    s0  t d t d}tG dd dtt |f }G dd d|ttf t}| t t|ttf | W d    n1 s=w   Y  | 	|| | t |t  W d    n1 s\w   Y  G  fdddtt  }G  fd	d
d
t  t}tG dd d|t t}G dd d}| 
| | d S )Nr   r  c                   @   r&  )zCProtocolTests.test_defining_generic_protocols_old_style.<locals>.PRc                 S   r   rG   rB   r]   rB   rB   rC   r    r   zHProtocolTests.test_defining_generic_protocols_old_style.<locals>.PR.methNr  rB   rB   rB   rC   r    r  r  c                   @   r  )zBProtocolTests.test_defining_generic_protocols_old_style.<locals>.Pr   Nr  rB   rB   rB   rC   r"    r  r"  c                          e Zd Zd defddZdS )zCProtocolTests.test_defining_generic_protocols_old_style.<locals>.P1r   r   c                 S   r   rG   rB   r  rB   rB   rC   rB    r   zGProtocolTests.test_defining_generic_protocols_old_style.<locals>.P1.barNrL   rM   rN   r   rB  rB   r  rB   rC   r        r  c                       r  )zCProtocolTests.test_defining_generic_protocols_old_style.<locals>.P2r   r   c                 S   r   rG   rB   r  rB   rB   rC   rB    r   zGProtocolTests.test_defining_generic_protocols_old_style.<locals>.P2.barNr	  rB   r  rB   rC   r,    r
  r,  c                   @   r  )zEProtocolTests.test_defining_generic_protocols_old_style.<locals>.PSubr   Nr  rB   rB   rB   rC   PSub  r  r  c                   @   s"   e Zd ZdZdedefddZdS )zEProtocolTests.test_defining_generic_protocols_old_style.<locals>.Testr   r   r   c                 S   s   |S rG   rB   r  rB   rB   rC   rB    r   zIProtocolTests.test_defining_generic_protocols_old_style.<locals>.Test.barN)rL   rM   rN   r   r   rB  rB   rB   rB   rC   Test  s    r  )r
   r   r   r   rh   r   rZ   r[   r<   rD   r   )r>   r  r  r"  r  r,  r  r  rB   r  rC   )test_defining_generic_protocols_old_style  s$   
z7ProtocolTests.test_defining_generic_protocols_old_stylec                 C   s   t d}G dd dt| }G dd d|| }| |t  jd G dd d}G d	d
 d
||| }| |t  jd G dd d|| |}| |t  jd d S )Nr   c                   @   rO   )z)ProtocolTests.test_init_called.<locals>.PNrQ   rB   rB   rB   rC   r"    r   r"  c                   @   r&  )z)ProtocolTests.test_init_called.<locals>.Cc                 S   
   d| _ d S r  testr]   rB   rB   rC   ri    rj  z2ProtocolTests.test_init_called.<locals>.C.__init__Nr  rB   rB   rB   rC   r     r(  r   r  c                   @   r&  )z)ProtocolTests.test_init_called.<locals>.Bc                 S   r  r  r  r]   rB   rB   rC   ri    rj  z2ProtocolTests.test_init_called.<locals>.B.__init__Nr  rB   rB   rB   rC   r    r(  r  c                   @   rO   )z*ProtocolTests.test_init_called.<locals>.D1NrQ   rB   rB   rB   rC   r    rR   r  c                   @   rO   )z*ProtocolTests.test_init_called.<locals>.D2NrQ   rB   rB   rB   rC   r    rR   r  )r
   r   rd   rh   r  )r>   r   r"  r   r  r  r  rB   rB   rC   test_init_called  s   zProtocolTests.test_init_calledc                 C   s   t d}G dd dt| }G dd d|| }| |t  jd | t |t d W d    n1 s8w   Y  | t |t dd W d    d S 1 sUw   Y  d S )	Nr   c                   @   rO   )z(ProtocolTests.test_new_called.<locals>.PNrQ   rB   rB   rB   rC   r"    r   r"  c                          e Zd Z fddZ  ZS )z(ProtocolTests.test_new_called.<locals>.Cc                    s   t  j| g|R  }d|_|S r  )super__new__r  )r?   r   r>   r)  rB   rC   r    s   z0ProtocolTests.test_new_called.<locals>.C.__new__rL   rM   rN   r  __classcell__rB   rB   r  rC   r         r   r  rY   r  )r
   r   rd   rh   r  rZ   r[   r>   r   r"  r   rB   rB   rC   test_new_called  s   "zProtocolTests.test_new_calledc                 C   s$  t d}t d}| t G dd dt||f }W d    n1 s$w   Y  | t G dd dtt }W d    n1 sCw   Y  | t G dd dt| t| }W d    n1 sew   Y  | t G dd dtj||f t| }W d    d S 1 sw   Y  d S )Nr   r  c                   @   rO   z6ProtocolTests.test_protocols_bad_subscripts.<locals>.PNrQ   rB   rB   rB   rC   r"    r   r"  c                   @   rO   r  rQ   rB   rB   rB   rC   r"    r   c                   @   rO   r  rQ   rB   rB   rB   rC   r"    r   c                   @   rO   r  rQ   rB   rB   rB   rC   r"    r   )r
   rZ   r[   r   rh   rH   r   r>   r   r  r"  rB   rB   rC   test_protocols_bad_subscripts  s   ""z+ProtocolTests.test_protocols_bad_subscriptsc                 C   sd   t d}t d}G dd dt||f }| t|||f d | t|ttf d d S )Nr   r  c                   @   rO   )z4ProtocolTests.test_generic_protocols_repr.<locals>.PNrQ   rB   rB   rB   rC   r"    r   r"  z	P[~T, ~S]zP[int, str])r
   r   
assertTruere   endswithrh   r   r  rB   rB   rC   test_generic_protocols_repr	  s
    z)ProtocolTests.test_generic_protocols_reprc                 C   s   t d}t d}G dd dt||f }| || | |t|f |t|f  | |||f t||f  ttf |tttf tttf f  d S )Nr   r  c                   @   rO   )z2ProtocolTests.test_generic_protocols_eq.<locals>.PNrQ   rB   rB   rB   rC   r"    r   r"  )r
   r   rd   rh   r   r   r  rB   rB   rC   test_generic_protocols_eq  s   "z'ProtocolTests.test_generic_protocols_eqc                 C   sh   t d}G dd dt| }| |j|f | |t jd | |t jtf | |t j| d S )Nr   c                   @   rO   )zDProtocolTests.test_generic_protocols_special_from_generic.<locals>.PNrQ   rB   rB   rB   rC   r"     r   r"  rB   )r
   r   rd   r   rh   r   r   r   r>   r   r"  rB   rB   rC   +test_generic_protocols_special_from_generic  s   z9ProtocolTests.test_generic_protocols_special_from_genericc                 C   s   t G dd dt}G dd dt}td}G dd dt| }| |j | |j | |j | |j | |j | |t j | t	
|dh | t	
|d	h | tt	
|td	dh d S )
Nc                   @   r  )zFProtocolTests.test_generic_protocols_special_from_protocol.<locals>.PRr   Nr  rB   rB   rB   rC   r  (  r  r  c                   @   r&  )zEProtocolTests.test_generic_protocols_special_from_protocol.<locals>.Pc                 S   r   rG   rB   r]   rB   rB   rC   r  -  r   zJProtocolTests.test_generic_protocols_special_from_protocol.<locals>.P.methNr  rB   rB   rB   rC   r"  ,  r(  r"  r   c                   @   r  )zFProtocolTests.test_generic_protocols_special_from_protocol.<locals>.PGr   c                 S   r   rG   rB   r]   rB   rB   rC   r  5  r   zKProtocolTests.test_generic_protocols_special_from_protocol.<locals>.PG.methN)rL   rM   rN   r   r  rB   rB   rB   rC   r  2  r  r  r  r   )r   r   r
   r  Z_is_protocolr   Z_is_runtime_protocolrh   rd   rH   Z_get_protocol_attrs	frozenset)r>   r  r"  r   r  rB   rB   rC   ,test_generic_protocols_special_from_protocol'  s    
z:ProtocolTests.test_generic_protocols_special_from_protocolc                 C   s   |  t tG dd d}W d    n1 sw   Y  G dd dt}|  t tG dd d|}W d    d S 1 sAw   Y  d S )Nc                   @   rO   )z8ProtocolTests.test_no_runtime_deco_on_nominal.<locals>.CNrQ   rB   rB   rB   rC   r   E  rR   r   c                   @   r  )z<ProtocolTests.test_no_runtime_deco_on_nominal.<locals>.Protor   Nr  rB   rB   rB   rC   r~  H  r  r~  c                   @   rO   )z?ProtocolTests.test_no_runtime_deco_on_nominal.<locals>.ConcreteNrQ   rB   rB   rB   rC   r  L  r}  r  )rZ   r[   r   r   )r>   r   r~  r  rB   rB   rC   test_no_runtime_deco_on_nominalC  s   "z-ProtocolTests.test_no_runtime_deco_on_nominalc                 C   s   t G dd dt}G dd dt}| | | G dd d}G dd d}| | | | | | G d	d
 d
}G dd d}| | | | | | d S )Nc                   @   r  )z4ProtocolTests.test_none_treated_correctly.<locals>.PNr  rB   rB   rB   rC   r"  Q  r  r"  c                   @   rO   )z4ProtocolTests.test_none_treated_correctly.<locals>.BNrQ   rB   rB   rB   rC   r  U  r   r  c                   @   r  )z4ProtocolTests.test_none_treated_correctly.<locals>.Cr   Nr  rB   rB   rB   rC   r   Y  r  r   c                   @   r  )z4ProtocolTests.test_none_treated_correctly.<locals>.DNr  rB   rB   rB   rC   r  \  r  r  c                   @   r&  )z5ProtocolTests.test_none_treated_correctly.<locals>.CIc                 S   r  rH  r   r]   rB   rB   rC   ri  c  rj  z>ProtocolTests.test_none_treated_correctly.<locals>.CI.__init__Nr  rB   rB   rB   rC   r  b  r(  r  c                   @   r&  )z5ProtocolTests.test_none_treated_correctly.<locals>.DIc                 S   r  rG   r   r]   rB   rB   rC   ri  g  rj  z>ProtocolTests.test_none_treated_correctly.<locals>.DI.__init__Nr  rB   rB   rB   rC   DIf  r(  r'  )r   r   r   r   r   )r>   r"  r  r   r  r  r'  rB   rB   rC   test_none_treated_correctlyP  s   z)ProtocolTests.test_none_treated_correctlyc                 C   s@   G dd dt }tjtj|f }tj|tjf }| || d S )Nc                   @   r  )z1ProtocolTests.test_protocols_in_unions.<locals>.PNr  rB   rB   rB   rC   r"  n  r  r"  )r   rH   r   r   rd   )r>   r"  AliasZAlias2rB   rB   rC   test_protocols_in_unionsm  s   z&ProtocolTests.test_protocols_in_unionsc           	      C   s   t d}tG dd dt| aG dd dtt at }d|_d|_tt	j
d D ]E}t	||}t	|}| |jd | |jd | |jd | |jddd	 t	t|}t	|}G d
d d}| | | q*d S )Nr   c                   @   r  )r"  r   Nr  rB   rB   rB   rC   r"  y  r  r"  c                   @   rO   )CPNrQ   rB   rB   rB   rC   r+  }  rR   r+  rY   r	  r   rC  c                   @   r  )z2ProtocolTests.test_protocols_pickleable.<locals>.Er   Nr  rB   rB   rB   rC   r    r  r  )r
   r   r   r"  rh   r+  r  rB  r  r  r  r  r  rd   r   __dict__r   )	r>   r   r   r  r<  r   r  r  r  rB   rB   rC   test_protocols_pickleableu  s&   

z'ProtocolTests.test_protocols_pickleablec                 C       |  ttj | ttj d S rG   )rD   rh   rH   SupportsIntrF   r   r]   rB   rB   rC   test_supports_int     zProtocolTests.test_supports_intc                 C   r.  rG   )rD   r   rH   ZSupportsFloatrF   r   r]   rB   rB   rC   test_supports_float  r1  z!ProtocolTests.test_supports_floatc                 C   .   G dd d}|  |tj | ttj d S )Nc                   @   r&  )z.ProtocolTests.test_supports_complex.<locals>.Cc                 S   r  )Ny                rB   r]   rB   rB   rC   __complex__  r   z:ProtocolTests.test_supports_complex.<locals>.C.__complex__N)rL   rM   rN   r4  rB   rB   rB   rC   r     r(  r   )rD   rH   SupportsComplexrF   r   r   rB   rB   rC   test_supports_complex     z#ProtocolTests.test_supports_complexc                 C   r3  )Nc                   @   r&  )z,ProtocolTests.test_supports_bytes.<locals>.Bc                 S   r  N    rB   r]   rB   rB   rC   	__bytes__  r   z6ProtocolTests.test_supports_bytes.<locals>.B.__bytes__N)rL   rM   rN   r:  rB   rB   rB   rC   r    r(  r  )rD   rH   SupportsBytesrF   r   )r>   r  rB   rB   rC   test_supports_bytes  r7  z!ProtocolTests.test_supports_bytesc                 C   s.   |  ttj |  ttj | ttj d S rG   )rD   r   rH   SupportsAbsrh   rF   r   r]   rB   rB   rC   test_supports_abs  s   zProtocolTests.test_supports_absc                 C   s:   t ttj | ttj | ttj | ttj d S rG   )r<   r   rH   ZSupportsRoundrD   rh   rF   r   r]   rB   rB   rC   test_supports_round  s   z!ProtocolTests.test_supports_roundc                 C   r.  rG   )rD   r   rH   
ReversiblerF   rh   r]   rB   rB   rC   test_reversible  r1  zProtocolTests.test_reversiblec                 C   r.  rG   )rD   rh   rH   ZSupportsIndexrF   r   r]   rB   rB   rC   test_supports_index  r1  z!ProtocolTests.test_supports_indexc                 C   sF   |  dtj G dd dtj}G dd d|}| }|  || d S )Nr   c                   @   r  )z>ProtocolTests.test_bundled_protocol_instance_works.<locals>.C1r   c                 S   r  rX   rB   r]   rB   rB   rC   __int__  r   zFProtocolTests.test_bundled_protocol_instance_works.<locals>.C1.__int__N)rL   rM   rN   rh   rC  rB   rB   rB   rC   r    r  r  c                   @   rO   )z>ProtocolTests.test_bundled_protocol_instance_works.<locals>.C2NrQ   rB   rB   rB   rC   r    rR   r  )r   rH   r=  r/  )r>   r  r  r   rB   rB   rC   $test_bundled_protocol_instance_works  s
   z2ProtocolTests.test_bundled_protocol_instance_worksc                 C   sR   t G dd dtjjt}G dd d}G dd d}| || | || d S )Nc                   @   r&  )z@ProtocolTests.test_collections_protocols_allowed.<locals>.Customc                 S   r   rG   rB   r]   rB   rB   rC   close  r   zFProtocolTests.test_collections_protocols_allowed.<locals>.Custom.closeN)rL   rM   rN   rE  rB   rB   rB   rC   Custom  r  rF  c                   @   rO   )z;ProtocolTests.test_collections_protocols_allowed.<locals>.ANrQ   rB   rB   rB   rC   rl     r   rl   c                   @   r  )z;ProtocolTests.test_collections_protocols_allowed.<locals>.Bc                 S   r  rG   rB   r]   rB   rB   rC   __iter__  r   zDProtocolTests.test_collections_protocols_allowed.<locals>.B.__iter__c                 S   r  r  rB   r]   rB   rB   rC   rE    r   zAProtocolTests.test_collections_protocols_allowed.<locals>.B.closeN)rL   rM   rN   rG  rE  rB   rB   rB   rC   r    s    r  )r   r  r	  r   r   rD   rF   )r>   rF  rl   r  rB   rB   rC   "test_collections_protocols_allowed  s   z0ProtocolTests.test_collections_protocols_allowedc                 C   sT   |  t G dd dtt}W d    n1 sw   Y  G dd dtjt}d S )Nc                   @   rO   )zEProtocolTests.test_builtin_protocol_allowlist.<locals>.CustomProtocolNrQ   rB   rB   rB   rC   CustomProtocol  rR   rI  c                   @   rO   )zKProtocolTests.test_builtin_protocol_allowlist.<locals>.CustomContextManagerNrQ   rB   rB   rB   rC   CustomContextManager  rR   rJ  )rZ   r[   r   r   rH   ContextManager)r>   rI  rJ  rB   rB   rC   test_builtin_protocol_allowlist  s   z-ProtocolTests.test_builtin_protocol_allowlistc                 C   sL   G dd dt }| td td| W d    d S 1 sw   Y  d S )Nc                   @   rr  )zCProtocolTests.test_non_runtime_protocol_isinstance_check.<locals>.Pr   Nro  rB   rB   rB   rC   r"    rz  r"  z@runtime_checkabler   )r   r#  r[   r\   r>   r"  rB   rB   rC   *test_non_runtime_protocol_isinstance_check  s   "z8ProtocolTests.test_non_runtime_protocol_isinstance_checkc                 C   s*   G dd dt }G dd d|}|  d S )Nc                   @   rr  )z-ProtocolTests.test_super_call_init.<locals>.Pr   Nro  rB   rB   rB   rC   r"    rz  r"  c                       r  )z/ProtocolTests.test_super_call_init.<locals>.Fooc                    s   t    d S rG   )r  ri  r]   r  rB   rC   ri    rk  z8ProtocolTests.test_super_call_init.<locals>.Foo.__init__rL   rM   rN   ri  r  rB   rB   r  rC   rK    r  rK  )r   )r>   r"  rK  rB   rB   rC   test_super_call_init  s   
z"ProtocolTests.test_super_call_initN)3rL   rM   rN   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r!  r#  r%  r&  r(  r*  r-  r0  r2  r6  r<  r>  r?  rA  rB  rD  rH  rL  rN  rP  rB   rB   rB   rC   r  |  sb     #%G%
#	



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%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWdX Z.dYdZ Z/d[d\ Z0d]d^ Z1d_d` Z2dadb Z3dcdd Z4dedf Z5dgdh Z6diS )jGenericTestsc                 C   sR  t ttf }| |jd | t |t  W d    n1 s!w   Y  | t |ttf  W d    n1 s<w   Y  t ttf }| |jtf |t  | t |ttf  W d    n1 siw   Y  t ttf }| t t	|t  W d    n1 sw   Y  | 
| t  td}| tt| tB  j|f d S )NrB   r   )r\  r   r   rd   r   rZ   r[   rZ  rh   r<   r   r
   r   r   r   )r>   r   r   ZSM1r   rB   rB   rC   r     s*   
 zGenericTests.test_basicsc                 C   s  t d}t d}| t t| |  W d    n1 sw   Y  | t t| |  W d    n1 s9w   Y  | t G dd dt| t| }W d    n1 s[w   Y  | t tg tt  W d    n1 sww   Y  | t tttt  W d    n1 sw   Y  | t G dd dt}W d    n1 sw   Y  | t G dd dt| t| }W d    n1 sw   Y  | t G d	d dt| t| }W d    d S 1 sw   Y  d S )
Nr   r  c                   @   rO   )z+GenericTests.test_generic_errors.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   c                   @   rO   )z4GenericTests.test_generic_errors.<locals>.NewGenericNrQ   rB   rB   rB   rC   
NewGeneric  r   rR  c                   @   rO   z3GenericTests.test_generic_errors.<locals>.MyGenericNrQ   rB   rB   rB   rC   	MyGeneric  r   rT  c                   @   rO   rS  rQ   rB   rB   rB   rC   rT    r   )	r
   rZ   r[   r   r\   r   rh   r<   r   )r>   r   r  r   rR  rT  rB   rB   rC   test_generic_errors	  s4   "z GenericTests.test_generic_errorsc                 C   s   t d}t d}| t t||f  W d    n1 sw   Y  | t t|||f  W d    d S 1 s;w   Y  d S )Nr   r  )r
   rZ   r[   r   )r>   r   r  rB   rB   rC   	test_init  s   "zGenericTests.test_initc                 C   s   G dd dt jt }G dd d|}| |jd | t |j W d    n1 s-w   Y  d|_d|_G dd	 d	|}G d
d d|t }| |jd | |jd | |jd d S )Nc                       r  )z*GenericTests.test_init_subclass.<locals>.Xc                    s   t  jdi | d| _d S )NrY   rB   )r  __init_subclass__r  )r?   kwargsr  rB   rC   rW  '  s   
z<GenericTests.test_init_subclass.<locals>.X.__init_subclass__rL   rM   rN   rW  r  rB   rB   r  rC   r   &  r  r   c                   @   rO   )z*GenericTests.test_init_subclass.<locals>.YNrQ   rB   rB   rB   rC   r   *  rR   r   rY   r   r9  c                   @   rO   )z*GenericTests.test_init_subclass.<locals>.ZNrQ   rB   rB   rB   rC   Z1  rR   rZ  c                   @   rO   )z*GenericTests.test_init_subclass.<locals>.WNrQ   rB   rB   rB   rC   W3  rR   r[  )rH   r   r   rd   r  rZ   AttributeErrorrh   )r>   r   r   rZ  r[  rB   rB   rC   test_init_subclass%  s   zGenericTests.test_init_subclassc                 C   s4   |  ttdt d |  ttdt d d S )Nz<class 'z.SimpleMapping'>z.MySimpleMapping'>)rd   re   r\  rL   rf  r]   rB   rB   rC   rf   9  s   



zGenericTests.test_reprc                 C   s   t d}t d}G dd dt| }|t||f  }| ||t||f   | ||t||f   ||tf }| |||tf  | |||tf  | |||tf  |t }| ||t  | ||t  | |||  | t|d d S )Nr   r  c                   @   rO   )z'GenericTests.test_chain_repr.<locals>.CNrQ   rB   rB   rB   rC   r   C  rR   r   z.C[typing.Tuple[str, int]])	r
   r   r   rd   r   rh   r   r  r  )r>   r   r  r   r   r   rZ  rB   rB   rC   test_chain_repr?  s"   
zGenericTests.test_chain_reprc                 C   s   t d}t ddd}t d}| ttd | tt| d | tt| d | tt| | t d	 | ttt d	 d S )
Nr   UTr   r  ztyping.Listztyping.List[~T]ztyping.List[+U]ztyping.List[int])r
   rd   re   r   rh   )r>   r   r_  r  rB   rB   rC   test_new_reprW  s   zGenericTests.test_new_reprc                 C   s~   t d}t d}| ttj||f ||f d | ttt||f  t|f d | ttt||f  tt  d d S )Nr   TSztyping.Mapping[~TS, ~T]z"typing.List[typing.Tuple[int, ~T]]z=typing.List[typing.Tuple[typing.List[int], typing.List[int]]])r
   rd   re   rH   r   r   r   rh   )r>   r   ra  rB   rB   rC   test_new_repr_complexb  s   "z"GenericTests.test_new_repr_complexc                 C   sZ   t d}| tt| d | ttj| d G dd dtjttf }t|j d S )Nr   ztyping.Generic[~T]ztyping.Protocol[~T]c                   @   rO   )z*GenericTests.test_new_repr_bare.<locals>.CNrQ   rB   rB   rB   rC   r   r  r   r   )	r
   rd   re   r   rH   r   r   r   __mro__r>   r   r   rB   rB   rC   test_new_repr_baren  s
   zGenericTests.test_new_repr_barec                 C   sp   t d}G dd dt| }| }d|_| |jddi G dd d|t }| }d|_| |jd	di d S )
Nr   c                   @   rO   )z!GenericTests.test_dict.<locals>.BNrQ   rB   rB   rB   rC   r  y  rR   r  rY   r  c                   @   rO   )z!GenericTests.test_dict.<locals>.CNrQ   rB   rB   rB   rC   r     rR   r   r	  rB  )r
   r   r  rd   r,  rh   rB  )r>   r   r  br   r   rB   rB   rC   	test_dictv  s   zGenericTests.test_dictc                 C   sT  t d}G dd dt| }| |t jd | ||t  jd d||t  _| |jd | |t jd d|tt  _| |jd | |tt  jd | | jd | |tt   jd G dd d|| }| |t jd | |jd d	|_d
|t _| |jd | |t jd | |jd
 | |t jd	 d S )Nr   c                   @   r  )z<GenericTests.test_subscripted_generics_as_proxies.<locals>.CdefNr  rB   rB   rB   rC   r     r  r   rh  changednewc                   @   rO   )z<GenericTests.test_subscripted_generics_as_proxies.<locals>.DNrQ   rB   rB   rB   rC   r    rR   r  zfrom derived zzfrom derived x)	r
   r   rd   rh   r   r   r   r<  r   r>   r   r   r  rB   rB   rC   $test_subscripted_generics_as_proxies  s*   
z1GenericTests.test_subscripted_generics_as_proxiesc                 C   s`   t d}G dd dtjjt| }|t | d| |t  | d| |  |	  d S )Nr   c                   @   rO   )z.GenericTests.test_abc_registry_kept.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   r   )
r
   r  r	  r   r   r  rh   r   _abc_registry_clear_abc_caches_clearrd  rB   rB   rC   test_abc_registry_kept  s   
z#GenericTests.test_abc_registry_keptc                 C   s4   G dd dt ttf }| i | | t| d S )Nc                   @   rO   )z5GenericTests.test_false_subclasses.<locals>.MyMappingNrQ   rB   rB   rB   rC   	MyMapping  r   rp  )r   r   r   rF   r   )r>   rp  rB   rB   rC   test_false_subclasses  s   z"GenericTests.test_false_subclassesc                 C   s`   G dd dt ttf }|   | | tjj  | | t  | | t | i | d S )Nc                   @   4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )z'GenericTests.test_abc_bases.<locals>.MMc                 S   r   rG   rB   r>   krB   rB   rC   r_    r   z3GenericTests.test_abc_bases.<locals>.MM.__getitem__c                 S   r   rG   rB   r>   rt  r   rB   rB   rC   rb    r   z3GenericTests.test_abc_bases.<locals>.MM.__setitem__c                 S   r   rG   rB   rs  rB   rB   rC   __delitem__  r   z3GenericTests.test_abc_bases.<locals>.MM.__delitem__c                 S      t dS r   iterr]   rB   rB   rC   rG    r   z0GenericTests.test_abc_bases.<locals>.MM.__iter__c                 S   r  r  rB   r]   rB   rB   rC   __len__  r   z/GenericTests.test_abc_bases.<locals>.MM.__len__NrL   rM   rN   r_  rb  rv  rG  rz  rB   rB   rB   rC   MM      r|  )r   r   updater   r  r	  r   r   )r>   r|  rB   rB   rC   test_abc_bases  s   
zGenericTests.test_abc_basesc                 C   sV   G dd dt ttf tjj }G dd dtjj t ttf }| |jtjj tf d S )Nc                   @   rO   )z-GenericTests.test_multiple_bases.<locals>.MM1NrQ   rB   rB   rB   rC   MM1  rR   r  c                   @   rO   )z-GenericTests.test_multiple_bases.<locals>.MM2NrQ   rB   rB   rB   rC   MM2  rR   r  )r   r   r  r	  rd   	__bases__r   )r>   r  r  rB   rB   rC   test_multiple_bases  s   z GenericTests.test_multiple_basesc                 C   s@   t d}G dd dtjt|f }| |jtjt|f f d S )Nr   c                   @   rO   )z'GenericTests.test_orig_bases.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   )r
   rH   r   r   rd   __orig_bases__rd  rB   rB   rC   test_orig_bases  s   zGenericTests.test_orig_basesc                 C   sp  dd }|  |dditjttf  | |dditjttf  | t |dditjttf  W d    n1 s>w   Y  dd }G dd dt	t }|  ||t  |t  | ||t  |t  | ||t  t
 | t |g d	|t  W d    n1 sw   Y  d
d }G dd dt
t }|  |g d	| | |ddg| d S )Nc                    sB   t |jdkr	t|jr|j\ t fdd|  D S d S )Nr   c                 3   s(    | ]\}}t | ot |V  qd S rG   )r\   .0rt  r   r   r   rB   rC   	<genexpr>  s
    
zSGenericTests.test_naive_runtime_checks.<locals>.naive_dict_check.<locals>.<genexpr>)r   r   r  r   allitemsr  tprB   r  rC   naive_dict_check  s   
z@GenericTests.test_naive_runtime_checks.<locals>.naive_dict_checkr   r   c                 S   s   t | dst| j|kS )Nr*  )hasattrr  r*  r  rB   rB   rC   naive_generic_check  s   

zCGenericTests.test_naive_runtime_checks.<locals>.naive_generic_checkc                   @   rO   )z4GenericTests.test_naive_runtime_checks.<locals>.NodeNrQ   rB   rB   rB   rC   Node  r   r  r8  c                    s   t  fdd| D S )Nc                 3   s&    | ]}t | jd  jd  V  qdS )r   N)r\   r  r   )r  r   r  rB   rC   r    s    zXGenericTests.test_naive_runtime_checks.<locals>.naive_list_base_check.<locals>.<genexpr>)r  r  rB   r  rC   naive_list_base_check  s   zEGenericTests.test_naive_runtime_checks.<locals>.naive_list_base_checkc                   @   rO   )z1GenericTests.test_naive_runtime_checks.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   r   rf  )r  rH   r   r   rh   r   rZ   r  r   r   r   )r>   r  r  r  r  r   rB   rB   rC   test_naive_runtime_checks  s$   
z&GenericTests.test_naive_runtime_checksc                 C   s"  t d}t d}t d}G dd dt| | | }G dd d|t| | | }| |j|f | |j|f | |t jd | |t jd | |t jtf | |t jtf | |jttf | |j|ttf | |j	t| | | f | |j	|t| | | f d S )	Nr   r_  r   c                   @   rO   )z.GenericTests.test_multi_subscr_base.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   c                   @   rO   )z.GenericTests.test_multi_subscr_base.<locals>.DNrQ   rB   rB   rB   rC   r    r   r  rB   )
r
   r   rd   r   rh   r   r  r   r   r  )r>   r   r_  r   r   r  rB   rB   rC   test_multi_subscr_base  s   "z#GenericTests.test_multi_subscr_basec                 C   sj   t d}G dd dt}| t| t|  | t|tf | t|tf  | td|f jt|f d S )Nr   c                   @   rO   )z.GenericTests.test_subscript_meta.<locals>.MetaNrQ   rB   rB   rB   rC   Meta  r   r  .)	r
   rn   rd   r%   r   rh   r   r   Ellipsis)r>   r   r  rB   rB   rC   test_subscript_meta  s
    z GenericTests.test_subscript_metac                 C   s  G dd dt t }G dd dt t }| || | tjt tjt  | |j|j | tjj|jt  tjj|jt   | ||j | |tj | |tjj | |jtj | |jtjj | |t |jt  | |tt	  |jtt	   | |t tjt  | |t tjjt  | |jt
 tjt
  | |jtt	  tjjtt	   | t|t  t|jt   | t|tt	   t|jtt	    | tt|t f tttjt f  | t|t |t f t|t tjt f  | tj|t  tjtjjt   tjd d dkr]| tt|t  d | tt|jt  d | tttjt  d	 | tttjjt  d
 d S d S )Nc                   @   rO   )z+GenericTests.test_generic_hashes.<locals>.ANrQ   rB   rB   rB   rC   rl     rR   rl   c                   @   s    e Zd ZG dd dee ZdS )z+GenericTests.test_generic_hashes.<locals>.Bc                   @   rO   )z-GenericTests.test_generic_hashes.<locals>.B.ANrQ   rB   rB   rB   rC   rl     rR   rl   N)rL   rM   rN   r   r   rl   rB   rB   rB   rC   r    s    r  r9  )r:  r9  z<locals>.A[str]]z<locals>.B.A[str]]zmod_generics_cache.A[str]]zmod_generics_cache.B.A[str]])r   r   rd   r7   rl   r   r  r   r   r   rh   r   r   rH   	FrozenSetsysversion_infor  re   r  r>   rl   r  rB   rB   rC   test_generic_hashes  sL   "&&z GenericTests.test_generic_hashesc                 C   s  t d}t d}| t||f t tttf  | tjt||f  | tjt||f   | t t|tf d  W d    n1 sFw   Y  | t|tf t t | t||f tttt	f f ttt	f  G dd d}G dd d|}| t||f t||f  t||f  | t t|tf d  W d    n1 sw   Y  | t
|g|f t t
tgtf  | t
d	t| f t t
d	tt f  d S )
Nr   r_  rB   c                   @   rO   )z9GenericTests.test_extended_generic_rules_eq.<locals>.BaseNrQ   rB   rB   rB   rC   BaseA  r   r  c                   @   rO   )z<GenericTests.test_extended_generic_rules_eq.<locals>.DerivedNrQ   rB   rB   rB   rC   DerivedB  r   r  r   .)r
   rd   r   rh   rH   r   rZ   r[   r   r   r   r   r   )r>   r   r_  r  r  rB   rB   rC   test_extended_generic_rules_eq7  s"    ,,($,z+GenericTests.test_extended_generic_rules_eqc                 C   s   t d}| ttttf ddd | ttttt f ddd | ttdt| f t ddd | ttg t	| f t ddd d S )	Nr   ztyping. zUnion[Tuple, Callable]zUnion[Tuple, Tuple[int]].zCallable[..., Optional[int]]zCallable[[], List[int]])
r
   rd   re   r   r   r   replacerh   r   r   r   rB   rB   rC    test_extended_generic_rules_reprJ  s   ""z-GenericTests.test_extended_generic_rules_reprc           
      C   sD  dt t d  fdd}dtttd  fdd}dttd tB fdd	}G d
d d}| t|t t dt t |  i | t|t t dtt|  i | t|t t dt|tB  tB i td}t	|df }d|fdd}| 
t|t t d | tdt | f }d|fdd}	| 
t|	t t d | d S )Nr   CCc                 S   r   rG   rB   r   rB   rB   rC   foobarV  r   z5GenericTests.test_generic_forward_ref.<locals>.foobarc                 S   r   rG   rB   r   rB   rB   rC   foobar2W  r   z6GenericTests.test_generic_forward_ref.<locals>.foobar2zCC | intc                 S   r   rG   rB   r   rB   rB   rC   foobar3X  r   z6GenericTests.test_generic_forward_ref.<locals>.foobar3c                   @   rO   )z1GenericTests.test_generic_forward_ref.<locals>.CCNrQ   rB   rB   rB   rC   r  Y  r   r   .c                 S   r   rG   rB   r   rB   rB   rC   barfooi  r   z5GenericTests.test_generic_forward_ref.<locals>.barfooc                 S   r   rG   rB   r   rB   rB   rC   barfoo2l  r   z6GenericTests.test_generic_forward_ref.<locals>.barfoo2)r   r   r0   rh   rd   r   r  r  r
   r   r   r   )
r>   r  r  r  r  r   ATr  ZCTr  rB   rB   rC   test_generic_forward_refU  s.    z%GenericTests.test_generic_forward_refc                 C   s  G dd dt ttf }G dd dt tdf }G dd dtjt }| |jttf | |ttf j	ttf | |ttf j
| | |jtf | t|t dd	 d
 | |jtf | | tjj | |tjj | | t | |t | t tt tdf tj W d    n1 sw   Y  | t tt tdf tj W d    d S 1 sw   Y  d S )Nc                   @   rO   )z@GenericTests.test_extended_generic_rules_subclassing.<locals>.T1NrQ   rB   rB   rB   rC   T1p  r   r  c                   @   rO   )z@GenericTests.test_extended_generic_rules_subclassing.<locals>.T2NrQ   rB   rB   rB   rC   T2q  r   r  .c                   @   r&  )z@GenericTests.test_extended_generic_rules_subclassing.<locals>.C1c                 S   r  )NFrB   )r>   itemrB   rB   rC   __contains__s  r   zMGenericTests.test_extended_generic_rules_subclassing.<locals>.C1.__contains__N)rL   rM   rN   r  rB   rB   rB   rC   r  r  r(  r  .zC1[int])r   r   r   rH   	Containerrd   r   rh   r   r   r   re   splitr   r  r	  rD   r   rZ   r[   r<   Sequencer   )r>   r  r  r  rB   rB   rC   'test_extended_generic_rules_subclassingo  s&   "z4GenericTests.test_extended_generic_rules_subclassingc                 C   s   |  t tt  W d    n1 sw   Y  |  t tt  W d    n1 s-w   Y  |  t tt  W d    n1 sFw   Y  |  t ttt   W d    d S 1 sbw   Y  d S rG   )rZ   r[   r   r   r   r   r   rh   r]   rB   rB   rC   test_fail_with_bare_union  s   


"z&GenericTests.test_fail_with_bare_unionc                 C   s   t d}| t tt  W d    n1 sw   Y  | t tt|   W d    n1 s3w   Y  | t ttj  W d    d S 1 sNw   Y  d S r   )r
   rZ   r[   r   r   r   rH   r   r   rB   rB   rC   test_fail_with_bare_generic  s   
"z(GenericTests.test_fail_with_bare_genericc                 C   s8  t d}|   G dd dt||f }| |t  j| | |t  j|t  G dd dtj	||f }| |t  j| | |t  j|t  G dd dtj
t|f }| |t  j| | |t  j|t  tjdkrG d	d
 d
tjt|f }| |t  j| | |t  j|t  d S d S )Nr   c                   @   rO   )z5GenericTests.test_type_erasure_special.<locals>.MyTupNrQ   rB   rB   rB   rC   MyTup  r   r  c                   @   rO   )z6GenericTests.test_type_erasure_special.<locals>.MyDictNrQ   rB   rB   rB   rC   MyDict  r   r  c                   @   rO   )z5GenericTests.test_type_erasure_special.<locals>.MyDefNrQ   rB   rB   rB   rC   MyDef  r   r  r:  r:  c                   @   rO   )z7GenericTests.test_type_erasure_special.<locals>.MyChainNrQ   rB   rB   rB   rC   MyChain  r   r  )r
   rK   r   r   rh   r)  rd   r*  rH   r   DefaultDictr   r  r  ChainMap)r>   r   r  r  r  r  rB   rB   rC   test_type_erasure_special  s    
z&GenericTests.test_type_erasure_specialc                 C   s   dd t jD }|D ]@}| t|d | || t|dd r1t|jdkr1| |t j	tf t
|trJ|jD ]}| t|d | || q9q
d S )Nc                 s   s    | ]}t t|V  qd S rG   )getattrrH   )r  elrB   rB   rC   r    s    z4GenericTests.test_all_repr_eq_any.<locals>.<genexpr>r  r   r   )rH   __all__r   re   rd   r  r   r   r   r   r\   rn   rc  )r>   Zobjsr  baserB   rB   rC   test_all_repr_eq_any  s   

z!GenericTests.test_all_repr_eq_anyc           
      C   s  t d}G dd dt| }G dd d|t at }d|_d|_ttjd D ]%}t	||}t
|}| |jd | |jd | |jddd	 q(ttttttttf tt ttd
f td ttgtf tjtjt g}|D ]}ttjd D ]}t	||}t
|}| || q|qsttjtjtt tjtj tjtttf  g}	|	D ]}ttjd D ]}t	||}t
|}| || qqd S )Nr   c                   @   rO   )z#GenericTests.test_pickle.<locals>.BNrQ   rB   rB   rB   rC   r    rR   r  c                   @   rO   )r   NrQ   rB   rB   rB   rC   r     rR   r   rY   r	  r   rC  .rB   )r
   r   rh   r   r  rB  r  r  r  r  r  rd   r,  r   r   r   r   r   r   r   r   rH   r  r  r   r%   r   AbstractSet)
r>   r   r  r   r  r<  r   r  r  Zmore_samplesrB   rB   rC   r    sB   

 

zGenericTests.test_picklec                 C   s  t d}G dd dt| }t|tf t|tf td td|f ttgtf tttf || |t |t tj| tjt tjt tj	tt
f tj	|tf tt tt|  td tdtf td tjdtf g}|tg D ]}| |t| | |t| qld S )Nr   c                   @   rO   )z1GenericTests.test_copy_and_deepcopy.<locals>.NodeNrQ   rB   rB   rB   rC   r    r   r  rB   .)r   r   )r
   r   r   rh   r   r   r   rH   r   r   r   r   r   r   rd   r   r   )r>   r   r  thingsr   rB   rB   rC   test_copy_and_deepcopy  s   $"z#GenericTests.test_copy_and_deepcopyc                 C   s   t dat dtdat dttatttttj	t
tjttttfD ]}| t|| | t|| | tt|| qt d}t dtd}t dtt}|||fD ]}| t|| | t|| qSd S )Nr   TPBr   TPVTLTLBTLV)r
   r   rh   r  r   r   r  r   rH   r   r   r   r   r   r   r   r   r   r   r  r  r  )r>   r   r  r  r  rB   rB   rC   $test_immutability_by_copy_and_pickle  s    z1GenericTests.test_immutability_by_copy_and_picklec                    s&  t d G  fdddt  }|d}| t|jd | t|jd | t|| | t|| d|_| t|jd | t|jd |t d}| t|jd | t|jd | t|| | t|| d|_| t|jd | t|jd | |j|t  d S )Nr   c                       s   e Zd Zd ddfddZdS )z3GenericTests.test_copy_generic_instances.<locals>.Cr  r   Nc                 S   r  rG   r  r  rB   rB   rC   ri  	  rj  z<GenericTests.test_copy_generic_instances.<locals>.C.__init__r  rB   r  rB   rC   r   	  r
  r   rY   r   )	r
   r   rd   r   r  r   assertIsNotrh   r*  )r>   r   r   ZcirB   r  rC   test_copy_generic_instances	  s&   z(GenericTests.test_copy_generic_instancesc              	   C   sv   t d}tt|tf td|f tttf ttt  tj	tt
f tjjt tjd g}|D ]}| t| | q,d S )Nr   .whatever)r
   r   r   rh   r   r   r   r   rH   r   r   rer.   r   r   rd   r  r  )r>   r   r  r   rB   rB   rC   test_weakref_all	  s    zGenericTests.test_weakref_allc                 C   s   t d}G dd dt| }| }|t  }d|_d|_| t d|_W d    n1 s/w   Y  | t d|_W d    n1 sGw   Y  d|d fdd}| t|t	 t
 d ||  | t|t t|t  d S )Nr   c                   @   r  )z0GenericTests.test_parameterized_slots.<locals>.C)potatoNrL   rM   rN   	__slots__rB   rB   rB   rC   r   %	  r  r   r   r   c                 S   r   rG   rB   r   rB   rB   rC   r  2	  r   z2GenericTests.test_parameterized_slots.<locals>.foo)r
   r   rh   r  rZ   r\  Ztomatord   r   r  r  r   r   )r>   r   r   r   Zc_intr  rB   rB   rC   test_parameterized_slots#	  s   
  z%GenericTests.test_parameterized_slotsc                 C   s   t d}G dd dt| }| }|t  }d|_d|_| t d|_W d    n1 s/w   Y  | t d|_W d    d S 1 sHw   Y  d S )Nr   c                   @   s   e Zd ZddiZdS )z5GenericTests.test_parameterized_slots_dict.<locals>.DbananarY   Nr  rB   rB   rB   rC   r  8	  r(  r  Zyesno)r
   r   rh   r  rZ   r\  r  )r>   r   r  dZd_intrB   rB   rC   test_parameterized_slots_dict6	  s   
"z*GenericTests.test_parameterized_slots_dictc                 C   sP   |  t tttf }G dd dt| }W d    d S 1 s!w   Y  d S )Nc                   @   rO   )z#GenericTests.test_errors.<locals>.CNrQ   rB   rB   rB   rC   r   I	  rR   r   )rZ   r[   r\  rZ  r   r   )r>   r  r   rB   rB   rC   ri   E	  s   "zGenericTests.test_errorsc                 C   s   G dd dt t }| |jt | |jd |t }| |jt | t|dd d G dd d|t }| |jt | |jd	 d S )
Nc                   @   rO   )#GenericTests.test_repr_2.<locals>.CNrQ   rB   rB   rB   rC   r   M	  rR   r   r  r  r  zC[int]c                   @   rO   )#GenericTests.test_repr_2.<locals>.YNrQ   rB   rB   rB   rC   r   W	  rR   r   r  )	r   r   rd   rM   rL   rN   rh   re   r  )r>   r   r   r   rB   rB   rC   test_repr_2L	  s   zGenericTests.test_repr_2c                 C   s8   |  tt |  tt tt  | tt tt  d S rG   )rd   r   r   r   r   r   r]   rB   rB   rC   	test_eq_1^	  s   zGenericTests.test_eq_1c                 C   sl   G dd dt t }G dd dt t }| || | || | |t |t  | |t |t  d S )Nc                   @   rO   )z!GenericTests.test_eq_2.<locals>.ANrQ   rB   rB   rB   rC   rl   e	  rR   rl   c                   @   rO   )z!GenericTests.test_eq_2.<locals>.BNrQ   rB   rB   rB   rC   r  h	  rR   r  )r   r   rd   r   r  rB   rB   rC   	test_eq_2c	  s   zGenericTests.test_eq_2c                 C   sv   G dd dt ttf }G dd dt ttf }G dd d|ttf t tttf |ttf }| |jtttf d S )Nc                   @   rO   )z1GenericTests.test_multiple_inheritance.<locals>.ANrQ   rB   rB   rB   rC   rl   r	  rR   rl   c                   @   rO   )z1GenericTests.test_multiple_inheritance.<locals>.BNrQ   rB   rB   rB   rC   r  u	  rR   r  c                   @   rO   )z1GenericTests.test_multiple_inheritance.<locals>.CNrQ   rB   rB   rB   rC   r   x	  rR   r   )r   r   r   r   rd   r   )r>   rl   r  r   rB   rB   rC   test_multiple_inheritancep	  s   .z&GenericTests.test_multiple_inheritancec                 C   sN   t d}G dd dt| }G dd dtt |}| |j|t|ttf d S )Nr  c                   @   rO   )z9GenericTests.test_multiple_inheritance_special.<locals>.BNrQ   rB   rB   rB   rC   r  	  r   r  c                   @   rO   )z9GenericTests.test_multiple_inheritance_special.<locals>.CNrQ   rB   rB   rB   rC   r   	  r   r   )r
   r   r   rh   rd   rc  r   r   )r>   r  r  r   rB   rB   rC   !test_multiple_inheritance_special}	  s   z.GenericTests.test_multiple_inheritance_specialc                    s   G dd dt G  fddd G dd dtt  }|  G dd d|}W d    n1 s5w   Y  |  G d	d d|t }W d    d S 1 sUw   Y  d S )
Nc                   @   rO   )zDGenericTests.test_init_subclass_super_called.<locals>.FinalExceptionNrQ   rB   rB   rB   rC   FinalException	  rR   r  c                       s"   e Zd Zd fddZ  ZS )z;GenericTests.test_init_subclass_super_called.<locals>.Finalr   Nc                    s<   | j D ]}| urt| r|qt jdi | d S r   )r  r<   r  rW  )r?   rX  r  )r   r  r)  rB   rC   rW  	  s
   
zMGenericTests.test_init_subclass_super_called.<locals>.Final.__init_subclass__)r   NrY  rB   r   r  r  rC   r   	  s    r   c                   @   rO   )z:GenericTests.test_init_subclass_super_called.<locals>.TestNrQ   rB   rB   rB   rC   r  	  rR   r  c                   @   rO   z>GenericTests.test_init_subclass_super_called.<locals>.SubclassNrQ   rB   rB   rB   rC   Subclass	  rR   r  c                   @   rO   r  rQ   rB   rB   rB   rC   r  	  rR   )	Exceptionr   r   rZ   rh   )r>   r  r  rB   r  rC   test_init_subclass_super_called	  s   "z,GenericTests.test_init_subclass_super_calledc                 C   sr   t }G dd d|t }|tjt  }G dd d|}| }|g  |d |d | | ddg d S )Nc                   @   s4   e Zd ZdZdefddZdd Zdefdd	ZdS )
z)GenericTests.test_nested.<locals>.VisitorNr   c                 S   r  rG   r  r>   r   rB   rB   rC   set	  rj  z-GenericTests.test_nested.<locals>.Visitor.setc                 S      | j S rG   r  r]   rB   rB   rC   re  	  r  z-GenericTests.test_nested.<locals>.Visitor.getr   c                 S   r  rG   r  r]   rB   rB   rC   visit	  r  z/GenericTests.test_nested.<locals>.Visitor.visit)rL   rM   rN   r   r   r  re  r  rB   rB   rB   rC   Visitor	  s
    r  c                   @   r  )z0GenericTests.test_nested.<locals>.IntListVisitorr   c                 S   s   | j | d S rG   )r   appendr  rB   rB   rC   r  	     z7GenericTests.test_nested.<locals>.IntListVisitor.appendN)rL   rM   rN   rh   r  rB   rB   rB   rC   IntListVisitor	      r  r   rY   )	r   r   rH   r   rh   r  r  rd   re  )r>   Gr  r   r  r   rB   rB   rC   test_nested	  s   


zGenericTests.test_nestedc                    sB   t dG fdddt  df fdd}|d d S )Nr   c                       s(   e Zd Z		dd ddddfddZdS )	z,GenericTests.test_type_erasure.<locals>.NodeNrt  leftNode[T]rightc                 S   r  rG   rt  r  r  )r>   rt  r  r  rB   rB   rC   ri  	  s   
z5GenericTests.test_type_erasure.<locals>.Node.__init__NNr  rB   r  rB   rC   r  	  s    r  r   c                    s~    | }  | } t  | }t|  t|  t|  |j|  |j|  |j|  d S rG   )r   r   rn   rd   rt  )r   r   rf  r   r  r   r>   rB   rC   r  	  s   z+GenericTests.test_type_erasure.<locals>.foorY   r
   r   r>   r  rB   r  rC   r+  	  s   zGenericTests.test_type_erasurec                 C   s   t d}G dd dt| }G dd d|}| |jd | t |t  W d    n1 s1w   Y  | t |t  W d    n1 sJw   Y  | t ||  W d    d S 1 sdw   Y  d S )Nr   c                   @   rO   )z)GenericTests.test_implicit_any.<locals>.CNrQ   rB   rB   rB   rC   r   	  rR   r   c                   @   rO   )z)GenericTests.test_implicit_any.<locals>.DNrQ   rB   rB   rB   rC   r  	  rR   r  rB   )r
   r   rd   r   rZ   r[   rh   r   rk  rB   rB   rC   test_implicit_any	  s   


"zGenericTests.test_implicit_anyc                 C   sN   G dd dt t }G dd d}G dd d||}|d}| |jd d S )Nc                   @   rO   )z*GenericTests.test_new_with_args.<locals>.ANrQ   rB   rB   rB   rC   rl   	  rR   rl   c                       r  )z*GenericTests.test_new_with_args.<locals>.Bc                    s   t  | }||_|S rG   )r  r  r   r?   r   r  r  rB   rC   r  	     z2GenericTests.test_new_with_args.<locals>.B.__new__r  rB   rB   r  rC   r  	  r  r  c                   @   rO   )z*GenericTests.test_new_with_args.<locals>.CNrQ   rB   rB   rB   rC   r   	  rR   r   r  )r   r   rd   r   r>   rl   r  r   r   rB   rB   rC   test_new_with_args	  s
   zGenericTests.test_new_with_argsc                 C   sL   G dd d}G dd dt t |}|d}| |jd | |jd d S )Nc                       r  )z+GenericTests.test_new_with_args2.<locals>.Ac                    s   || _ t   d S rG   )from_ar  ri  r  r  rB   rC   ri  	  s   z4GenericTests.test_new_with_args2.<locals>.A.__init__rO  rB   rB   r  rC   rl   	  r  rl   c                       r  )z+GenericTests.test_new_with_args2.<locals>.Cc                    s   || _ t | d S rG   )from_cr  ri  r  r  rB   rC   ri  	  s   z4GenericTests.test_new_with_args2.<locals>.C.__init__rO  rB   rB   r  rC   r   	  r  r   r  )r   r   rd   r   r  )r>   rl   r   r   rB   rB   rC   test_new_with_args2	  s
   z GenericTests.test_new_with_args2c                 C   s   G dd dt t }| t |d W d    n1 sw   Y  G dd d}G dd d||}|d}| |jd | |jd | |jd	 d S )
Nc                   @   rO   )z(GenericTests.test_new_no_args.<locals>.ANrQ   rB   rB   rB   rC   rl   
  rR   rl   r  c                       r  )z(GenericTests.test_new_no_args.<locals>.Bc                    s   t  | }d|_|S )Nrf  )r  r  from_b)r?   r  r  rB   rC   r  
  r  z0GenericTests.test_new_no_args.<locals>.B.__new__r  rB   rB   r  rC   r  
  r  r  c                       s$   e Zd Zdd Z fddZ  ZS )z(GenericTests.test_new_no_args.<locals>.Cc                 S   r  rG   r   r  rB   rB   rC   ri  
  rj  z1GenericTests.test_new_no_args.<locals>.C.__init__c                    s   t  | }d|_|S )Nr   )r  r  r  r  r  rB   rC   r  
  r  z0GenericTests.test_new_no_args.<locals>.C.__new__)rL   rM   rN   ri  r  r  rB   rB   r  rC   r   
  s    r   rf  r   )r   r   rZ   r[   rd   r   r  r  r  rB   rB   rC   test_new_no_args
  s   

zGenericTests.test_new_no_argsc              
   C   s   t t tt tttf tt td tttdf t	t fD ]@}| j
|d0 | tdtd| d G dd d|}W d    n1 sIw   Y  W d    n1 sXw   Y  qd S )	Nr>  r"  )r@   ^zCannot subclass $c                   @   rO   )z4GenericTests.test_subclass_special_form.<locals>.FooNrQ   rB   rB   rB   rC   rK  1
  rR   rK  )r   rh   r   r   r   r   r   r3   r2   r6   r   r#  r[   r  escape)r>   r  rK  rB   rB   rC   test_subclass_special_form#
  s$   
	z'GenericTests.test_subclass_special_formc                 C   sB   t ddd}G dd dt| }t d}G dd d|t| }d S )	Nr   Tr   c                   @   rO   )z2GenericTests.test_complex_subclasses.<locals>.BaseNrQ   rB   rB   rB   rC   r  7
  rR   r  r   c                   @   rO   )z1GenericTests.test_complex_subclasses.<locals>.SubNrQ   rB   rB   rB   rC   Sub=
  rR   r	  r  )r>   r   r  r   r	  rB   rB   rC   test_complex_subclasses4
  s   z$GenericTests.test_complex_subclassesc                 C   s   |  tt jtf |  ttt  jtf G dd d}ttfD ]A}ttttj	tj
fD ]5}| j||d$ | td || t  W d    n1 sMw   Y  W d    n1 s\w   Y  q,q!|  t|  jtf d S )Nc                   @   s   e Zd ZefZdS )z0GenericTests.test_parameter_detection.<locals>.AN)rL   rM   rN   r   r   rB   rB   rB   rC   rl   C
  r  rl   )Zgenericsubz0.* is not a generic class|no type variables left)rd   r   r   r   r   rh   r
   r2   r   r
  	UnionTyper   r#  r[   r   )r>   rl   r   rf  rB   rB   rC   test_parameter_detection@
  s    z%GenericTests.test_parameter_detectionc                 C   s  t d}G dd dt| }t|ttt ttjtjfD ]}t	t
fD ]V}| j||dE | |||f t ||tf  | |||f t |t|f  || }| t |t  W d    n1 sbw   Y  W d    n1 sqw   Y  q ttjjfD ]]}| j||dL | ||g|f t ||gtf  | ||g|f t |tg|f  ||g|f }| t |t  W d    n1 sw   Y  W d    n1 sw   Y  q}qd S )Nr   c                   @   rO   )z2GenericTests.test_non_generic_subscript.<locals>.GNrQ   rB   rB   rB   rC   r  S
  rR   r  )r   r  )callabler  )r
   r   rh   r   r   r2   r   r
  r  r   r   r   rd   rZ   r[   r   r  r	  )r>   r   r  r  r   r   r   rB   rB   rC   test_non_generic_subscriptQ
  s<     
$$
z'GenericTests.test_non_generic_subscriptN)7rL   rM   rN   r   rU  rV  r]  rf   r^  r`  rb  re  rg  rl  ro  rq  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  ri   r  r  r  r  r  r  r  r+  r  r  r  r  r  r
  r  r  rB   rB   rB   rC   rQ    sj    
$+
	$rQ  c                   @   rr  )ClassVarTestsc                 C   s   |  t td  W d    n1 sw   Y  |  t tttf  W d    n1 s/w   Y  |  t tt t  W d    d S 1 sKw   Y  d S rH  )rZ   r[   r   rh   r   r]   rB   rB   rC   r   m
     
"zClassVarTests.test_basicsc                 C   sH   |  ttd tt }|  t|d tt }|  t|dt  d S )Nztyping.ClassVartyping.ClassVar[int]ztyping.ClassVar[%s.Employee])rd   re   r   rh   rP   rL   r>   ZcvrB   rB   rC   rf   u
  s
   zClassVarTests.test_reprc                 C      |  t G dd dtt}W d    n1 sw   Y  |  t G dd dttt }W d    d S 1 s<w   Y  d S )Nc                   @   rO   z-ClassVarTests.test_cannot_subclass.<locals>.CNrQ   rB   rB   rB   rC   r   ~
  rR   r   c                   @   rO   r  rQ   rB   rB   rB   rC   r   
  rR   )rZ   r[   rn   r   rh   r   rB   rB   rC   rp   |
     "z"ClassVarTests.test_cannot_subclassc                 C      |  t t  W d    n1 sw   Y  |  t tt  W d    n1 s-w   Y  |  t tttt    W d    d S 1 sLw   Y  d S rG   )rZ   r[   r   rn   r   rh   r]   rB   rB   rC   rI  
     "zClassVarTests.test_cannot_initc                 C   r   |  t tdtt  W d    n1 sw   Y  |  t ttt W d    d S 1 s2w   Y  d S rH  )rZ   r[   r\   r   rh   r<   r]   rB   rB   rC   test_no_isinstance
     "z ClassVarTests.test_no_isinstanceNrL   rM   rN   r   rf   rp   rI  r  rB   rB   rB   rC   r  k
  s    r  c                   @   rv   )
FinalTestsc                 C   s   t t  | t t d  W d    n1 sw   Y  | t t ttf  W d    n1 s3w   Y  | t t t t  W d    n1 sNw   Y  | t tt t   W d    d S 1 sjw   Y  d S rH  )r   rh   rZ   r[   r   r   r]   rB   rB   rC   r   
  s   
"zFinalTests.test_basicsc                 C   d   |  ttd tt }|  t|d tt }|  t|dt  ttt  }|  t|d d S )Nztyping.Finalztyping.Final[int]ztyping.Final[%s.Employee]ztyping.Final[tuple[int]])rd   re   r   rh   rP   rL   r   r  rB   rB   rC   rf   
     zFinalTests.test_reprc                 C   r  )Nc                   @   rO   z*FinalTests.test_cannot_subclass.<locals>.CNrQ   rB   rB   rB   rC   r   
  rR   r   c                   @   rO   r   rQ   rB   rB   rB   rC   r   
  rR   )rZ   r[   rn   r   rh   r   rB   rB   rC   rp   
  r  zFinalTests.test_cannot_subclassc                 C   r  rG   )rZ   r[   r   rn   r   rh   r]   rB   rB   rC   rI  
  r  zFinalTests.test_cannot_initc                 C   r  rH  )rZ   r[   r\   r   rh   r<   r]   rB   rB   rC   r  
  r  zFinalTests.test_no_isinstancec                 C   s   dd }|  |t| d S )Nc                 S   r   rG   rB   r   rB   rB   rC   func
  r   z.FinalTests.test_final_unmodified.<locals>.func)r   r   )r>   r!  rB   rB   rC   test_final_unmodified
  s   z FinalTests.test_final_unmodifiedN)	rL   rM   rN   r   rf   rp   rI  r  r"  rB   rB   rB   rC   r  
  s    	r  c                   @   r  )	CastTestsc                 C   s   |  ttdd |  ttdd | tttdt |  ttdd |  ttdd |  ttt	tf dd |  tt
dd |  td dd d S rX   )rd   r   rh   r   r   rn   r   r   r   r   r   r]   rB   rB   rC   r   
  s   zCastTests.test_basicsc                 C   s   t dd t dd d S )NrY   Zhello)r   r]   rB   rB   rC   ri   
  s   
zCastTests.test_errorsN)rL   rM   rN   r   ri   rB   rB   rB   rC   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;S )<ForwardRefTestsc                 C   s   G dd dt t }|t }t|jt t }| |d t|t   | |d t|t   | |d |d  | |d tt  | 	d| t|j
t t }| |d t|t   t|jt t }| |d t|t   d S )Nc                   @   sV   e Zd ZdefddZ			dddddd	efd
dZded fddZddddZ	dS )z)ForwardRefTests.test_basics.<locals>.Nodert  c                 S   s   || _ d  | _| _d S rG   r  )r>   rt  rB   rB   rC   ri  
  s   z2ForwardRefTests.test_basics.<locals>.Node.__init__Nr  zOptional[Node[T]]r  r  stuffc                 S   r  rG   )r  r  )r>   r  r  r%  blahrB   rB   rC   add_both
  s   
z2ForwardRefTests.test_basics.<locals>.Node.add_bothnodec                 S   s   |  |d  d S rG   r'  r>   r(  rB   rB   rC   add_left
  r  z2ForwardRefTests.test_basics.<locals>.Node.add_leftc                 S   s   |  d | d S rG   r)  r*  rB   rB   rC   	add_right
  r  z3ForwardRefTests.test_basics.<locals>.Node.add_right)NNNrG   )r(  r  )
rL   rM   rN   r   ri  rh   r'  r   r+  r,  rB   rB   rB   rC   r  
  s    
r  r  r  r%  r&  r(  )r   r   rh   r   r'  r  r  rd   r   assertNotInr+  r,  )r>   r  r   Z
both_hintsZ
left_hintsZright_hintsrB   rB   rC   r   
  s   zForwardRefTests.test_basicsc                 C   sD   t d}| t td| W d    d S 1 sw   Y  d S )Nrh   rY   )rH   r0   rZ   r[   r\   r>   frrB   rB   rC   #test_forwardref_instance_type_error
     
"z3ForwardRefTests.test_forwardref_instance_type_errorc                 C   sD   t d}| t tt| W d    d S 1 sw   Y  d S )Nrh   )rH   r0   rZ   r[   r<   rh   r.  rB   rB   rC   #test_forwardref_subclass_type_error   r1  z3ForwardRefTests.test_forwardref_subclass_type_errorc                 C   s:   |  t td W d    d S 1 sw   Y  d S rH  )rZ   r[   rH   r0   r]   rB   rB   rC   test_forwardref_only_str_arg  r_   z,ForwardRefTests.test_forwardref_only_str_argc                 C   s   t d}| |t d | td tt  | |t jdtd t jdtd}| |t jdtd | |t jddd d S )Nrh   module__other_name__)rH   r0   rd   r   r   rh   rL   )r>   r/  ZfrmrB   rB   rC   test_forward_equality	  s   
z%ForwardRefTests.test_forward_equalityc                 C   s   t d}t d}t d}t d}G dd d}d|d|fdd}| t|t t ||d | || | || | || | t| t|  | t| t|  | t| t|  | t||f t|  | t||t	f t|t	f  d S )Nr   c                   @   rO   )z4ForwardRefTests.test_forward_equality_gth.<locals>.CNrQ   rB   rB   rB   rC   r     rR   r   rf  c                 S   r   rG   rB   r   rf  rB   rB   rC   r    r   z6ForwardRefTests.test_forward_equality_gth.<locals>.foor8  )
rH   r0   rd   r   r  r  r   r   r   rh   )r>   r3  c1_gthr4  c2_gthr   r  rB   rB   rC   test_forward_equality_gth  s   



"z)ForwardRefTests.test_forward_equality_gthc                 C   s   t d}t d}t d}t d}d|d|fdd}t|t t  | t|t| | t|t| | t|t| t jdtd}t jddd}| t|t| | t|t| | t|t| | t|tt jdtd d S )Nrh   r   rf  c                 S   r   rG   rB   r8  rB   rB   rC   r  -  r   z7ForwardRefTests.test_forward_equality_hash.<locals>.foor4  r6  )	rH   r0   r   r  r  rd   r2  rL   r   )r>   r3  r9  r4  r:  r  Zc3Zc4rB   rB   rC   test_forward_equality_hash'  s   



"z*ForwardRefTests.test_forward_equality_hashc                 C   sB   G dd d}dd }dd }|  | |  | | |  d S )Nc                   @   rO   )z:ForwardRefTests.test_forward_equality_namespace.<locals>.ANrQ   rB   rB   rB   rC   rl   >  rR   rl   c                  S   s,   t d} d| fdd}t|t t  | S )Nrl   r   c                 S   r   rG   rB   r   rB   rB   rC   r   B  r   zPForwardRefTests.test_forward_equality_namespace.<locals>.namespace1.<locals>.funrH   r0   r   r  r  )r   r   rB   rB   rC   
namespace1@  s   
zCForwardRefTests.test_forward_equality_namespace.<locals>.namespace1c                  S   s:   t d} G dd d}d| fdd}t|t t  | S )Nrl   c                   @   rO   )zNForwardRefTests.test_forward_equality_namespace.<locals>.namespace2.<locals>.ANrQ   rB   rB   rB   rC   rl   J  rR   r   c                 S   r   rG   rB   r   rB   rB   rC   r   L  r   zPForwardRefTests.test_forward_equality_namespace.<locals>.namespace2.<locals>.funr=  )r   rl   r   rB   rB   rC   
namespace2G  s
   
zCForwardRefTests.test_forward_equality_namespace.<locals>.namespace2)rd   r   )r>   rl   r>  r?  rB   rB   rC   test_forward_equality_namespace=  s
   z/ForwardRefTests.test_forward_equality_namespacec                 C   s   |  ttd d d S )Nrh   ztyping.List[ForwardRef('int')])rd   re   r   r]   rB   rB   rC   test_forward_reprU     z!ForwardRefTests.test_forward_reprc                 C   st   dt d fdd}| t|t t dt t i dttd tB fdd}| t|t t dtt tB i d S )Nr   r   c                 S   r   rG   rB   r  rB   rB   rC   r  Z  r   z/ForwardRefTests.test_union_forward.<locals>.fooc                 S   r   rG   rB   r  rB   rB   rC   r  `  r   )	r   rd   r   r  r  r   r   r0   rh   r  rB   rB   rC   test_union_forwardX  s   
z"ForwardRefTests.test_union_forwardc                 C   sl   dt d fdd}| t|t t dt t i dttd fdd}| t|t t dtt i d S )Nr   r   c                 S   r   rG   rB   r  rB   rB   rC   r  h  r   z/ForwardRefTests.test_tuple_forward.<locals>.fooc                 S   r   rG   rB   r  rB   rB   rC   r  n  r   )r   rd   r   r  r  r   r   r0   r  rB   rB   rC   test_tuple_forwardf  s   

z"ForwardRefTests.test_tuple_forwardc                 C   s.   ddd}|  t|t t dtt i d S )Nr   List['int']c                 S   r   rG   rB   r  rB   rB   rC   r  u  r   z0ForwardRefTests.test_double_forward.<locals>.foo)r   rE  )rd   r   r  r  r   rh   r  rB   rB   rC   test_double_forwardt  s   

z#ForwardRefTests.test_double_forwardc                 C   sD   dd }dd }dd }| }| }|  || | t||| d S )Nc                  S   0   t d} | }d| fdd}t|t t }| S )Nrl   r   c                 S   r   rG   rB   r   rB   rB   rC   r   ~  r   zPForwardRefTests.test_forward_recursion_actually.<locals>.namespace1.<locals>.funr=  r   rl   r   retrB   rB   rC   r>  {  
   
zCForwardRefTests.test_forward_recursion_actually.<locals>.namespace1c                  S   rG  )Nrl   r   c                 S   r   rG   rB   r   rB   rB   rC   r     r   zPForwardRefTests.test_forward_recursion_actually.<locals>.namespace2.<locals>.funr=  rH  rB   rB   rC   r?    rJ  zCForwardRefTests.test_forward_recursion_actually.<locals>.namespace2c                 S   s   | |kS rG   rB   )Zo1Zo2rB   rB   rC   cmp  r   z<ForwardRefTests.test_forward_recursion_actually.<locals>.cmp)r  rZ   RecursionError)r>   r>  r?  rK  Zr1Zr2rB   rB   rC   test_forward_recursion_actuallyz  s   z/ForwardRefTests.test_forward_recursion_actuallyc                    s  t d ttf  G  fddd}G  fddd}G  fddd}G  fdd	d	}| t|t t t|t t  | t|t t d
t ttt ttt d f  f  i | t|t t d
ttt ttt d f  f i | t|t t d
tt ttt ttt d f  f  t ttt d f  f i | t|t t d
ttt ttt d f  t ttt ttt d f  f  f i d S )NValuec                       s   e Zd ZU e  ed< dS )z7ForwardRefTests.test_union_forward_recursion.<locals>.Cr  N)rL   rM   rN   r   rp  rB   )rN  rB   rC   r        
 r   c                       s   e Zd ZU e f ed< dS )z7ForwardRefTests.test_union_forward_recursion.<locals>.Dr  N)rL   rM   rN   r   rp  rB   rN  Z	ValueListrB   rC   r       
 r  c                       s"   e Zd ZU ee  f ed< dS )z7ForwardRefTests.test_union_forward_recursion.<locals>.Er  NrL   rM   rN   r   r   rp  rB   rP  rB   rC   r       
 r  c                       s$   e Zd ZU e e  f ed< dS )z7ForwardRefTests.test_union_forward_recursion.<locals>.Fr  NrR  rB   rP  rB   rC   r    s   
 r  r  )r   r   r   rd   r   r  r  )r>   r   r  r  r  rB   rP  rC   test_union_forward_recursion  s8   $"z,ForwardRefTests.test_union_forward_recursionc                 C   sB   dt dgdf fdd}| t|t t dt tgtf i d S )Nr   r   c                 S   r   rG   rB   r  rB   rB   rC   r    r   z2ForwardRefTests.test_callable_forward.<locals>.foo)r   rd   r   r  r  r   r  rB   rB   rC   test_callable_forward  s   z%ForwardRefTests.test_callable_forwardc                 C   s2   ddd}|  t|t t dtdtf i d S )Nr   Callable[..., T]c                 S   r   rG   rB   r  rB   rB   rC   r    r   z@ForwardRefTests.test_callable_with_ellipsis_forward.<locals>.foo.)r   rV  )rd   r   r  r  r   r   r  rB   rB   rC   #test_callable_with_ellipsis_forward  s   
z3ForwardRefTests.test_callable_with_ellipsis_forwardc                 C   s   G dd d}G dd d}|  t|t d tt  |  t|t d tt  | t t|t f W d    d S 1 sBw   Y  d S )Nc                   @   s.   e Zd ZU dZed ed< dZed ed< dS )z5ForwardRefTests.test_special_forms_forward.<locals>.Cr@  )ClassVar[int])r:  rA  r   )
Final[int]constrf  N)rL   rM   rN   r   r/   rp  rf  rB   rB   rB   rC   r        
 r   c                   @      e Zd ZU dZed ed< dS )z6ForwardRefTests.test_special_forms_forward.<locals>.CFr@  rY  rf  N)rL   rM   rN   rf  r   rp  rB   rB   rB   rC   CF  rQ  r]  r   rf  )rd   r   r  r   rh   r   rZ   r[   )r>   r   r]  rB   rB   rC   test_special_forms_forward  s   "z*ForwardRefTests.test_special_forms_forwardc                 C   r   )Nz/T)rZ   SyntaxErrorr   r]   rB   rB   rC   test_syntax_error  s   
"z!ForwardRefTests.test_syntax_errorc                 C   sB   ddd}|  t t| W d    d S 1 sw   Y  d S )Nr   Node[Tc                 S   r   rG   rB   r  rB   rB   rC   r    r   z6ForwardRefTests.test_delayed_syntax_error.<locals>.foo)r   ra  )rZ   r_  r   r  rB   rB   rC   test_delayed_syntax_error  s   

"z)ForwardRefTests.test_delayed_syntax_errorc                 C   sJ   dt d fdd}| t t| W d    d S 1 sw   Y  d S )Nr   Z42c                 S   r   rG   rB   r  rB   rB   rC   r    r   z,ForwardRefTests.test_type_error.<locals>.foo)r   rZ   r[   r   r  rB   rB   rC   test_type_error  s   
"zForwardRefTests.test_type_errorc                 C   sF   ddd}|  t t|t  W d    d S 1 sw   Y  d S )Nr   Noode[T]c                 S   r   rG   rB   r  rB   rB   rC   r    r   z,ForwardRefTests.test_name_error.<locals>.foo)r   rd  )rZ   	NameErrorr   r  r  rB   rB   rC   test_name_error  s   
"zForwardRefTests.test_name_errorc                 C   s.   t dddi fdd}t|}| |i  d S )Nr   	whateversr   c                 S   r   rG   rB   r  rB   rB   rC   r    r  z/ForwardRefTests.test_no_type_check.<locals>.foo)r"   r   rd   )r>   r  thrB   rB   rC   test_no_type_check  s   z"ForwardRefTests.test_no_type_checkc                 C   sD   t G dd d}t|j}| |i  t| j}| |i  d S )Nc                   @      e Zd Zdddi fddZdS )z3ForwardRefTests.test_no_type_check_class.<locals>.Cr   rg  r   c                 S   r   rG   rB   r  rB   rB   rC   r    r   z7ForwardRefTests.test_no_type_check_class.<locals>.C.fooNrL   rM   rN   r  rB   rB   rB   rC   r         r   )r"   r   r  rd   )r>   r   cthithrB   rB   rC   test_no_type_check_class  s   
z(ForwardRefTests.test_no_type_check_classc                    s@   G dd d t G  fddd }| t jdti d S )Nc                   @   r  )z6ForwardRefTests.test_no_type_check_no_bases.<locals>.Cr   c                 S   r   rG   rB   r  rB   rB   rC   r    r   z;ForwardRefTests.test_no_type_check_no_bases.<locals>.C.methNrL   rM   rN   rh   r  rB   rB   rB   rC   r     r  r   c                       s   e Zd Z ZdS )z6ForwardRefTests.test_no_type_check_no_bases.<locals>.DN)rL   rM   rN   r   rB   r   rB   rC   r    r  r  r   )r"   rd   r   r  rh   r>   r  rB   rq  rC   test_no_type_check_no_bases  s   z+ForwardRefTests.test_no_type_check_no_basesc                 C   sl   G dd d}G dd d}G dd d}G dd d}d	t jt i}||||fD ]
}| t|| q)d S )
Nc                   @   s    e Zd ZU dZeje ed< dS )zCForwardRefTests.test_no_type_check_forward_ref_as_string.<locals>.C   r  N)rL   rM   rN   r  rH   r   rh   rp  rB   rB   rB   rC   r        
 r   c                   @   s   e Zd ZU dZee ed< dS )zCForwardRefTests.test_no_type_check_forward_ref_as_string.<locals>.Drt  r  N)rL   rM   rN   r  r   rh   rp  rB   rB   rB   rC   r    rQ  r  c                   @      e Zd ZU dZded< dS )zCForwardRefTests.test_no_type_check_forward_ref_as_string.<locals>.Ert  r  r  NrL   rM   rN   r  rp  rB   rB   rB   rC   r    rO  r  c                   @   rv  )zCForwardRefTests.test_no_type_check_forward_ref_as_string.<locals>.Frt  rX  r  Nrw  rB   rB   rB   rC   r    rO  r  r  )rH   r   rh   rd   r   )r>   r   r  r  r  Zexpected_resultclazzrB   rB   rC   (test_no_type_check_forward_ref_as_string  s   z8ForwardRefTests.test_no_type_check_forward_ref_as_stringc              	   C   s`   G dd d}G dd d}||fD ]}|  t t| W d    n1 s(w   Y  qd S )Nc                   @   rv  )zGForwardRefTests.test_nested_classvar_fails_forward_ref_check.<locals>.Ert  z%typing.ClassVar[typing.ClassVar[int]]r  Nrw  rB   rB   rB   rC   r    rO  r  c                   @   r\  )zGForwardRefTests.test_nested_classvar_fails_forward_ref_check.<locals>.Frt  rX  r  N)rL   rM   rN   r  r   rp  rB   rB   rB   rC   r    rQ  r  )rZ   r[   r   )r>   r  r  rx  rB   rB   rC   ,test_nested_classvar_fails_forward_ref_check  s   
z<ForwardRefTests.test_nested_classvar_fails_forward_ref_checkc                 C   s   t dd }| |jd |dddi fdd}|G d	d
 d
}| |jd t|}| |i  t|j}| |i  t| j}| |i  d S )Nc                 S   s   | S rG   rB   )r!  rB   rB   rC   magic_decorator&  r  z@ForwardRefTests.test_meta_no_type_check.<locals>.magic_decoratorr{  r   rg  r   c                 S   r   rG   rB   r  rB   rB   rC   r  ,  r  z4ForwardRefTests.test_meta_no_type_check.<locals>.fooc                   @   rj  )z2ForwardRefTests.test_meta_no_type_check.<locals>.Cr   rg  r   c                 S   r   rG   rB   r  rB   rB   rC   r  2  r   z6ForwardRefTests.test_meta_no_type_check.<locals>.C.fooNrk  rB   rB   rB   rC   r   0  rl  r   r  )r#   rd   rL   r   r  )r>   r{  r  r   rh  rm  rn  rB   rB   rC   test_meta_no_type_check$  s   

z'ForwardRefTests.test_meta_no_type_checkc                 C   s>   d}i }t || t|d j}| ||d |d d d S )Nz^class C:
    def foo(self, a: 'C') -> 'D': pass
class D:
    def bar(self, b: 'D') -> C: pass
r   r  )r   r   )r   r   r  rd   )r>   r   nshintsrB   rB   rC   test_default_globals=  s
   
z$ForwardRefTests.test_default_globalsc                 C   sT   |  ttt d tt  | ttt d tt  | ttt d t d S )Nr  )rd   gthLoopr  r   r   rh   r]   rB   rB   rC   test_final_forward_refH  s   z&ForwardRefTests.test_final_forward_refN) rL   rM   rN   r   r0  r2  r3  r7  r;  r<  r@  rA  rC  rD  rF  rM  rT  rU  rW  r^  r`  rb  rc  rf  ri  ro  rs  ry  rz  r|  r  r  rB   rB   rB   rC   r$  
  s<    $	 		
r$  c                   @   r  )OverloadTestsc                 C   sN   ddl m} | t |dd }|  W d    d S 1 s w   Y  d S )Nr   overloadc                   S   r   rG   rB   rB   rB   rB   rC   r&  U  r  z/OverloadTests.test_overload_fails.<locals>.blah)rH   r  rZ   RuntimeErrorr>   r  r&  rB   rB   rC   test_overload_failsP  s   
"z!OverloadTests.test_overload_failsc                 C   s*   ddl m} |dd }dd }|  d S )Nr   r  c                   S   r   rG   rB   rB   rB   rB   rC   r&  ^  r  z2OverloadTests.test_overload_succeeds.<locals>.blahc                   S   r   rG   rB   rB   rB   rB   rC   r&  b  r   )rH   r  r  rB   rB   rC   test_overload_succeeds[  s
   

z$OverloadTests.test_overload_succeedsN)rL   rM   rN   r  r  rB   rB   rB   rC   r  N  s    r  a  
import asyncio

T_a = TypeVar('T_a')

class AwaitableWrapper(typing.Awaitable[T_a]):

    def __init__(self, value):
        self.value = value

    def __await__(self) -> typing.Iterator[T_a]:
        yield
        return self.value

class AsyncIteratorWrapper(typing.AsyncIterator[T_a]):

    def __init__(self, value: typing.Iterable[T_a]):
        self.value = value

    def __aiter__(self) -> typing.AsyncIterator[T_a]:
        return self

    async def __anext__(self) -> T_a:
        data = await self.value
        if data:
            return data
        else:
            raise StopAsyncIteration

class ACM:
    async def __aenter__(self) -> int:
        return 42
    async def __aexit__(self, etype, eval, tb):
        return None
FT)
ann_moduleann_module2ann_module3ann_module5ann_module6)AsyncContextManagerc                   @   rr  )rl   r;  N)rL   rM   rN   r   rp  rB   rB   rB   rC   rl     rz  rl   c                   @   s2   e Zd ZU dZeed   ed< eed< eed< dS )r  Nr   r;  rf  )rL   rM   rN   r   r   r   rp  rh   rB   rB   rB   rC   r    s   
 r  c                   @   s    e Zd ZU e Zed  ed< dS )CSubr<  N)rL   rM   rN   r  r<  r   rp  rB   rB   rB   rC   r    ru  r  c                   @   s"   e Zd ZU g Zeee  ed< dS )r  lstN)rL   rM   rN   r  r   r   r   rp  rB   rB   rB   rC   r    rS  r  c                   @   s   e Zd ZU ed  ed< dS )r  r  N)rL   rM   rN   r   rp  rB   rB   rB   rC   r    rO  r  c                   @   s   e Zd ZU d ed< ded< dS )NoneAndForwardparentNmeaningr  rB   rB   rB   rC   r    rq  r  c                   @      e Zd ZU eed< eed< dS )CoolEmployeenamecoolNrL   rM   rN   r   rp  rh   rB   rB   rB   rC   r    rq  r  c                   @   s"   e Zd ZU eed< dZeed< dS )CoolEmployeeWithDefaultr  r   r  N)rL   rM   rN   r   rp  r  rh   rB   rB   rB   rC   r    s   
 r  c                   @      e Zd ZU eed< dd ZdS )XMethr   c                 C   s
   d| j  S )Nr9  r   r]   rB   rB   rC   double  rj  zXMeth.doubleN)rL   rM   rN   rh   rp  r  rB   rB   rB   rC   r    rq  r  c                   @   s2   e Zd ZU eed< dZeed< dd Zdd ZdS )	XReprr   r   r;  c                 C   s   | j  d| j S )Nz -> r  r]   rB   rB   rC   __str__     zXRepr.__str__c                 C   r  r  rB   r>   r  rB   rB   rC   __add__  r   zXRepr.__add__N)rL   rM   rN   rh   rp  r;  r  r  rB   rB   rB   rC   r    s
   
 r  Labelrt  c                   @   rm  )Point2Dr   r;  Nro  rB   rB   rB   rC   r    rq  r  c                   @   rr  )rL  rf  Nro  rB   rB   rB   rC   rL    rz  rL  totalc                   @   rO   )LabelPoint2DNrQ   rB   rB   rB   rC   r    r   r  c                   @   r  )Options	log_levellog_pathNrx  rB   rB   rB   rC   r    rq  r  c                   @   s   e Zd ZU ded< ded< dS )HasForeignBaseClassr  
some_xreprzmod_generics_cache.Aother_aNr  rB   rB   rB   rC   r    rq  r  amc              	      sB   | 4 I d H }|W  d   I d H  S 1 I d H sw   Y  d S rG   rB   )r  r   rB   rB   rC   g_with  s   0r  c                   @   s2   e Zd ZejdddZejejdddZdS )ForRefExampler>   c                 C   r   rG   rB   r]   rB   rB   rC   r!    r  zForRefExample.funcc                 C   r   rG   rB   r]   rB   rB   rC   nested  s   zForRefExample.nestedN)r>   r  )rL   rM   rN   r  decr!  r  rB   rB   rB   rC   r    s    r  c                   @   s   e Zd Zdd Zdd Zed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$S )%GetTypeHintTestsc                 C   s   |  t td W d    n1 sw   Y  |  t td W d    n1 s-w   Y  |  t td  W d    d S 1 sGw   Y  d S )N{   r	  )rZ   r[   r  r]   rB   rB   rC   (test_get_type_hints_from_various_objects  s   


"z9GetTypeHintTests.test_get_type_hints_from_various_objectsc                 C   sP   dt ttf ttttB d}| tt| | tti  | tti  d S )Nr9  )r   rJ   r   r;  r   )	r   rh   r   r   rd   r  r  r  r  )r>   Zann_module_type_hintsrB   rB   rC   test_get_type_hints_modules  s   z,GetTypeHintTests.test_get_type_hints_modulesz	known bugc                 C   s*   t tj t tj d}| tt| d S )N)Z	default_aZ	default_b)r   r7   rl   r  rd   r  )r>   Z	mgc_hintsrB   rB   rC   &test_get_type_hints_modules_forwardref  s   z7GetTypeHintTests.test_get_type_hints_modules_forwardrefc                 C   s<  |  ttjdttj i | ttjt |  ttjdt	d |  ttj
ttttj d |  ttjdti |  ttjdttj i |  ttjttd |  ttjdti |  tttt	d d |  ttttjtjd	 |  ttjttd |  ttjtjjtjjtjd
 d S )Nr;  r  )Z123r   )jrt  r;  r<  r  r   )r  r  )r  r  Zsome_b)Zmy_inner_a1Zmy_inner_a2Z
my_outer_a)rd   r  r  r   r   r   Zj_classr   Mrn   r  r   r   rh   Zh_classr  r  r  r  r  r7   rl   r  r  r]   rB   rB   rC   test_get_type_hints_classes  s>   

z,GetTypeHintTests.test_get_type_hints_classesc                 C   &   G dd d}|  t|dti d S )Nc                   @   s   e Zd ZU dZeed< dS )zZGetTypeHintTests.test_get_type_hints_classes_no_implicit_optional.<locals>.WithNoneDefaultNfield)rL   rM   rN   r  rh   rp  rB   rB   rB   rC   WithNoneDefault  rO  r  r  )rd   r  rh   )r>   r  rB   rB   rC   0test_get_type_hints_classes_no_implicit_optional  s   zAGetTypeHintTests.test_get_type_hints_classes_no_implicit_optionalc                 C   s   t G dd d}| |j | |jjj | ttjj	i  G dd dt
t }t G dd d|}| t|j	dti d S )Nc                   @   s   e Zd ZG dd dZdS )z>GetTypeHintTests.test_respect_no_type_check.<locals>.NoTpCheckc                   @   s   e Zd ZdddZdS )zBGetTypeHintTests.test_respect_no_type_check.<locals>.NoTpCheck.Innr   
not a typec                 S   r   rG   rB   r  rB   rB   rC   ri  $  r   zKGetTypeHintTests.test_respect_no_type_check.<locals>.NoTpCheck.Inn.__init__N)r   r  r  rB   rB   rB   rC   Inn#  r  r  N)rL   rM   rN   r  rB   rB   rB   rC   	NoTpCheck!  r  r  c                   @   r  )z:GetTypeHintTests.test_respect_no_type_check.<locals>.ABaser   c                 S   r   rG   rB   r   rB   rB   rC   r  )  r   z?GetTypeHintTests.test_respect_no_type_check.<locals>.ABase.methNrp  rB   rB   rB   rC   ABase(  r  r  c                   @   rO   )z8GetTypeHintTests.test_respect_no_type_check.<locals>.DerNrQ   rB   rB   rB   rC   Der*  rR   r  r   )r"   r  Z__no_type_check__r  ri  rd   r  r  ZNTCr  r   r   rh   )r>   r  r  r  rB   rB   rC   test_respect_no_type_check   s   z+GetTypeHintTests.test_respect_no_type_checkc                 C   s|   |  tti  |  tti  |  tti  |  tti  |  ttji  |  tt ji  |  ttj	i  d S rG   )
rd   r  rh   rn   dirr   r   r  r   joinr]   rB   rB   rC    test_get_type_hints_for_builtins.  s   z1GetTypeHintTests.test_get_type_hints_for_builtinsc                 C   sL   dd }d|j d< | t|dti ddd}| t|dtd i d S )Nc                 S   r   rG   rB   r  rB   rB   rC   testf9  r   z6GetTypeHintTests.test_previous_behavior.<locals>.testfrh   r   c                 S   r   rG   rB   r   rB   rB   rC   testg<  r   z6GetTypeHintTests.test_previous_behavior.<locals>.testg)r   N)rp  rd   r  rh   rn   )r>   r  r  rB   rB   rC   test_previous_behavior8  s
   

z'GetTypeHintTests.test_previous_behaviorc                 C   sH   G dd d}G dd d}| }ddi|_ | t|t d|i d S )Nc                   @   rO   )zKGetTypeHintTests.test_get_type_hints_for_object_with_annotations.<locals>.ANrQ   rB   rB   rB   rC   rl   @  r   rl   c                   @   rO   )zKGetTypeHintTests.test_get_type_hints_for_object_with_annotations.<locals>.BNrQ   rB   rB   rB   rC   r  A  r   r  r   )rp  rd   r  r  )r>   rl   r  rf  rB   rB   rC   /test_get_type_hints_for_object_with_annotations?  s
   
z@GetTypeHintTests.test_get_type_hints_for_object_with_annotationsc              	   C   s   |  ttjtjdtjtj i |  ttt t	tt
t  t	d |  ttt tt t	t	tt
t  d |  ttdttt  i d S )Nvar)r;  r   rf  )r<  r;  rf  r   r  )rd   r  r  ZCVr,  rH   r   r  r  rh   r   r  r  r   r   r]   rB   rB   rC   test_get_type_hints_ClassVarF  s   

 z-GetTypeHintTests.test_get_type_hints_ClassVarc                 C   s0   dt i}| tt j| | tt j| d S )Nr>   )r  rd   r  r!  r  )r>   ZexpectsrB   rB   rC   ,test_get_type_hints_wrapped_decoratored_funcP  s   z=GetTypeHintTests.test_get_type_hints_wrapped_decoratored_funcc           
      C   s  dt d fdd}ttdf }| t|t t dt t i | t|t t dddt ttdf  i dttd fdd}ttdf }| t|t t dtt i | t|t t dddtttdf  i t	tt
d	f d
f }d|fdd}| t|t t d t	t
d
f  | t|t t ddd | ttt
d	f d
f }d|fdd}| t|t t d tt
d
f  | t|t t ddd | dtjd
tt t
 df f dtjttt
df f fdd}| t|t t tjd
t t
 f tjtt
f d tjd
t t
 f }d|fdd}| t|t t ddd | tjttB df }d|fdd}	| t|	t t dttB i | t|	t t dddtjttB df i d S )Nr   r   c                 S   r   rG   rB   r   rB   rB   rC   r  V  r   z>GetTypeHintTests.test_get_type_hints_annotated.<locals>.foobarr   r  TZinclude_extrasc                 S   r   rG   rB   r   rB   rB   rC   r  a  r   )r   r   .c                 S   r   rG   rB   r   rB   rB   rC   r  m  r   z>GetTypeHintTests.test_get_type_hints_annotated.<locals>.barfooc                 S   r   rG   rB   r   rB   rB   rC   r  u  r   rZ  r;  Zmutablec                 S   r   rG   rB   r  rB   rB   rC   r  |  r   z?GetTypeHintTests.test_get_type_hints_annotated.<locals>.barfoo2r  c                 S   r   rG   rB   r   rB   rB   rC   barfoo3  r   z?GetTypeHintTests.test_get_type_hints_annotated.<locals>.barfoo3c                 S   r   rG   rB   r   rB   rB   rC   barfoo4  r   z?GetTypeHintTests.test_get_type_hints_annotated.<locals>.barfoo4)r   r/   rh   rd   r   r  r  r   r0   r   r   r   r   rH   r   r   r   )
r>   r  r   ZBAr  r  ZBA2r  ZBA3r  rB   rB   rC   test_get_type_hints_annotatedU  sr   

$$
 
z.GetTypeHintTests.test_get_type_hints_annotatedc              	   C   sf   dt tttdf  B fdd}| t|dt tt B i | t|dddt tttdf  B i d S )Nr   metac                 S   r   rG   rB   r   rB   rB   rC   
with_union  r   zKGetTypeHintTests.test_get_type_hints_annotated_in_union.<locals>.with_unionTr  )rh   r   r/   r   rd   r   )r>   r  rB   rB   rC   &test_get_type_hints_annotated_in_union  s   
z7GetTypeHintTests.test_get_type_hints_annotated_in_unionc                    s   t tdf  G  fdddtt }| t|jt t |t |t d | t|jt t dd |t  |t d | t|jt t |t |t d d S )NConstc                       s,   e Zd Zd
ddZd d ddfddZd	S )zBGetTypeHintTests.test_get_type_hints_annotated_refs.<locals>.MySetr  Const[MySet[T]]r   MySet[T]c                 S   r   rG   rB   r  rB   rB   rC   __ior__  r   zJGetTypeHintTests.test_get_type_hints_annotated_refs.<locals>.MySet.__ior__c                 S   r   rG   rB   r  rB   rB   rC   __iand__  r   zKGetTypeHintTests.test_get_type_hints_annotated_refs.<locals>.MySet.__iand__N)r  r  r   r  )rL   rM   rN   r  r  rB   r  rB   rC   MySet  s    
r  )r  r   Tr  )	r/   r   r   rd   r   r  r  r  r  )r>   r  rB   r  rC   "test_get_type_hints_annotated_refs  s   z3GetTypeHintTests.test_get_type_hints_annotated_refsc                 C   r  )Nc                   @   s   e Zd ZU eZded< dS )zIGetTypeHintTests.test_get_type_hints_classes_str_annotations.<locals>.Foor;  r   N)rL   rM   rN   r   r;  rp  rB   rB   rB   rC   rK    s   
 rK  r   )rd   r   r   r>   rK  rB   rB   rC   +test_get_type_hints_classes_str_annotations  s   z<GetTypeHintTests.test_get_type_hints_classes_str_annotationsc                 C   s6   G dd d}d|_ | dtj | t|i  d S )Nc                   @   rO   )zBGetTypeHintTests.test_get_type_hints_bad_module.<locals>.BadModuleNrQ   rB   rB   rB   rC   	BadModule  rR   r  bad)rM   r-  r  modulesrd   r   )r>   r  rB   rB   rC   test_get_type_hints_bad_module  s   z/GetTypeHintTests.test_get_type_hints_bad_modulec                 C   sR   G dd d}G dd d|}d |_ |_ | dtj | t|ttd d S )Nc                   @   rr  )zJGetTypeHintTests.test_get_type_hints_annotated_bad_module.<locals>.BadBaser  N)rL   rM   rN   r   rp  rB   rB   rB   rC   BadBase  rz  r  c                   @   rr  )zJGetTypeHintTests.test_get_type_hints_annotated_bad_module.<locals>.BadTyperB  N)rL   rM   rN   r   rp  rB   rB   rB   rC   BadType  rz  r  r  rC  )rM   r-  r  r  rd   r   r   r   )r>   r  r  rB   rB   rC   (test_get_type_hints_annotated_bad_module  s
   z9GetTypeHintTests.test_get_type_hints_annotated_bad_moduleN)rL   rM   rN   r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rB   rB   rB   rC   r    s&    	


?	r  c                   @   ,   e Zd Zdd Zdd Zdd Zdd Zd	S )
GetUtilitiesTestCasec                 C   s  t d}td}G dd dt| }| t|t | | t|| | | ttd  | ttt t | ttttf t | tt	d t	 | tt
tt  t
 | ttt | tt| t | ttt||f  t t | tt|df t | ttt | ttt | tttjj | ttt t | ttd  | tttB tj | t|j| | t|j| d S )Nr   r"  c                   @   rO   )z/GetUtilitiesTestCase.test_get_origin.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   rY   +   r  )r
   r2   r   r   r   rh   r   r   r   r   r   r   r   r   r/   r   r   r  r	  r   r  r   rX  r  rB   rB   rC   test_get_origin  s,    z$GetUtilitiesTestCase.test_get_originc              	   C   sP  t d}G dd dt| }| t|t tf | t|| |f | ttd | ttt tf | ttttf ttf | ttd d | tt	t
t  t
t f | tttt|tf f t ttttf f | ttjtt||f f tt  tttt tt f f | ttg |f t g tf | ttdtf dtf | ttttt|df gtf f ttt|df gtf f | tttdf tdf | ttd d | tt|dd	d
gf |dd	d
gf | tt
d | ttd | ttd | ttt tf | ttd | ttjjtgtf tgtf | ttjjdtf dtf | ttjjg tf g tf | ttjjtgtf tttgtf  td}| tt|tf |tf | tttt|f tf tt|f tf | tttB ttf d S )Nr   c                   @   rO   )z-GetUtilitiesTestCase.test_get_args.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   rB   r  .)rB   oner9  Zthreer"  )r
   r   rd   r    rh   r   r   r   r   r   r   r   rH   r   r   r   r/   r   r  r	  r2   r3   )r>   r   r   r"  rB   rB   rC   test_get_args  sP   $ $($  z"GetUtilitiesTestCase.test_get_argsc                 C   s:   t t}| |dtt i t tj}| |dti d S )Nr  r`  )r   r  rd   r   r   MyClass)r>   r~  rB   rB   rC   test_forward_ref_and_final  s   
z/GetUtilitiesTestCase.test_forward_ref_and_finalc                 C   s:   |  td tt W d    d S 1 sw   Y  d S )Nz4typing.ClassVar\[int\] is not valid as type argument)r#  r[   r   r  r]   rB   rB   rC   test_top_level_class_var  s   
"z-GetUtilitiesTestCase.test_top_level_class_varN)rL   rM   rN   r  r  r  r  rB   rB   rB   rC   r    s
    %r  c                   @   s  e Zd Zdd Zdd Zdd Zeeddd	 Zeedd
d Z	eeddd Z
eed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d2d3 Zd4d5 Zd6d7 Zd8d9 Z d:d; Z!d<d= Z"d>d? Z#d@dA Z$ee%j&dBkdCdDdE Z'ee%j&dBkdCdFdG Z(dHdI Z)dJdK Z*dLdM Z+dNdO Z,dPdQ Z-dRdS Z.dTdU Z/dVdW Z0dXdY Z1dZd[ Z2d\d] Z3d^d_ Z4d`da Z5dbdc Z6ddde Z7dfdg Z8dhdi Z9djdk Z:dlS )mCollectionsAbcTestsc                 C   s    |  dtj | g tj d S rX   )r   rH   Hashabler   r]   rB   rB   rC   test_hashable#  r1  z!CollectionsAbcTests.test_hashablec                 C   sX   |  g tj |  g tj |  g tj | dtj | ttj | ttj d S rX   )r   rH   r   r   rD   r   r]   rB   rB   rC   test_iterable'  s   z!CollectionsAbcTests.test_iterablec                 C   s(   t g }| |tj | dtj d S rX   )ry  r   rH   Iteratorr   )r>   itrB   rB   rC   test_iterator2  s   z!CollectionsAbcTests.test_iteratorz&Python 3.5 and multithreading requiredc                 C   sJ   i }t dt | |d }| }| |tj | |tj |d  d S )NzPasync def foo() -> typing.Awaitable[int]:
    return await AwaitableWrapper(42)
r  )r   r  r   rH   	Awaitabler   sendr>   r}  r  grB   rB   rC   test_awaitable7  s   z"CollectionsAbcTests.test_awaitablec                 C   s   i }t dt | |d }| }| |tj | t t|tjt  W d    n1 s/w   Y  | 	|tj z|
d  W d S  tyM   Y d S w )Nzasync def foo():
    return
r  )r   r  r   rH   	CoroutinerZ   r[   r\   rh   r   r  StopIterationr  rB   rB   rC   test_coroutineD  s"   z"CollectionsAbcTests.test_coroutinec                 C   s>   t d}t|}| |tj | |tj | dtj d S Nr  rY   )r  AsyncIteratorWrapperr   rH   AsyncIterabler   r>   Zbase_itr  rB   rB   rC   test_async_iterableV  s
   z'CollectionsAbcTests.test_async_iterablec                 C   s0   t d}t|}| |tj | dtj d S r  )r  r  r   rH   AsyncIteratorr   r  rB   rB   rC   test_async_iterator^  s   z'CollectionsAbcTests.test_async_iteratorc                 C       |  g tj | dtj d S rX   )r   rH   Sizedr   r]   rB   rB   rC   
test_sizede  r1  zCollectionsAbcTests.test_sizedc                 C   r  rX   )r   rH   r  r   r]   rB   rB   rC   test_containeri  r1  z"CollectionsAbcTests.test_containerc                 C   s@   |  t tj |  t tj | ttj | dtj d S rX   )r   r   rH   
Collectionr$  rD   r   r   r]   rB   rB   rC   test_collectionm  s   z#CollectionsAbcTests.test_collectionc                 C   s"   |  t tj | dtj d S rX   )r   r  rH   r  r   r]   rB   rB   rC   test_abstractsets  s   z$CollectionsAbcTests.test_abstractsetc                 C   s$   |  t tj | t tj d S rG   )r   r  rH   
MutableSetr   r$  r]   rB   rB   rC   test_mutablesetw  s   z#CollectionsAbcTests.test_mutablesetc                 C       |  i tj | dtj d S rX   )r   rH   r   r   r]   rB   rB   rC   test_mapping{  r1  z CollectionsAbcTests.test_mappingc                 C   r  rX   )r   rH   r   r   r]   rB   rB   rC   test_mutablemapping  r1  z'CollectionsAbcTests.test_mutablemappingc                 C   r  rX   )r   rH   r  r   r]   rB   rB   rC   test_sequence  r1  z!CollectionsAbcTests.test_sequencec                 C   r  r   )r   rH   MutableSequencer   r]   rB   rB   rC   test_mutablesequence  r1  z(CollectionsAbcTests.test_mutablesequencec                 C   s$   |  dtj |  tdtj d S r8  )r   rH   
ByteString	bytearrayr]   rB   rB   rC   test_bytestring  s   z#CollectionsAbcTests.test_bytestringc                 C      |  ttj d S rG   )rD   r   rH   r   r]   rB   rB   rC   	test_list  r  zCollectionsAbcTests.test_listc                 C   s:   |  tjtj G dd dtjt }| | tj d S )Nc                   @   rO   )z/CollectionsAbcTests.test_deque.<locals>.MyDequeNrQ   rB   rB   rB   rC   MyDeque  r   r  )rD   r  dequerH   Dequerh   r   )r>   r  rB   rB   rC   
test_deque  s   zCollectionsAbcTests.test_dequec                 C   s   |  tjtj d S rG   )rD   r  CounterrH   r]   rB   rB   rC   test_counter  rg   z CollectionsAbcTests.test_counterc                 C   r.  rG   )rD   r  rH   SetrF   r$  r]   rB   rB   rC   test_set  r1  zCollectionsAbcTests.test_setc                 C   r.  rG   )rD   r$  rH   r  rF   r  r]   rB   rB   rC   test_frozenset  r1  z"CollectionsAbcTests.test_frozensetc                 C   r  rG   )rD   r   rH   r   r]   rB   rB   rC   rg    r  zCollectionsAbcTests.test_dictc                 C   s   t d}t d}| t||f ttf tttf  | t|tf t tttf  | tt|f t tttf  | t|t| f ttf tttt f  | t|tt f t tttt f  | t|t| f ttf tttt f  | t|tt f t tttt f  d S )NKr   )r
   rd   r   r   rh   r   r   )r>   r%  r   rB   rB   rC   test_dict_subscribe  s   $  ,(,,z'CollectionsAbcTests.test_dict_subscribec                 C      |  t t  W d    n1 sw   Y  |  t tjt   W d    n1 s/w   Y  |  t tjt   W d    d S 1 sKw   Y  d S rG   )rZ   r[   rH   r   r   rh   r]   rB   rB   rC   test_no_list_instantiation  r  z.CollectionsAbcTests.test_no_list_instantiationc                 C   sR   G dd dt jt }| }| || | |t j | |t | t| d S )Nc                   @   rO   )z6CollectionsAbcTests.test_list_subclass.<locals>.MyListNrQ   rB   rB   rB   rC   MyList  rR   r)  )rH   r   rh   r   r  rD   r   rF   )r>   r)  r   rB   rB   rC   test_list_subclass  s   z&CollectionsAbcTests.test_list_subclassc                 C   s   |  t t  W d    n1 sw   Y  |  t tjttf   W d    n1 s1w   Y  |  t tjttf   W d    d S 1 sOw   Y  d S rG   )rZ   r[   rH   r   r   r   r   rh   r]   rB   rB   rC   test_no_dict_instantiation     
"z.CollectionsAbcTests.test_no_dict_instantiationc                 C   sV   G dd dt jttf }| }| || | |t j | |t | t| d S )Nc                   @   rO   )z6CollectionsAbcTests.test_dict_subclass.<locals>.MyDictNrQ   rB   rB   rB   rC   r    rR   r  )	rH   r   r   rh   r   r   rD   r   rF   )r>   r  r  rB   rB   rC   test_dict_subclass  s   z&CollectionsAbcTests.test_dict_subclassc                 C   sV   |  tt tj |  ttjttf  tj |  ttjtt	f  tj d S rG   )
r   rn   rH   r  r  defaultdictr   r   r   rh   r]   rB   rB   rC   test_defaultdict_instantiation     "z2CollectionsAbcTests.test_defaultdict_instantiationc                 C   sL   G dd dt jttf }| }| || | |tj | tj| d S )Nc                   @   rO   )z@CollectionsAbcTests.test_defaultdict_subclass.<locals>.MyDefDictNrQ   rB   rB   rB   rC   	MyDefDict  rR   r1  )	rH   r  r   rh   r   rD   r  r.  rF   )r>   r1  ddrB   rB   rC   test_defaultdict_subclass  
   z-CollectionsAbcTests.test_defaultdict_subclassc                 C   sV   |  tt tj |  ttjttf  tj |  ttjttf  tj d S rG   )	r   rn   rH   OrderedDictr  r   r   r   rh   r]   rB   rB   rC   test_ordereddict_instantiation  r0  z2CollectionsAbcTests.test_ordereddict_instantiationc                 C   L   G dd dt jttf }| }| || | |tj | tj| d S )Nc                   @   rO   )z@CollectionsAbcTests.test_ordereddict_subclass.<locals>.MyOrdDictNrQ   rB   rB   rB   rC   	MyOrdDict  rR   r8  )rH   r5  r   rh   r   rD   r  rF   )r>   r8  ZodrB   rB   rC   test_ordereddict_subclass  r4  z-CollectionsAbcTests.test_ordereddict_subclassr  zChainMap was added in 3.3c                 C   s   |  tt tj |  ttjttf  tj |  ttjttf  tj G dd dtjttf }|  t|ttf  | d S )Nc                   @   rO   )z;CollectionsAbcTests.test_chainmap_instantiation.<locals>.CMNrQ   rB   rB   rB   rC   CM  r   r:  )	r   rn   rH   r  r  r   r   r   rh   )r>   r:  rB   rB   rC   test_chainmap_instantiation  s
   z/CollectionsAbcTests.test_chainmap_instantiationc                 C   r7  )Nc                   @   rO   )z>CollectionsAbcTests.test_chainmap_subclass.<locals>.MyChainMapNrQ   rB   rB   rB   rC   
MyChainMap  rR   r<  )rH   r  r   rh   r   rD   r  rF   )r>   r<  cmrB   rB   rC   test_chainmap_subclass   s
   z*CollectionsAbcTests.test_chainmap_subclassc                 C   sz   |  tt tj |  ttjt  tj |  ttjt  tj G dd dtjt }|  t|t  | d S )Nc                   @   rO   )z7CollectionsAbcTests.test_deque_instantiation.<locals>.DNrQ   rB   rB   rB   rC   r    r   r  )r   rn   rH   r  r  r  r   rh   rr  rB   rB   rC   test_deque_instantiation  
   z,CollectionsAbcTests.test_deque_instantiationc                 C   sz   |  tt tj |  ttjt  tj |  ttjt  tj G dd dtjt }|  t|t  | d S )Nc                   @   rO   )z9CollectionsAbcTests.test_counter_instantiation.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   )r   rn   rH   r   r  r   rh   r   rB   rB   rC   test_counter_instantiation  r@  z.CollectionsAbcTests.test_counter_instantiationc                 C   sH   G dd dt jt }| }| || | |t j | |tj d S )Nc                   @   rO   )zJCollectionsAbcTests.test_counter_subclass_instantiation.<locals>.MyCounterNrQ   rB   rB   rB   rC   	MyCounter  rR   rB  )rH   r   rh   r   r  )r>   rB  r  rB   rB   rC   #test_counter_subclass_instantiation  s
   z7CollectionsAbcTests.test_counter_subclass_instantiationc                 C   r'  rG   )rZ   r[   rH   r"  r   rh   r]   rB   rB   rC   test_no_set_instantiation$  r  z-CollectionsAbcTests.test_no_set_instantiationc                 C   ,   G dd dt jt }| }| || d S )Nc                   @   rO   )zBCollectionsAbcTests.test_set_subclass_instantiation.<locals>.MySetNrQ   rB   rB   rB   rC   r  .  rR   r  )rH   r"  rh   r   )r>   r  r  rB   rB   rC   test_set_subclass_instantiation,     z3CollectionsAbcTests.test_set_subclass_instantiationc                 C   r'  rG   )rZ   r[   rH   r  r   rh   r]   rB   rB   rC   test_no_frozenset_instantiation4  r  z3CollectionsAbcTests.test_no_frozenset_instantiationc                 C   rE  )Nc                   @   rO   )zNCollectionsAbcTests.test_frozenset_subclass_instantiation.<locals>.MyFrozenSetNrQ   rB   rB   rB   rC   MyFrozenSet>  rR   rI  )rH   r  rh   r   )r>   rI  r  rB   rB   rC   %test_frozenset_subclass_instantiation<  rG  z9CollectionsAbcTests.test_frozenset_subclass_instantiationc                 C   s   |  t t  W d    n1 sw   Y  |  t tt   W d    n1 s-w   Y  |  t tt   W d    d S 1 sHw   Y  d S rG   )rZ   r[   r   r   rh   r]   rB   rB   rC   test_no_tuple_instantiationD  s   "z/CollectionsAbcTests.test_no_tuple_instantiationc                 C   s$   dd }| }|  t|tj d S )Nc                   s       dV  d S rX   rB   rB   rB   rB   rC   r  M  s   
z/CollectionsAbcTests.test_generator.<locals>.foo)rD   rn   rH   	Generator)r>   r  r  rB   rB   rC   test_generatorL  s   z"CollectionsAbcTests.test_generatorc                 C   s   |  t t  W d    n1 sw   Y  |  t tjtttf   W d    n1 s2w   Y  |  t tjtttf   W d    d S 1 sQw   Y  d S rG   )rZ   r[   rH   rM  r   rh   r]   rB   rB   rC   test_no_generator_instantiationR  s   
"z3CollectionsAbcTests.test_no_generator_instantiationc                 C   s2   i }t dt | |d  }| t|tj d S )Nzasync def f():
    yield 42
rJ   )r   r  rD   rn   rH   AsyncGenerator)r>   r}  r  rB   rB   rC   test_async_generatorZ  s   
z(CollectionsAbcTests.test_async_generatorc                 C   s   |  t t  W d    n1 sw   Y  |  t tjttf   W d    n1 s1w   Y  |  t tjttf   W d    d S 1 sOw   Y  d S rG   )rZ   r[   rH   rP  r   rh   r]   rB   rB   rC   %test_no_async_generator_instantiationa  r,  z9CollectionsAbcTests.test_no_async_generator_instantiationc                 C   sT  G dd dt j}| t |  W d    n1 sw   Y  G dd d|}| t| d | | t j G dd dt jtt	f }| t| d | t|t
t
f  d | t|tt	f  d | t| | t| | |t j | |t j | |t j | |tt	f  t j | |tt	f  tjj | |tjj | |tjj | |tjj | t t|t
t
f t j W d    n1 sw   Y  | || G dd	 d	t j}| t| G d
d dt jtttf }dd }| |t j | |t j | |tjj | |tjj | t|| d S )Nc                   @   rO   )z1CollectionsAbcTests.test_subclassing.<locals>.MMANrQ   rB   rB   rB   rC   MMAk  rR   rS  c                   @   rr  )z1CollectionsAbcTests.test_subclassing.<locals>.MMCc                 S   r   rG   rB   rs  rB   rB   rC   r_  r  r   z=CollectionsAbcTests.test_subclassing.<locals>.MMC.__getitem__c                 S   r   rG   rB   ru  rB   rB   rC   rb  t  r   z=CollectionsAbcTests.test_subclassing.<locals>.MMC.__setitem__c                 S   r   rG   rB   rs  rB   rB   rC   rv  v  r   z=CollectionsAbcTests.test_subclassing.<locals>.MMC.__delitem__c                 S   rw  r   rx  r]   rB   rB   rC   rG  x  r   z:CollectionsAbcTests.test_subclassing.<locals>.MMC.__iter__c                 S   r  r  rB   r]   rB   rB   rC   rz  z  r   z9CollectionsAbcTests.test_subclassing.<locals>.MMC.__len__Nr{  rB   rB   rB   rC   MMCq  r}  rT  r   c                   @   rr  )z1CollectionsAbcTests.test_subclassing.<locals>.MMBc                 S   r   rG   rB   rs  rB   rB   rC   r_    r   z=CollectionsAbcTests.test_subclassing.<locals>.MMB.__getitem__c                 S   r   rG   rB   ru  rB   rB   rC   rb    r   z=CollectionsAbcTests.test_subclassing.<locals>.MMB.__setitem__c                 S   r   rG   rB   rs  rB   rB   rC   rv    r   z=CollectionsAbcTests.test_subclassing.<locals>.MMB.__delitem__c                 S   rw  r   rx  r]   rB   rB   rC   rG    r   z:CollectionsAbcTests.test_subclassing.<locals>.MMB.__iter__c                 S   r  r  rB   r]   rB   rB   rC   rz    r   z9CollectionsAbcTests.test_subclassing.<locals>.MMB.__len__Nr{  rB   rB   rB   rC   MMB  r}  rU  c                   @   rO   )z/CollectionsAbcTests.test_subclassing.<locals>.INrQ   rB   rB   rB   rC   I  r   rV  c                   @   rO   )z/CollectionsAbcTests.test_subclassing.<locals>.GNrQ   rB   rB   rB   rC   r    r   r  c                   s   rL  r  rB   rB   rB   rB   rC   r    s   
 z/CollectionsAbcTests.test_subclassing.<locals>.g)rH   r   rZ   r[   rd   r   r   r   r   r   r   rF   r   rD   r  r	  r<   r   r   rM  rh   rn   )r>   rS  rT  rU  rV  r  r  rB   rB   rC   test_subclassingi  sD   z$CollectionsAbcTests.test_subclassingc                 C   s   G dd dt jttf }i }tdt | |d }| |t j | |t j | |tjj | |tjj | 	t
|| | }| |t j | |t j | |tjj | |tjj | t
|| | || d S )Nc                   @   s   e Zd Zdd ZdddZdS )z?CollectionsAbcTests.test_subclassing_async_generator.<locals>.Gc                 S   r   rG   rB   )r>   r`  rB   rB   rC   asend  r   zECollectionsAbcTests.test_subclassing_async_generator.<locals>.G.asendNc                 S   r   rG   rB   )r>   typvaltbrB   rB   rC   athrow  r   zFCollectionsAbcTests.test_subclassing_async_generator.<locals>.G.athrowr  )rL   rM   rN   rX  r\  rB   rB   rB   rC   r    s    r  zasync def g(): yield 0r  )rH   rP  rh   r   r  rD   r  r  r	  rF   rn   r   r   )r>   r  r}  r  instancerB   rB   rC    test_subclassing_async_generator  s    z4CollectionsAbcTests.test_subclassing_async_generatorc                 C   sf   G dd dt j}G dd d|}G dd d}G dd d}| || | || | || d S )	Nc                   @   r  )z?CollectionsAbcTests.test_subclassing_subclasshook.<locals>.Basec                 S   s   |j dkrdS dS )NrK  TF)rL   r  rB   rB   rC   r    s   
zPCollectionsAbcTests.test_subclassing_subclasshook.<locals>.Base.__subclasshook__Nr   rB   rB   rB   rC   r    r  r  c                   @   rO   )z<CollectionsAbcTests.test_subclassing_subclasshook.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   c                   @   rO   )z>CollectionsAbcTests.test_subclassing_subclasshook.<locals>.FooNrQ   rB   rB   rB   rC   rK    r   rK  c                   @   rO   )z>CollectionsAbcTests.test_subclassing_subclasshook.<locals>.BarNrQ   rB   rB   rB   rC   rL    r   rL  )rH   r   rD   rF   )r>   r  r   rK  rL  rB   rB   rC   test_subclassing_subclasshook  s   z1CollectionsAbcTests.test_subclassing_subclasshookc                 C   s   G dd dt j}G dd d|}G dd d}|| | || | || G dd d}|| | || | || G d	d
 d
}tjj| | |t j d S )Nc                   @   rO   )z8CollectionsAbcTests.test_subclassing_register.<locals>.ANrQ   rB   rB   rB   rC   rl     r   rl   c                   @   rO   )z8CollectionsAbcTests.test_subclassing_register.<locals>.BNrQ   rB   rB   rB   rC   r    r   r  c                   @   rO   )z8CollectionsAbcTests.test_subclassing_register.<locals>.CNrQ   rB   rB   rB   rC   r     r   r   c                   @   rO   )z8CollectionsAbcTests.test_subclassing_register.<locals>.DNrQ   rB   rB   rB   rC   r    r   r  c                   @   rO   )z8CollectionsAbcTests.test_subclassing_register.<locals>.MNrQ   rB   rB   rB   rC   r    r   r  )	rH   r  r  rD   rF   r  r	  r   r   )r>   rl   r  r   r  r  rB   rB   rC   test_subclassing_register  s   

z-CollectionsAbcTests.test_subclassing_registerc                 C   s   G dd dt jj}| |tj | |tj G dd dt jj}| |tj | |tj G dd dt jj}| |tj G dd dt jjtjd	}G d
d d}|| | |tj d S )Nc                   @   rO   )z7CollectionsAbcTests.test_collections_as_base.<locals>.MNrQ   rB   rB   rB   rC   r    r   r  c                   @   rO   )z7CollectionsAbcTests.test_collections_as_base.<locals>.SNrQ   rB   rB   rB   rC   r    r   r  c                   @   rO   )z7CollectionsAbcTests.test_collections_as_base.<locals>.INrQ   rB   rB   rB   rC   rV    r   rV  c                   @   rO   )z7CollectionsAbcTests.test_collections_as_base.<locals>.ANrQ   rB   rB   rB   rC   rl     r   rl   )	metaclassc                   @   rO   )z7CollectionsAbcTests.test_collections_as_base.<locals>.BNrQ   rB   rB   rB   rC   r    r   r  )	r  r	  r   rD   rH   r   r  ABCMetar  )r>   r  r  rV  rl   r  rB   rB   rC   test_collections_as_base  s   
z,CollectionsAbcTests.test_collections_as_basec                 C   sD   |  tjtjB ttjtjf  |  tjtjB ttjtjf  d S rG   )rd   rH   r	  r  r   r  r  r]   rB   rB   rC   r    s    $z#CollectionsAbcTests.test_or_and_rorN);rL   rM   rN   r  r  r  r   ASYNCIOr  r   r  r  r
  r  r  r  r  r  r  r  r  r  r  r  r!  r#  r$  rg  r&  r(  r*  r+  r-  r/  r3  r6  r9  r  r  r;  r>  r?  rA  rC  rD  rF  rH  rJ  rK  rN  rO  rQ  rR  rW  r^  r_  r`  rc  r  rB   rB   rB   rC   r  !  sv    






Er  c                   @   s&   e Zd Zdd Zeeddd ZdS )OtherABCTestsc                 C   s4   t jdd }| }| |tj | dtj d S )Nc                   s   rL  rX   rB   rB   rB   rB   rC   manager     
z2OtherABCTests.test_contextmanager.<locals>.managerrY   )
contextlibcontextmanagerr   rH   rK  r   )r>   rf  r=  rB   rB   rC   test_contextmanager  s
   
z!OtherABCTests.test_contextmanagerzPython 3.5 requiredc                 C   s   G dd d}|  t tj | | tj tjdd }| }| |tj | tjt j	tf | 
t tdtjt  W d    n1 sKw   Y  | 
t tjttf  W d    d S 1 shw   Y  d S )Nc                   @   rO   )z7OtherABCTests.test_async_contextmanager.<locals>.NotACMNrQ   rB   rB   rB   rC   NotACM  rR   rk  c                   s   rL  rX   rB   rB   rB   rB   rC   rf    rg  z8OtherABCTests.test_async_contextmanager.<locals>.managerrY   )r   ACMrH   r  r   rh  ri  rd   rh   r   rZ   r[   r\   r   )r>   rk  rf  r=  rB   rB   rC   test_async_contextmanager  s   
"z'OtherABCTests.test_async_contextmanagerN)rL   rM   rN   rj  r   rd  rm  rB   rB   rB   rC   re    s    	re  c                   @   $   e Zd Zdd Zdd Zdd ZdS )	TypeTestsc                 C   sP   G dd d}G dd d|}G dd d|}dt | d|fd	d
}|| d S )Nc                   @   rO   )z'TypeTests.test_type_basic.<locals>.UserNrQ   rB   rB   rB   rC   User#  r   rp  c                   @   rO   )z,TypeTests.test_type_basic.<locals>.BasicUserNrQ   rB   rB   rB   rC   	BasicUser$  r   rq  c                   @   rO   )z*TypeTests.test_type_basic.<locals>.ProUserNrQ   rB   rB   rB   rC   ProUser%  r   rr  
user_classr   c                 S      |  S rG   rB   rs  rB   rB   rC   new_user'  r  z+TypeTests.test_type_basic.<locals>.new_userr$   )r>   rp  rq  rr  rv  rB   rB   rC   test_type_basic!  s
   zTypeTests.test_type_basicc                 C   s\   G dd d}G dd d|}G dd d|}t d|d}d	t| d
|fdd}|| d S )Nc                   @   rO   )z)TypeTests.test_type_typevar.<locals>.UserNrQ   rB   rB   rB   rC   rp  .  r   rp  c                   @   rO   )z.TypeTests.test_type_typevar.<locals>.BasicUserNrQ   rB   rB   rB   rC   rq  /  r   rq  c                   @   rO   )z,TypeTests.test_type_typevar.<locals>.ProUserNrQ   rB   rB   rB   rC   rr  0  r   rr  r_  r   rs  r   c                 S   rt  rG   rB   ru  rB   rB   rC   rv  4  r  z-TypeTests.test_type_typevar.<locals>.new_user)r
   r%   )r>   rp  rq  rr  r_  rv  rB   rB   rC   test_type_typevar,  s   zTypeTests.test_type_typevarc                 C   s&   t tt  }d|dt t fdd}d S )Nr   r   c                 S   s   | d u rd S |  S rG   rB   r  rB   rB   rC   r  <  s   z)TypeTests.test_type_optional.<locals>.foo)r   r%   BaseException)r>   rl   r  rB   rB   rC   test_type_optional9  s   zTypeTests.test_type_optionalN)rL   rM   rN   rw  rx  rz  rB   rB   rB   rC   ro    s    ro  c                   @   sd   e Zd Zedd Ze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 )NewTypeTestsc                 C   s    t dtat | jd t| _d S )NUserId	.UserName)r&   rh   r|  rN   r   UserNamer?   rB   rB   rC   
setUpClassG  s   
zNewTypeTests.setUpClassc                 C   s
   b | `d S rG   )r|  r~  r  rB   rB   rC   tearDownClassM  s   zNewTypeTests.tearDownClassc                 C   s   |    d S rG   )rK   r]   rB   rB   rC   tearDownS  s   zNewTypeTests.tearDownc                 C   s:   |  tdt |  | dt | tdd d d S )NrA  Joer      )r   r|  rh   r~  r   rd   r]   rB   rB   rC   r  V  s   zNewTypeTests.test_basicc                 C   st   |  t ttt W d    n1 sw   Y  |  t G dd dt}W d    d S 1 s3w   Y  d S )Nc                   @   rO   )z#NewTypeTests.test_errors.<locals>.DNrQ   rB   rB   rB   rC   r  _  rR   r  )rZ   r[   r<   r|  rh   rr  rB   rB   rC   ri   [  s   "zNewTypeTests.test_errorsc              	   C   s   t | jfD ]H}| j|d8 | t|B tt|f  | |tB t|tf  | tt|B t|f | t|tB |tf W d    n1 sHw   Y  qd S )Nr  )rh   r~  r   rd   r|  r   r    )r>   r?   rB   rB   rC   r   b  s   zNewTypeTests.test_orc                 C   s   |  tjd |  tjd |  tjt |  tjt | j}|  |jd |  |j| jjd  |  |jt |  |jt	 d S )Nr|  r~  r}  )
rd   r|  rL   rN   rM   Z__supertype__rh   r~  r)  r   )r>   r~  rB   rB   rC   test_special_attrsk  s   
zNewTypeTests.test_special_attrsc                 C   s<   |  ttt d |  t| jt d| jj d d S )Nz.UserIdr  r}  )rd   re   r|  rL   r~  r)  rN   r]   rB   rB   rC   rf   x  s   zNewTypeTests.test_reprc              
   C   s   t dt}ttjd D ]X}| j|dH tt|}t|}| 	|t t| j
|}t|}| 	|| j
 | tj t|| W d    n1 sPw   Y  W d    n1 s_w   Y  qd S )NUserAger   )r  )r&   r   r  r  r  r   r  r|  r  r   r~  rZ   PicklingError)r>   r  r  pickledr  rB   rB   rC   r  }  s    


zNewTypeTests.test_picklec                 C   r   )Nz-import typing
NT = typing.NewType('NT', int)
r   r   rB   rB   rC   r     s   z!NewTypeTests.test_missing__name__N)rL   rM   rN   r  r  r  r  r  ri   r   r  rf   r  r   rB   rB   rB   rC   r{  F  s    

	r{  c                   @   st   e Zd ZG dd de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 )NamedTupleTestsc                   @   r  )zNamedTupleTests.NestedEmployeer  r  Nr  rB   rB   rB   rC   NestedEmployee  rq  r  c                 C   s   t ddtfdtfg}| |t |dd}|ddd}| || | |t | |jd | |jd | |jd | |jd | |j	d | |j
d | |jtdtfdtfg d S )	NEmpr  idr  rY   Jimr   r  r  )r'   r   rh   rD   r   r   rd   r  r  rL   _fieldsrp  r  r5  )r>   r  ZjoejimrB   rB   rC   r     s   
zNamedTupleTests.test_basicsc                 C   s   t jd d dk rE| t tdttd W d    n1 s w   Y  | t G dd dt}W d    d S 1 s>w   Y  d S d S )Nr9  )r:  r  Name)r  r  c                   @   r  )z9NamedTupleTests.test_namedtuple_pyversion.<locals>.NotYetr   N)rL   rM   rN   r  rB   rB   rB   rC   NotYet  r  r  )r  r  rZ   r[   r'   rh   r   )r>   r  rB   rB   rC   test_namedtuple_pyversion  s   "z)NamedTupleTests.test_namedtuple_pyversionc                 C   sv   t dd}| |t  | |t | |jd | |jd | t jd | t jd | t jt	j
ttd d S )NZTimi(#  r  r  r  )r  r   r   rd   r  r  rL   r  rp  r  r5  r   rh   )r>   ZtimrB   rB   rC   test_annotation_usage  s   
z%NamedTupleTests.test_annotation_usagec                 C   s   t d}| |t  | |t | |jd | |jd t dd}| |jd | t jd | t jd | t jt	t
td | t jt	dd | t G dd	 d	t}W d    d S 1 sfw   Y  d S )
NZJeller   ZSjoerdr   r  r  )r  c                   @   s"   e Zd ZU dZeed< eed< dS )zRNamedTupleTests.test_annotation_usage_with_default.<locals>.NonDefaultAfterDefaultr:  r   r;  N)rL   rM   rN   r   rh   rp  rB   rB   rB   rC   NonDefaultAfterDefault  s   
 r  )r  r   r   rd   r  r  rL   r  rp  r   r   rh   _field_defaultsrZ   r[   r'   )r>   ZjelleZcooler_employeer  rB   rB   rC   "test_annotation_usage_with_default  s    

"z2NamedTupleTests.test_annotation_usage_with_defaultc                 C   s   |  td d |  tdjtdd  |  ttdd |  tddtd d | t G dd dt}W d    n1 sFw   Y  | t G d	d
 d
t}W d    d S 1 sdw   Y  d S )Nr   r9  rY   r   z42 -> 1r:  c                   @   r  )zDNamedTupleTests.test_annotation_usage_with_methods.<locals>.XMethBadr   c                 S   r  )Nzno chance for thisrB   r]   rB   rB   rC   r    r   zLNamedTupleTests.test_annotation_usage_with_methods.<locals>.XMethBad._fieldsN)rL   rM   rN   rh   rp  r  rB   rB   rB   rC   XMethBad  rq  r  c                   @   r  )zENamedTupleTests.test_annotation_usage_with_methods.<locals>.XMethBad2r   c                 S   r  )Nzno chance for this as wellrB   r]   rB   rB   rC   _source  r   zMNamedTupleTests.test_annotation_usage_with_methods.<locals>.XMethBad2._sourceN)rL   rM   rN   rh   rp  r  rB   rB   rB   rC   	XMethBad2  rq  r  )	rd   r  r  r   r   r  rZ   r\  r'   )r>   r  r  rB   rB   rC   "test_annotation_usage_with_methods  s   "z2NamedTupleTests.test_annotation_usage_with_methodsc                 C   sP   G dd d}|  t G dd dt|}W d    d S 1 s!w   Y  d S )Nc                   @   rO   )z4NamedTupleTests.test_multiple_inheritance.<locals>.ANrQ   rB   rB   rB   rC   rl     rR   rl   c                   @   rr  )z4NamedTupleTests.test_multiple_inheritance.<locals>.Xr   Nro  rB   rB   rB   rC   r     rz  r   )rZ   r[   r'   )r>   rl   r   rB   rB   rC   r    s   "z)NamedTupleTests.test_multiple_inheritancec                 C   s   t dttd}|dd}| |t | |jd | |jd | |jd | |j	t
ttd | t t ddtfgtd W d    n1 sLw   Y  | t t ddd	d
 W d    d S 1 siw   Y  d S )NLocalEmployee)r  ZageZNick   r  r   r;  r   r   r  )r'   r   rh   r   r   rd   r  rL   r  rp  r   rZ   r[   )r>   r  ZnickrB   rB   rC   test_namedtuple_keyword_usage  s   
"z-NamedTupleTests.test_namedtuple_keyword_usagec                 C   s   t dttttd}| |jd | |jd |tdddtfgd}| |j	t | |j
d | |jd | |jdtfg d S )Nr  )r?   r>   typenamefieldsrY   r  rB  )r'   rn   r   r   r   rd   rL   r  r   r?   r>   r  r  )r>   r  r   rB   rB   rC   %test_namedtuple_special_keyword_names  s   z5NamedTupleTests.test_namedtuple_special_keyword_namesc              	   C   s   t d}G dd dt }||fD ]4}| j|d$ | |jd | |ji  | |ji  | | | W d    n1 s?w   Y  qd S )Nr  c                   @   rO   )z2NamedTupleTests.test_empty_namedtuple.<locals>.CNTNrQ   rB   rB   rB   rC   CNT  rR   r  )structrB   )r'   r   rd   r  r  rp  r   )r>   r  r  r  rB   rB   rC   test_empty_namedtuple  s   z%NamedTupleTests.test_empty_namedtuplec                 C   sX  |  t t  W d    n1 sw   Y  |  t t  W d    n1 s,w   Y  |  t tddtfgd  W d    n1 sJw   Y  |  t tddtfg W d    n1 sgw   Y  |  t tdttd W d    n1 sw   Y  |  t tddtfdtfgd W d    d S 1 sw   Y  d S )Nr  r  _name)r  r  r  r  )r  )rZ   r[   r'   r  r   r   rh   r]   rB   rB   rC   test_namedtuple_errors  s$   
"z&NamedTupleTests.test_namedtuple_errorsc              	   C   s   t ddtfdtfgatt| jfD ]^}| j|dN |dd}ttj	d D ]}t
||}t|}| || | || q&t|}| || | || t|}| || | || W d    n1 sjw   Y  qd S )Nr  r  r  r  jane%   r   )r'   r   rh   r  r  r  r   r  r  r  r  r  rd   r   r   r   )r>   r?   r  r  r<  jane2rB   rB   rC   test_copy_and_pickle  s$   

z$NamedTupleTests.test_copy_and_pickleN)rL   rM   rN   r'   r  r   r  r  r  r  r  r  r  r  r  r  rB   rB   rB   rC   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S ) TypedDictTestsc                 C   s   t dttd}| |t | |tj | |tj	j
 |ddd}| t|t | |d d | |d d | |jd | |jt | |jtf | |jttd | |jd d S Nr  r  r  r   r  r  Tr(   r   rh   rD   r   rH   r   rF   r  r	  r  r   rn   rd   rL   rM   r  rp  	__total__r>   r  r  rB   rB   rC   test_basics_functional_syntax0  s   z,TypedDictTests.test_basics_functional_syntaxc                 C   s   t dttd}| |t | |tj | |tj	j
 |ddd}| t|t | |d d | |d d | |jd | |jt | |jtf | |jttd | |jd d S r  r  r  rB   rB   rC   test_basics_keywords_syntax?  s   z*TypedDictTests.test_basics_keywords_syntaxc              
   C   s   t dttttttd}| |jd | |j	ttttttd |tddddt
fgdthd}| |d t | |d	 d | |d
 d | |d d | |d dt
fg | |d dth d S )NTD)r?   r>   r  	_typenamer  r  rY   r  5   rB  rE  r?   r>   r  r  r  r  )r(   rn   r   r   rh   r   r   rd   rL   rp  r   r  )r>   r  r   rB   rB   rC   $test_typeddict_special_keyword_namesN  s   z3TypedDictTests.test_typeddict_special_keyword_namesc                 C   s  |  t t  W d    n1 sw   Y  |  t t  W d    n1 s,w   Y  |  t tddtfgd  W d    n1 sJw   Y  |  t tdttd W d    n1 sfw   Y  |  t tdttdd W d    d S 1 sw   Y  d S )Nr  r  )r  r  r  r  )r  )rZ   r[   r(   r  r   rh   r]   rB   rB   rC   test_typeddict_create_errorsZ  s   
"z+TypedDictTests.test_typeddict_create_errorsc                 C   s|  t dttd}| t jd |ddd}| t ti | W d    n1 s*w   Y  | t t|| W d    n1 sDw   Y  | t tt	| W d    n1 s^w   Y  | t t ddd W d    n1 syw   Y  | t t ddtfd	g W d    n1 sw   Y  | t t ddtfgtd
 W d    d S 1 sw   Y  d S )Nr  r  rH   r  r   ZHir   r   )r;  r   r  )
r(   r   rh   rd   rM   rZ   r[   r\   r<   r   r  rB   rB   rC   test_typeddict_errorsg  s*   "z$TypedDictTests.test_typeddict_errorsc                 C   s   |  tjd |  tjt |  tjtttd |  tjtf |  tj	d | 
ttj tddd}|  |d d |  |d d tddd	d}|  |d
 d	 d S )Nr  r  Tr   r   r  r   r;  hirt  )rd   r  rL   rM   rp  rh   r   r  r   r  rF   rH   r  r  )r>   Z
not_originr  rB   rB   rC   test_py36_class_syntax_usagex  s   z+TypedDictTests.test_py36_class_syntax_usagec                 C   s   t dttdatddd}ttjd D ]2}t||}t|}| 	|| | 	|ddd tt|}t|}| 	|ddd| qd S )NEmpDr  r  r  r   )
r(   r   rh   r  r  r  r  r  r  rd   )r>   r  r  r<  r  ZZZZEmpDnewrB   rB   rC   r    s   

zTypedDictTests.test_picklec                 C   sF   t dttd}| tj| tjd |f  | tj| tj	|  d S )Nr  r  )
r(   r   rh   rd   rH   r   r   r   r   r   )r>   r  rB   rB   rC   r     s   zTypedDictTests.test_optionalc                 C   s   t ddtidd}| | i  | |ddddi | |jd | |jt  | |jdh | t i  | tddd	di | tjd | tjt  | tjd	d
h d S )Nr  r   Fr  r   r   r9  )r  r  r  )r(   rh   rd   r  __required_keys__r$  __optional_keys__r  rr  rB   rB   rC   
test_total  s   zTypedDictTests.test_totalc                 C   s   G dd dt dd}d S )Nc                   @   rr  )z6TypedDictTests.test_optional_keys.<locals>.Point2Dor3Dr<  Nro  rB   rB   rB   rC   Point2Dor3D  rz  r  Fr  )r  )r>   r  rB   rB   rC   test_optional_keys  rB  z!TypedDictTests.test_optional_keysc                 C   s8   G dd dt }G dd d|dd}G dd d|}d S )	Nc                   @   rr  )z8TypedDictTests.test_keys_inheritance.<locals>.BaseAnimalr  Nru  rB   rB   rB   rC   
BaseAnimal  rz  r  c                   @   r  )z4TypedDictTests.test_keys_inheritance.<locals>.AnimalZvoicetailN)rL   rM   rN   r   rp  r   rB   rB   rB   rC   Animal  rq  r  Fr  c                   @   rr  )z1TypedDictTests.test_keys_inheritance.<locals>.CatZ	fur_colorNru  rB   rB   rB   rC   Cat  rz  r  )r(   )r>   r  r  r  rB   rB   rC   test_keys_inheritance  s   z$TypedDictTests.test_keys_inheritancec              
   C   s>  G dd dt }G dd dt }G dd dt dd}t d	d
ti}G dd d}G dd d||}| |jtg d | |jtg  | |jtttd G dd d||}| |jtddg | |jtdg | |jtttd G dd d||dd}| |jtdg | |jtddg | |jtttd G dd d||}	| |	jtd
dg | |	jtdg | |	jtttd ||f||f|||f||f||fg}
|
D ];}| j	|d* | 
td G dd dg|R  }W d    n	1 sw   Y  W d    n	1 sw   Y  qd S )Nc                   @   rr  )z5TypedDictTests.test_multiple_inheritance.<locals>.Oner  Nro  rB   rB   rB   rC   One  rz  r  c                   @   rr  )z5TypedDictTests.test_multiple_inheritance.<locals>.TwotwoNru  rB   rB   rB   rC   Two  rz  r  c                   @   rr  )z9TypedDictTests.test_multiple_inheritance.<locals>.UntotaluntotalNru  rB   rB   rB   rC   Untotal  rz  r  Fr  Inlineinlinec                   @   rO   )z9TypedDictTests.test_multiple_inheritance.<locals>.RegularNrQ   rB   rB   rB   rC   Regular  rR   r  c                   @   rr  )z7TypedDictTests.test_multiple_inheritance.<locals>.ChildchildNrL   rM   rN   r   rp  rB   rB   rB   rC   Child  rz  r  )r  r  r  c                   @   rr  )zCTypedDictTests.test_multiple_inheritance.<locals>.ChildWithOptionalr  Nr  rB   rB   rB   rC   ChildWithOptional  rz  r  r  r  r  )r  r  r  c                   @   rr  )zETypedDictTests.test_multiple_inheritance.<locals>.ChildWithTotalFalser  Nr  rB   rB   rB   rC   ChildWithTotalFalse  rz  r  c                   @   rr  )zLTypedDictTests.test_multiple_inheritance.<locals>.ChildWithInlineAndOptionalr  Nr  rB   rB   rB   rC   ChildWithInlineAndOptional  rz  r  )r  r  r  )basesz=cannot inherit from both a TypedDict type and a non-TypedDictc                   @   rO   )z7TypedDictTests.test_multiple_inheritance.<locals>.WrongNrQ   rB   rB   rB   rC   Wrong!  rR   r  )r(   r   rd   r  r$  r  rp  rh   r   r   r#  r[   )r>   r  r  r  r  r  r  r  r  r  Zwrong_basesr  r  rB   rB   rC   r    s   







z(TypedDictTests.test_multiple_inheritancec                 C   r   rG   rB   r]   rB   rB   rC   test_is_typeddict$  r   z TypedDictTests.test_is_typeddictc                 C   s    |  tttjt td d S )Nr8  )rd   r   rL  rH   r   rh   r]   rB   rB   rC   test_get_type_hints*  s   z"TypedDictTests.test_get_type_hintsc                 C   sr   G dd dt }|t }| |j| | |jd | |jtf |dd}| t|t | |ddi d S )Nc                   @   rr  )z5TypedDictTests.test_non_generic_subscript.<locals>.TDr   N)rL   rM   rN   r   rp  rB   rB   rB   rC   r  3  rz  r  rB   r   r  r   )	r(   rh   rd   r   r   r   r   rn   r   )r>   r  rl   r   rB   rB   rC   r  0  s   
z)TypedDictTests.test_non_generic_subscriptN)rL   rM   rN   r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  rB   rB   rB   rC   r  /  s      Wr  c                   @   r  )
IOTestsc                 C   s0   dt dtfdd}|jd }| |jtf d S )Nr   r   c                 S      |   S rG   readliner  rB   rB   rC   r%  B  r   zIOTests.test_io.<locals>.stuff)r*   r   rp  rd   r   r>   r%  r   rB   rB   rC   test_io@  s   
zIOTests.test_ioc                 C   .   dt dtfdd}|jd }| |jd d S )Nr   r   c                 S   r  rG   r  r  rB   rB   rC   r%  J  r   z"IOTests.test_textio.<locals>.stuffrB   )r+   r   rp  rd   r   r  rB   rB   rC   test_textioH     
zIOTests.test_textioc                 C   r  )Nr   r   c                 S   r  rG   r  r  rB   rB   rC   r%  R  r   z$IOTests.test_binaryio.<locals>.stuffrB   )r,   r   rp  rd   r   r  rB   rB   rC   test_binaryioP  r  zIOTests.test_binaryioc                 C   sn   ddl m}m}m}m}m} | |tj | |tj | |tj | t	|t	g d | |d d S )Nr   )r*   r+   r,   r  rL   r)   z	typing.io)
Z	typing.ior*   r+   r,   r  rL   r   rH   rd   r  )r>   r*   r+   r,   r  rL   rB   rB   rC   test_io_submoduleX  s   zIOTests.test_io_submoduleN)rL   rM   rN   r  r  r  r  rB   rB   rB   rC   r  >  s
    r  c                   @   rv   )RETestsc                 C   s   t dt j}| |jt | t|t | |t |d}| |jt	 | t|t	 | |t	 tt
ttf   t	t
ttf   d S )Nz[a-z]+z12345abcde.....)r  compilerV  rD   r)  r-   rn   r   searchr.   r   r   r   )r>   r$  ZmatrB   rB   rC   r   d  s   
zRETests.test_basicsc                 C   sP   |  tt tt  | tt tt  | tt tt  | tt t d S rG   )rd   r-   r   r   r   r.   r]   rB   rB   rC   test_alias_equalitys  s   zRETests.test_alias_equalityc                 C   s   t tttf  }| t |t  W d    n1 sw   Y  | t tdtt  W d    n1 s8w   Y  | t ttt tt  W d    d S 1 sWw   Y  d S rX   )	r.   r   r   r   rZ   r[   r\   r-   r<   )r>   mrB   rB   rC   ri   y  s   
"zRETests.test_errorsc                 C   st   |  ttd |  ttt d |  ttt d |  ttd |  ttt d |  ttt d d S )Nztyping.Patternztyping.Pattern[str]ztyping.Pattern[bytes]ztyping.Matchztyping.Match[str]ztyping.Match[bytes])rd   re   r-   r   r   r.   r]   rB   rB   rC   rf     s   zRETests.test_reprc                 C   s\   ddl m}m}m}m} | |tj | |tj | t|tddg | |d d S )Nr   )r.   r-   r  rL   r.   r-   z	typing.re)	Z	typing.rer.   r-   r  rL   r   rH   rd   r  )r>   r.   r-   r  rL   rB   rB   rC   test_re_submodule  s
   zRETests.test_re_submodulec                 C   sR   |  t}G dd dtj}W d    n1 sw   Y  | t|jd d S )Nc                   @   rO   )z'RETests.test_cannot_subclass.<locals>.ANrQ   rB   rB   rB   rC   rl     rR   rl   z.type 're.Match' is not an acceptable base type)rZ   r[   rH   r.   rd   r   	exception)r>   exrl   rB   rB   rC   rp     s   zRETests.test_cannot_subclassN)	rL   rM   rN   r   r  ri   rf   r  rp   rB   rB   rB   rC   r  a  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)S )*AnnotatedTestsc                 C   s8   |  td t  W d    d S 1 sw   Y  d S )Nz%Type Annotated cannot be instantiatedr#  r[   r/   r]   rB   rB   rC   test_new  s   "zAnnotatedTests.test_newc                 C   s<   |  tttddf d |  tttt ddf d d S )Nr@  rA  ztyping.Annotated[int, 4, 5]z(typing.Annotated[typing.List[int], 4, 5])rd   re   r/   rh   r   r]   rB   rB   rC   rf     s   zAnnotatedTests.test_reprc                 C   sJ   t t tdf df }| |t tddf  | |jd | |jt d S )Nr@  rA  r?  )r/   rh   rd   __metadata__r   ro   rB   rB   rC   rY    s   zAnnotatedTests.test_flattenc                 C   s   t tt df }t tt df }| |t t tt df  | |t jd | |t jtt  | t |t  W d    n1 sFw   Y  | t |tt	f  W d    d S 1 sbw   Y  d S )Nmy decoration)r  )
r/   r   r   rh   rd   r  r   rZ   r[   r   )r>   LLIrB   rB   rC   test_specialize  s   
"zAnnotatedTests.test_specializec                 C   s   |  tttddf ttddf hd | ttddf ttddf  | ttddf ttddf  | ttdf ttddf  |  ttddf ttddf ttddf httddf ttddf h d S )Nr@  rA  r   )rd   r   r/   rh   r   r   r   r]   rB   rB   rC   test_hash_eq  s   (  &zAnnotatedTests.test_hash_eqc                    s^   G  fddd t  df }|d} d}| || | |j|j | |j|j d S )Nc                       s$   e Zd ZdZdd Z fddZdS )z*AnnotatedTests.test_instantiate.<locals>.Cr@  c                 S   r  rG   r   r  rB   rB   rC   ri    rj  z3AnnotatedTests.test_instantiate.<locals>.C.__init__c                    s   t | stS |j| jkS rG   )r\   NotImplementedr   r  rq  rB   rC   __eq__  s   
z1AnnotatedTests.test_instantiate.<locals>.C.__eq__N)rL   rM   rN   classvarri  r  rB   rq  rB   rC   r     s    r   a decorationrA  )r/   rd   r   r  )r>   rl   r   r   rB   rq  rC   test_instantiate  s   zAnnotatedTests.test_instantiatec                 C   sN   t tjt df }| |g dddd | |t g dddd d S )Nr  )r@  r@  rA  r9  r   r?  )r/   rH   r   r   rd   rh   )r>   ZMyCountrB   rB   rC   test_instantiate_generic  s   "z'AnnotatedTests.test_instantiate_genericc                 C   s@   t d }| t |d W d    d S 1 sw   Y  d S )N)rh   rA  r  rA  )r/   rZ   r[   ro   rB   rB   rC   test_cannot_instantiate_forward  s   
"z.AnnotatedTests.test_cannot_instantiate_forwardc                 C   sD   t tdf }| t |d W d    d S 1 sw   Y  d S )Nr  rA  )r/   r   rZ   r[   ro   rB   rB   rC    test_cannot_instantiate_type_var  s   
"z/AnnotatedTests.test_cannot_instantiate_type_varc                 C   s>   |  t ttdf j W d    d S 1 sw   Y  d S )N)rA  rt  )rZ   r\  r/   r   r   r]   rB   rB   rC   test_cannot_getattr_typevar  r   z*AnnotatedTests.test_cannot_getattr_typevarc                 C   s@   G dd d}t |df }| |jd d|_| |jd d S )Nc                   @   r  )z/AnnotatedTests.test_attr_passthrough.<locals>.Cr@  N)rL   rM   rN   r  rB   rB   rB   rC   r     r  r   r  r@  rA  )r/   rd   r  r   )r>   r   rl   rB   rB   rC   test_attr_passthrough  s
   z$AnnotatedTests.test_attr_passthroughc                 C   sJ   G dd d}|  t|t d tt  |  t|t d tt  d S )Nc                   @   s>   e Zd ZU dZeee df ed< dZee	e df ed< dS )z7AnnotatedTests.test_special_form_containment.<locals>.Cr@  r  r  r  rZ  N)
rL   rM   rN   r  r/   r   rh   rp  rZ  r   rB   rB   rB   rC   r     s   
 r   r  rZ  )rd   r   r  r   rh   r   r   rB   rB   rC   test_special_form_containment  s    z,AnnotatedTests.test_special_form_containmentc                 C   sB   |  td G dd dt}W d    d S 1 sw   Y  d S )NzCannot subclass .*Annotatedc                   @   rO   )z.AnnotatedTests.test_cannot_subclass.<locals>.CNrQ   rB   rB   rB   rC   r     rR   r   r  r   rB   rB   rC   rp     s   "z#AnnotatedTests.test_cannot_subclassc                 C   sB   |  t tdttdf  W d    d S 1 sw   Y  d S )NrA  positive)rZ   r[   r\   r/   rh   r]   rB   rB   rC   test_cannot_check_instance     "z)AnnotatedTests.test_cannot_check_instancec                 C   sB   |  t ttttdf  W d    d S 1 sw   Y  d S )Nr  )rZ   r[   r<   rh   r/   r]   rB   rB   rC   test_cannot_check_subclass  r  z)AnnotatedTests.test_cannot_check_subclassc                 C   s:   |  td tt  W d    d S 1 sw   Y  d S )Nzat least two arguments)r#  r[   r/   rh   r]   rB   rB   rC   test_too_few_type_args  s   
"z%AnnotatedTests.test_too_few_type_argsc           
   
   C   s6  t jt jttf t jt ttdf t jtgtf g}|D ]:}t	|df }t
tjd D ]*}| j||d t||}t|}| || W d    n1 sPw   Y  q+qG dd dtt at	tt df }d|_d	|_t
tjd D ]"}t||}	t|	}| |jd | |jd	 | |jd qvd S )
N.r   r   )protocolrn   c                   @   r  )_Annotated_test_Gr   Nr  rB   rB   rB   rC   r  #  r  r  zA decorationrY   r	  )rH   r   r   rh   r   r   r   r   r   r/   r  r  r  r   r  r  rd   r   r   r  r  rB  r   )
r>   r  r   r   Zprotr  Zrestoredr  r  r<  rB   rB   rC   r    s2   

zAnnotatedTests.test_picklec                 C   s  d}d}t t|f }| |t t t|f  | |t t|f  t t||f  t tt |f }| |t t tt |f  | t |ttf  W d    n1 sSw   Y  | ||t  t tt ||f  t tjt	t
f |f }| |ttf t tjttf |f  | t |t  W d    n1 sw   Y  t t|f }| t |d   W d    n1 sw   Y  |t }| t |d   W d    d S 1 sw   Y  d S )Nr  zanother decoration)r/   r   rd   rh   r   rZ   r[   rH   r   r   r   r   )r>   r  Zdec2r  r  r  ZItr  rB   rB   rC   
test_subst1  s0   ""&


"zAnnotatedTests.test_substc                 C   s0   t ttdf  }| |t t ttdf   d S )NrA  )r   r/   r   rd   rh   r   rB   rB   rC   test_annotated_in_other_typesN  s    z,AnnotatedTests.test_annotated_in_other_typesc                 C   s2   G dd dt tdf }| |j|ttfd d S )Nc                   @   rO   )z,AnnotatedTests.test_annotated_mro.<locals>.XNrQ   rB   rB   rB   rC   r   S  r   r   r  z Annotated should be transparent.)r/   rh   rd   rc  r   r   rB   rB   rC   test_annotated_mroR  s   z!AnnotatedTests.test_annotated_mroN)rL   rM   rN   r  rf   rY  r  r  r  r  r  r  r  r  r   rp   r  r  r  r  r  r	  r
  rB   rB   rB   rC   r    s*    

	r  c                   @   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 )TypeAliasTestsc                 C      t }d S rG   rP   r>   r)  rB   rB   rC   -test_canonical_usage_with_variable_annotationY  r   z<TypeAliasTests.test_canonical_usage_with_variable_annotationc                 C   r  rG   r  r  rB   rB   rC   &test_canonical_usage_with_type_comment\  r   z5TypeAliasTests.test_canonical_usage_with_type_commentc                 C   s6   |  t t  W d    d S 1 sw   Y  d S rG   )rZ   r[   r1   r]   rB   rB   rC   rs   _  s   "z&TypeAliasTests.test_cannot_instantiatec                 C   rW   rX   )rZ   r[   r\   r1   r]   rB   rB   rC   r  c  r_   z!TypeAliasTests.test_no_isinstancec                 C   r  )Nc                   @   s   e Zd ZU ded< dS )z/TypeAliasTests.test_stringized_usage.<locals>.Ar1   r   Nr  rB   rB   rB   rC   rl   h  rz  rl   r   )rd   r   r1   ro   rB   rB   rC   test_stringized_usageg  s   z$TypeAliasTests.test_stringized_usagec                 C   r`   rG   )rZ   r[   r<   rP   r1   r]   rB   rB   rC   test_no_issubclassl  s   "z!TypeAliasTests.test_no_issubclassc                 C   rj   )Nc                   @   rO   z.TypeAliasTests.test_cannot_subclass.<locals>.CNrQ   rB   rB   rB   rC   r   u  rR   r   c                   @   rO   r  rQ   rB   rB   rB   rC   r   y  rR   )rZ   r[   r1   rn   r   rB   rB   rC   rp   s  s   "z#TypeAliasTests.test_cannot_subclassc                 C   rc   )Nztyping.TypeAlias)rd   re   r1   r]   rB   rB   rC   rf   |  rg   zTypeAliasTests.test_reprc                 C   rz   rG   )rZ   r[   r1   rh   r]   rB   rB   rC   test_cannot_subscript  r|   z$TypeAliasTests.test_cannot_subscriptN)rL   rM   rN   r  r  rs   r  r  r  rp   rf   r  rB   rB   rB   rC   r  X  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S )ParamSpecTestsc                 C   r   )Nr"  )r2   rd   r   rM  rB   rB   rC   r     r   zParamSpecTests.test_basic_plainc                 C   s   t d}td}t|tf }| |j|tf | |j|f t||f }| |j||f | |j||f tjj|tf }| |j|tf | |j|f tjj||f }| |j||f | |j||f d S Nr"  r   )	r2   r
   r   rh   rd   r   r   r  r	  r>   r"  r   r  r  r  r   rB   rB   rC   test_valid_uses  s   zParamSpecTests.test_valid_usesc                 C   s  t d}t d}| dt| | dt| | |jt | |jt | |jj	| | |jj	| | 
|j|j | 
|j|j | |j|j | |j|j | |j|j | |j|j | |j|j | 
t|jd | 
t|jd d S )Nr"  P_2r   rX  P.argsP.kwargs)r2   r   r  r   r   r4   rX  r5   r   r   rd   r   re   )r>   r"  r  rB   rB   rC   test_args_kwargs  s"   zParamSpecTests.test_args_kwargsc                 C   sh   t d}G dd dt| }| t|t t dt|tf i | t|jt t |j	|j
d d S )Nr"  c                   @   s(   e Zd ZU edef ed< d
ddZd	S )z)ParamSpecTests.test_stringized.<locals>.Cr"  r!  r   r  rX  r  c                 _   r   rG   rB   )r>   r   rX  rB   rB   rC   r    r   z-ParamSpecTests.test_stringized.<locals>.C.fooN)r   r  rX  r  )rL   rM   rN   r   rh   rp  r  rB   rB   rB   rC   r     s   
 r   r!  )r   rX  )r2   r   rd   r  r  r  r   rh   r  r   rX  r  rB   rB   rC   test_stringized  s   $zParamSpecTests.test_stringizedc                    s  t dtd td}G  fdddt f }|t|f }| |jt|f | |j|f | td |t  W d    n1 sGw   Y  | td |t|t	f  W d    n1 sdw   Y  |tt
t|f f }| |jtt
t|f f | |j|f |tttgf }| |jtttff | |jd |td	f }| |jttf | |jd G  fd
ddt  }|tt	tg }| |jtt	tff | |jd |tt	tf }	| |	jtt	tff | |	jd | |j|	j | |j|	j | |j|	j | ||	 |t }
| |
jtff | |
jd | td |tt	gtf  W d    n	1 sBw   Y  | td ||tf  W d    d S 1 s`w   Y  d S )Nr   r"  r  c                       s&   e Zd ZU e ef ed< ed< dS )z,ParamSpecTests.test_user_generics.<locals>.XrJ   r   NrL   rM   rN   r   rh   rp  rB   r"  r   rB   rC   r     s   
 r   r0  r/  rB   .c                       s   e Zd ZU e ef ed< dS )z,ParamSpecTests.test_user_generics.<locals>.ZrJ   Nr  rB   )r"  rB   rC   rZ    rQ  rZ  )r
   r2   r   rh   rd   r   r   r#  r[   r   r3   r   r  r   )r>   r  r   G1G2G3ZG4rZ  ZG5ZG6ZG7rB   r  rC   test_user_generics  sT   
$z!ParamSpecTests.test_user_genericsc                    s   t d t dG  fdddt f }|ttgtgf }|tgttgf }| || | |jttftff | |jtfttff d S )Nr"  r,  c                       s.   e Zd ZU e ef ed< eef ed< dS )zCParamSpecTests.test_multiple_paramspecs_in_user_generics.<locals>.XrJ   r  N)rL   rM   rN   r   rh   rp  r   rB   r"  r,  rB   rC   r     r[  r   )r2   r   rh   r   r   r   rd   r   )r>   r   r   r!  rB   r$  rC   )test_multiple_paramspecs_in_user_generics  s   z8ParamSpecTests.test_multiple_paramspecs_in_user_genericsc              
   C   s   t d}td}dtd |ttB tttf f}|D ]Y}| j|dI | t tj	||f |tf  W d    n1 s<w   Y  | t t
jj	||f |tf  W d    n1 s]w   Y  W d    n1 slw   Y  qd S )Nr   r"  rY   r   )r
   r2   rh   r   r   r   rZ   r[   rH   r   r  r	  )r>   r   r"  Zbad_argsr   rB   rB   rC   r     s   z(ParamSpecTests.test_bad_var_substitutionc                 C   s   t d}td}| |t| j | |t||f j | |t| j | |t||f j | |t| t	B j | |t||f t	B j d S Nr   r"  )
r
   r2   r-  r   r   r   r   r   r   rh   r"  rB   rB   rC   "test_no_paramspec_in__parameters__
  s   z1ParamSpecTests.test_no_paramspec_in__parameters__c                 C   s   t d}td}t||f }t| }t| }t| tB }| |j||f | |j||f | |j||f tttgt	f }| |ttgt	f t|  | |ttgt	f t|  | |ttgt	f t| tB  d S r&  )
r
   r2   r   r   r   rh   rd   r   r   r   )r>   r   r"  r  r   r!  r"  r   rB   rB   rC   !test_paramspec_in_nested_generics  s   $z0ParamSpecTests.test_paramspec_in_nested_genericsc                 C   sV  t d}t d}t|tf }| |j|f | || j|f | |t jd | |ttf jtf | |tt|f  j|f | |tt|f  jt|f | |d jd ttt|f tf }| |j|f | || j|f | |t jd | |ttf jtf | |tt|f  j|f | |tt|f  jt|f d S )Nr"  r,  rB   .)r2   r   rh   rd   r   r   r   r3   )r>   r"  r,  r  r  rB   rB   rC   test_paramspec_gets_copied,  s"   "z)ParamSpecTests.test_paramspec_gets_copiedN)rL   rM   rN   r   r  r  r  r#  r%  r   r'  r(  r)  rB   rB   rB   rC   r    s    6r  c                   @   rn  )ConcatenateTestsc                 C   s2   t d}G dd d}t||f }| |t d S )Nr"  c                   @   rO   )z-ConcatenateTests.test_basics.<locals>.MyClassNrQ   rB   rB   rB   rC   r  E  r   r  )r2   r3   r   )r>   r"  r  r   rB   rB   rC   r   C  s   zConcatenateTests.test_basicsc                 C   s   t d}td}ttt|f tf }| |jtt|f tf | |j|f ttt||f |f }| |jtt||f |f | |j||f tj	jtt|f tf }| |jtt|f tf | |j|f tj	jtt||f |f }| |jtt||f |f | |j||f d S r  )
r2   r
   r   r3   rh   rd   r   r   r  r	  r  rB   rB   rC   r  I  s   z ConcatenateTests.test_valid_usesc                 C   s  t d}td}td}t||f }| |t|f tt|f  | |tttgf tttf | |tg f tf | |ttt|f f ttt|f  | t |tdf  W d    n1 scw   Y  tt|f }| || tt|f  | |ttg tttf | |ttf tttf | |g  tf | |tt|f  ttt|f  | t |d  W d    d S 1 sw   Y  d S )Nr   r"  r,  .)	r
   r2   r3   rd   rh   r   r   rZ   r[   )r>   r   r"  r,  r   rB   rB   rC   r!  [  s,   "
"z&ConcatenateTests.test_var_substitutionN)rL   rM   rN   r   r  r!  rB   rB   rB   rC   r*  B  s    r*  c                   @   rr  )TypeGuardTestsc                 C   s6   t t  dt t fdd}| t|dt t i d S )Nr   c                 S   r   rG   rB   r   rB   rB   rC   r  u  r   z'TypeGuardTests.test_basics.<locals>.foo)r6   rh   rd   r  r  rB   rB   rC   r   r  s   zTypeGuardTests.test_basicsc                 C   r  )Nztyping.TypeGuardztyping.TypeGuard[int]ztyping.TypeGuard[%s.Employee]ztyping.TypeGuard[tuple[int]])rd   re   r6   rh   rP   rL   r   r  rB   rB   rC   rf   x  r  zTypeGuardTests.test_reprc                 C   r  )Nc                   @   rO   z.TypeGuardTests.test_cannot_subclass.<locals>.CNrQ   rB   rB   rB   rC   r     rR   r   c                   @   rO   r,  rQ   rB   rB   rB   rC   r     rR   )rZ   r[   rn   r6   rh   r   rB   rB   rC   rp     r  z#TypeGuardTests.test_cannot_subclassc                 C   r  rG   )rZ   r[   r6   rn   r   rh   r]   rB   rB   rC   rI    r  zTypeGuardTests.test_cannot_initc                 C   r  rH  )rZ   r[   r\   r6   rh   r<   r]   rB   rB   rC   r    r  z!TypeGuardTests.test_no_isinstanceNr  rB   rB   rB   rC   r+  q  s    	r+  SpecialAttrsPSpecialAttrsTc                   @   s0   e Zd Zdd ZedeZdd Zdd Z	dS )	SpecialAttrsTestsc                  C   s  i t jdt jdt jdt jdt jdt jdt jdt jdt j	d	t j
d
t jdt jdt jdt jdt jdt jdt jdi t jdt jdt jdt jdt jdt jdt jdt jdt jdt jdt jdt jdt jdt jdt j d t j!d!t j"d"i t j#d#t j$d$t j%d%t j&d&t jt' dt jt' dt jt't'f dt jt' dt jt' dt jt' dt jg t'f dt jd't'f dt j	t't'f d	t j
t' d
t jt' dt jt' dt jt't't'f di t jt' dt jt't'f dt jt' dt jt't'f dt jt' dt jt't't'f dt jt't'f dt jt' dt jt' dt jt' dt jt' dt jt't'f dt jt' dt jt't'f dt jt' dt jt' dt jt't'f di t j t' d t j!t' d!t j"t' d"t j$t' d$t j$t'd'f d$t j%t' d%t j&t' d&t j(d(t j'd)t j)d*t j*d+t j+d,t j,d-t j-d.t j.d/t j/d0t j0d1t j1d2t j2d3t j3d4t j4d5t j(t'd6f d(t j)t' d*t j*t't5f d+t j+t' d,t j-t' d.t j-d7 d.t j-d8 d.t j0t' d1t j2t' d3t j4t' d)t j4t6t7f d5i}|8 D ]V\}}| j9|d9B | :|j;|t<| | :|j=|t<| | :|j>d:t<| t?t@jAd; D ]}t@B||}t@C|}| D|| qCW d    n	1 scw   Y  qd S )<Nr  r  rP  r  r  r  r  r   r  r  r  rK  r  r   r  r  r   r  rM  r  	ItemsViewr   r  KeysViewr   r   MappingViewr   r  r  r5  r@  r  r"  r	  r   r%   
ValuesView.r/   r   r   r3   r   r0   r   r&   r	   r   r1   r6   r
   r   Z
Annotationr>  rP  r  rH   r   )ErH   r  r  rP  r  r  r  r  r   r  r  r  rK  r  r   r  r  r   r  rM  r  r0  r   r  r1  r   r   r2  r   r  r  r5  r@  r  r"  r	  r   r%   r3  r   r/   r   r3   r   r0   r   r&   r	   r   r1   r6   r
   r   r-  rh   r   r  r   rd   rL   r   rN   rM   r  r  r  r  r  r   )r>   Zcls_to_checkr?   r  r  r  r  rB   rB   rC   r    s  	
 !"#$%&'
)
*+
,
-
./01
2
3
45
67
89
:;<
=
>
?
@A
BC
D
EF
G
H
I
JK
L
MOPQRSTUVWXY







p
z$SpecialAttrsTests.test_special_attrsSpecialAttrsTests.TypeNamec              	   C   s  t d}| t|d | t|d | |jd ttjd D ]}| 	t
 t|| W d    n1 s;w   Y  q#| tjjd | tjjd | tjjt ttjd D ]}ttj|}t|}| tj| q`| tjd | ttd | tjt ttjd D ]}tt|}t|}| t| q| tjd	 | ttd | tjt ttjd D ]}tt|}t|}| t| qd S )
Nzset[Any]rL   rN   rH   r   TypeNamer4  r.  r-  )rH   r0   r   r  rd   rM   r  r  r  rZ   r[   r  r/  r5  rL   rN   r  r   r.  r-  )r>   r/  r  r  r  rB   rB   rC   test_special_attrs2  sJ   



z%SpecialAttrsTests.test_special_attrs2c                 C   s@   G dd dt t }| dt|t  | dt|t  d S )Nc                   @   s   e Zd Zdd ZdZdS )z4SpecialAttrsTests.test_genericalias_dir.<locals>.Fooc                 S   r   rG   rB   r]   rB   rB   rC   rB  O  r   z8SpecialAttrsTests.test_genericalias_dir.<locals>.Foo.barr:  N)rL   rM   rN   rB  rE  rB   rB   rB   rC   rK  N  s    rK  rB  rE  )r   r   r   r  rh   r  rB   rB   rC   test_genericalias_dirM  s   z'SpecialAttrsTests.test_genericalias_dirN)
rL   rM   rN   r  rH   r&   r   r5  r6  r7  rB   rB   rB   rC   r/    s
    {2r/  c                   @   s   e Zd Z	 dd Zdd ZdS )AllTestsc                 C   s   ddl m} | d| | d| | d| | d| | d| | d| | d	| | d
| | d| | d| | d| | d| | d| d S )Nr   )r  r  r3  r   r  rK  r  ior  osr  ZTextr;  r5  )rH   r  r   r-  r  rB   rB   rC   test_all[  s   zAllTests.test_allc                    s4   t tj  fddtt D }| |  d S )Nc                    sn   h | ]3\}}| v s3| d s5|tjjvr5|tjjvr5|dvr5|ds5| |ks5t|ddtjkr|qS )_>   r9  r  )r  Z_contraZ_corM   N)	r  rH   r9  r  r  r  upperr  rL   r  Z
actual_allrB   rC   	<setcomp>s  s    z3AllTests.test_all_exported_names.<locals>.<setcomp>)r  rH   r  varsr  ZassertSetEqual)r>   Zcomputed_allrB   r>  rC   test_all_exported_namesq  s
   


z AllTests.test_all_exported_namesN)rL   rM   rN   r;  rA  rB   rB   rB   rC   r8  X  s    r8  __main__)rh  r  r  r  r  Zunittestr   r   r   r   r   r   rH   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r%   r&   r'   r(   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r	  r  r   r  r7   r8   r9   rP   rS   rT   rU   rV   rw   r   r   r   r   r1  r6  r7  r   r   rZ  r[  r\  rf  rn  rs  rw  ry  r{  r|  r~  r  r  r  r  r  rQ  r  r  r#  r$  r  ZASYNCIO_TESTSr   ImportErrorrd  r  r  r  r  r  r  rl   r  r  r  r  r  r  r  r  r  r  r  rK  rL  r  r  r  rh   r  rl  r  r  er  r  r  r  r  re  ro  r{  r  r  r  r  r  r  r  r*  r+  r-  r   complexr.  r/  r8  rL   rB   rB   rB   rC   <module>   s6   *"l , u^      ~      }'1  {$  jO   c'M   #< <, ?/
' =
0
