o
    HXh                    @   s  d dl T d dlZd dlZd dlZ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
 d dlmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZmZmZ d dlmZ d dlZd dl Z G dd	 d	eZG d
d dejZG dd dejZ G dd dejZ!G dd dejZ"G dd dejZ#G dd dejZ$G dd dejZ%G dd dejZ&G dd dejZ'G dd dejZ(G dd dejZ)G d d! d!ejZ*G d"d# d#ejZ+G d$d% d%ejZ,G d&d' d'ejZ-G d(d) d)ejZ.G d*d+ d+ejZ/e0d,kre1  dS dS )-    )*N)Mock)
ClassVarAnyListUnionTupleDictGenericTypeVarOptionalProtocol)get_type_hints)dequeOrderedDict
namedtuple)total_orderingc                   @      e Zd ZdS )CustomErrorN__name__
__module____qualname__ r   r   ?/opt/python-3.10.19/usr/lib/python3.10/test/test_dataclasses.pyr          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 Z6didj Z7dkdl Z8dmdn Z9dodp Z:dqdr Z;dsdt Z<dudv Z=dwdx Z>dydz Z?d{d| Z@d}d~ ZAdd ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd Zbdd ZcddĄ ZdddƄ ZedS )TestCasec                 C   0   t G dd d}| }| tt|d d S )Nc                   @   r   )z"TestCase.test_no_fields.<locals>.CNr   r   r   r   r   C       r   r   	dataclassassertEquallenfieldsselfr   or   r   r   test_no_fields      zTestCase.test_no_fieldsc                 C   r   )Nc                   @   s   e Zd ZdZdS )z6TestCase.test_no_fields_but_member_variable.<locals>.Cr   N)r   r   r   ir   r   r   r   r   %   s    r   r   r    r%   r   r   r   "test_no_fields_but_member_variable$   r)   z+TestCase.test_no_fields_but_member_variablec                 C   ,   t G dd d}|d}| |jd d S )Nc                   @      e Zd ZU eed< dS )z-TestCase.test_one_field_no_default.<locals>.CxNr   r   r   int__annotations__r   r   r   r   r   -      
 r   *   r!   r"   r.   r%   r   r   r   test_one_field_no_default,   s   z"TestCase.test_one_field_no_defaultc                 C   sH   d}|  t| tG dd d}W d    d S 1 sw   Y  d S )Nz/cannot specify both default and default_factoryc                   @   s"   e Zd ZU ededZeed< dS )z<TestCase.test_field_default_default_factory_error.<locals>.C   defaultdefault_factoryr.   N)r   r   r   fieldr0   r.   r1   r   r   r   r   r   7      
 r   )assertRaisesRegex
ValueErrorr!   )r&   msgr   r   r   r   (test_field_default_default_factory_error4   s
   "z1TestCase.test_field_default_default_factory_errorc                 C   s>   t dddd}d|_t|}dtdtd}| || d S )	Nr6   TF)r8   initrepridz4Field(name='id',type=None,default=1,default_factory=zO,init=True,repr=False,hash=None,compare=True,metadata=mappingproxy({}),kw_only=z,_field_type=None))r:   namerA   MISSINGr"   )r&   Z	int_fieldrepr_outputZexpected_outputr   r   r   test_field_repr;   s   zTestCase.test_field_reprc                 C   s*   t  }||_d|_t|}| d| d S )NrB   
,type=...,)r:   typerC   rA   assertIn)r&   Z	rec_fieldrE   r   r   r   test_field_recursive_reprH   s
   z"TestCase.test_field_recursive_reprc                 C   s:   G dd d}t G dd d}| dt|jd  d S )Nc                   @   r   )z-TestCase.test_recursive_annotation.<locals>.CNr   r   r   r   r   r   Q       r   c                   @   s   e Zd ZU e Zeed< dS )z-TestCase.test_recursive_annotation.<locals>.Dr   N)r   r   r   r:   r   r1   r   r   r   r   DT      
 rL   rG   )r!   rI   rA   __dataclass_fields__r&   r   rL   r   r   r   test_recursive_annotationP   s   z"TestCase.test_recursive_annotationc                 C   s.   t G dd d}|dd}| |jd d S )Nc                   @   r-   )z*TestCase.test_named_init_params.<locals>.Cr.   Nr/   r   r   r   r   r   [   r2   r       r.   r4   r%   r   r   r   test_named_init_paramsZ   s   
zTestCase.test_named_init_paramsc                 C   s  t G dd d}|d}| |j|jfd | td t G dd d}W d    n1 s1w   Y  | td t G dd d}t G d	d d|}W d    n1 sZw   Y  | td t G d
d d}t G dd d|}W d    d S 1 sw   Y  d S )Nc                   @   "   e Zd ZU eed< dZeed< dS )/TestCase.test_two_fields_one_default.<locals>.Cr.   r   yNr   r   r   r0   r1   rV   r   r   r   r   r   c      
 r      )rY   r   z1non-default argument 'y' follows default argumentc                   @   s"   e Zd ZU dZeed< eed< dS )rU   r   r.   rV   Nr   r   r   r.   r0   r1   r   r   r   r   r   o      
 c                   @      e Zd ZU dZeed< dS )/TestCase.test_two_fields_one_default.<locals>.Br   r.   NrZ   r   r   r   r   Bx      
 r^   c                   @   r-   )rU   rV   Nr/   r   r   r   r   r   |   r2   c                   @      e Zd ZU eed< eed< dS )r]   r.   rV   Nr/   r   r   r   r   r^         
 c                   @   r\   )rU   r   r.   NrZ   r   r   r   r   r      r_   )r!   r"   r.   rV   r<   	TypeError)r&   r   r'   r^   r   r   r   test_two_fields_one_defaultb   s4   	"z$TestCase.test_two_fields_one_defaultc                 C   s  t ddG dd d}| t|dd t ddG dd d}| t|dtd | td	 t dd
G dd d}W d    n1 sKw   Y  t dd
G dd d}| t|dtd | td	 t dd
G dd d}W d    d S 1 sw   Y  d S )NTfrozenc                   @      e Zd ZU eed< dd ZdS )'TestCase.test_overwrite_hash.<locals>.Cr.   c                 S      dS N-  r   r&   r   r   r   __hash__      0TestCase.test_overwrite_hash.<locals>.C.__hash__N)r   r   r   r0   r1   rl   r   r   r   r   r      ra   r   d   rj   c                   @   rf   )rg   r.   c                 S   rh   NFr   r&   otherr   r   r   __eq__   rm   .TestCase.test_overwrite_hash.<locals>.C.__eq__Nr   r   r   r0   r1   rs   r   r   r   r   r      ra   )ro   #Cannot overwrite attribute __hash__unsafe_hashc                   @      e Zd Zdd ZdS )rg   c                 S      d S Nr   rk   r   r   r   rl      rm   rn   Nr   r   r   rl   r   r   r   r   r          c                   @   rf   )rg   r.   c                 S   rz   r{   r   rk   r   r   r   rs      rm   rt   Nru   r   r   r   r   r      ra   
   )r~   c                   @   s&   e Zd ZU eed< dd Zdd ZdS )rg   r.   c                 S   rz   r{   r   rk   r   r   r   rs      rm   rt   c                 S   rz   r{   r   rk   r   r   r   rl      rm   rn   N)r   r   r   r0   r1   rs   rl   r   r   r   r   r      s   
 )r!   r"   hashr<   rb   r&   r   r   r   r   test_overwrite_hash   s*   "zTestCase.test_overwrite_hashc                 C   sp   t G dd d}t G dd d|}| }| t|d | }| t|d |dd}| t|d	 d S )
Nc                   @   s&   e Zd ZU dZeed< dZeed< dS )z=TestCase.test_overwrite_fields_in_derived_class.<locals>.Baseg      .@r.   r   rV   N)r   r   r   r.   r   r1   rV   r0   r   r   r   r   Base      
 r   c                   @   &   e Zd ZU dZeed< dZeed< dS )z;TestCase.test_overwrite_fields_in_derived_class.<locals>.C1r~   z   r.   N)r   r   r   r   r0   r1   r.   r   r   r   r   C1   r   r   zJTestCase.test_overwrite_fields_in_derived_class.<locals>.Base(x=15.0, y=0)zLTestCase.test_overwrite_fields_in_derived_class.<locals>.C1(x=15, y=0, z=10)   rR   zKTestCase.test_overwrite_fields_in_derived_class.<locals>.C1(x=5, y=0, z=10)r!   r"   rA   )r&   r   r   r'   r   r   r   &test_overwrite_fields_in_derived_class   s   
z/TestCase.test_overwrite_fields_in_derived_classc                 C   s   t G dd d}|d}| |jd t|j}tt|j}| 	d| t G dd d}t|j}tt|j}| d| d S )Nc                   @   r-   ))TestCase.test_field_named_self.<locals>.Cr&   Nr   r   r   strr1   r   r   r   r   r      r2   r   foor&   c                   @   r-   )r   ZselfxNr   r   r   r   r   r      r2   )
r!   r"   r&   inspect	signature__init__nextiter
parametersassertNotEqual)r&   r   csigfirstr   r   r   test_field_named_self   s   zTestCase.test_field_named_selfc                 C   r,   )Nc                   @   r-   )z+TestCase.test_field_named_object.<locals>.CobjectNr   r   r   r   r   r      r2   r   r   r!   r"   r   r&   r   r   r   r   r   test_field_named_object   s   z TestCase.test_field_named_objectc                 C   2   t ddG dd d}|d}| |jd d S )NTrd   c                   @   r-   )z2TestCase.test_field_named_object_frozen.<locals>.Cr   Nr   r   r   r   r   r      r2   r   r   r   r   r   r   r   test_field_named_object_frozen   s   z'TestCase.test_field_named_object_frozenc                 C   r   )NTrd   c                   @   r-   )z4TestCase.test_field_named_BUILTINS_frozen.<locals>.CBUILTINSNr/   r   r   r   r   r      r2   r   r   )r!   r"   r   r   r   r   r    test_field_named_BUILTINS_frozen   s   z)TestCase.test_field_named_BUILTINS_frozenc                    sn   h d t  fddtj D }dd |D }td|}|dd |D  }|D ]}| t||| q)d S )N>   NoneTrueFalsec                 3   &    | ]}| d s| vr|V  qdS __N
startswith.0bZ
exclusionsr   r   	<genexpr>
      z9TestCase.test_field_named_like_builtin.<locals>.<genexpr>c                 S      g | ]}|t fqS r   r   r   rC   r   r   r   
<listcomp>      z:TestCase.test_field_named_like_builtin.<locals>.<listcomp>r   c                 S      g | ]}|qS r   r   r   r   r   r   r         sortedbuiltins__dict__keysmake_dataclassr"   getattrr&   Zbuiltins_namesZ
attributesr   r   rC   r   r   r   test_field_named_like_builtin  s   
z&TestCase.test_field_named_like_builtinc                    sr   h d t  fddtj D }dd |D }td|dd}|d	d |D  }|D ]}| t||| q+d S )
N>   r   r   r   c                 3   r   r   r   r   r   r   r   r     r   z@TestCase.test_field_named_like_builtin_frozen.<locals>.<genexpr>c                 S   r   r   r   r   r   r   r   r      r   zATestCase.test_field_named_like_builtin_frozen.<locals>.<listcomp>r   Trd   c                 S   r   r   r   r   r   r   r   r   #  r   r   r   r   r   r   $test_field_named_like_builtin_frozen  s   z-TestCase.test_field_named_like_builtin_frozenc                 C   sR  t G dd d}t ddG dd d}||fD ]q}| j|da | | |  tdd	 d
d	 dd	 dd	 gD ]@\}}| j|d. | td|j d|j d || |  W d    n1 sfw   Y  W d    n1 suw   Y  q:W d    n1 sw   Y  qt ddG dd d}| | |  | | |  d S )Nc                   @   r   )z)TestCase.test_0_field_compare.<locals>.C0Nr   r   r   r   r   C0*  r   r   Forderc                   @   r   )z)TestCase.test_0_field_compare.<locals>.C1Nr   r   r   r   r   r   .  r   r   clsc                 S      | |k S r{   r   ar   r   r   r   <lambda>5      z/TestCase.test_0_field_compare.<locals>.<lambda>c                 S      | |kS r{   r   r   r   r   r   r   6  r   c                 S      | |kS r{   r   r   r   r   r   r   7  r   c                 S      | |kS r{   r   r   r   r   r   r   8  r   idx$not supported between instances of '' and ''Tc                   @   r   )z(TestCase.test_0_field_compare.<locals>.CNr   r   r   r   r   r   >  r   r   )	r!   subTestr"   	enumerater<   rb   r   assertLessEqualassertGreaterEqualr&   r   r   r   r   fnr   r   r   r   test_0_field_compare(  s8   zTestCase.test_0_field_comparec                 C   s  t G dd d}t ddG dd d}||fD ]}| j|do | |d|d | |d	|d td
d dd dd dd gD ]B\}}| j|d0 | td|j d|j d ||d	|d	 W d    n1 stw   Y  W d    n1 sw   Y  qFW d    n1 sw   Y  qt ddG dd d}| |d	|d | 	|d	|d | 	|d|d | 
|d|d	 | |d|d	 | |d|d d S )Nc                   @   r-   )z)TestCase.test_1_field_compare.<locals>.C0r.   Nr/   r   r   r   r   r   F  r2   r   Fr   c                   @   r-   )z)TestCase.test_1_field_compare.<locals>.C1r.   Nr/   r   r   r   r   r   J  r2   r   r   r6   r   c                 S   r   r{   r   r   r   r   r   r   R  r   z/TestCase.test_1_field_compare.<locals>.<lambda>c                 S   r   r{   r   r   r   r   r   r   S  r   c                 S   r   r{   r   r   r   r   r   r   T  r   c                 S   r   r{   r   r   r   r   r   r   U  r   r   r   r   r   Tc                   @   r-   )z(TestCase.test_1_field_compare.<locals>.Cr.   Nr/   r   r   r   r   r   [  r2   r   )r!   r   r"   r   r   r<   rb   r   
assertLessr   assertGreaterr   r   r   r   r   test_1_field_compareD  sB   zTestCase.test_1_field_comparec                 C   sF  t G dd d}t ddG dd d}||fD ]}| j|d | |dd|dd | |d	d
|d	d
 | |d	d|dd | |d	d|d	d	 tdd dd dd dd gD ]D\}}| j|d2 | td|j d|j d ||dd|dd W d    n1 sw   Y  W d    n1 sw   Y  qbW d    n1 sw   Y  qt ddG dd d}tdd dd dd gD ](\}}| j|d | ||dd|dd W d    n1 sw   Y  qtdd dd dd gD ]F\}}| j|d2 | ||dd|dd	 | ||dd	|d	d | ||d	d|d	d	 W d    n	1 sFw   Y  qtdd dd dd gD ]F\}}| j|d2 | ||dd	|dd | ||d	d|dd	 | ||d	d	|d	d W d    n	1 sw   Y  qZd S ) Nc                   @   r`   )z(TestCase.test_simple_compare.<locals>.C0r.   rV   Nr/   r   r   r   r   r   g  ra   r   Fr   c                   @   r`   )z(TestCase.test_simple_compare.<locals>.C1r.   rV   Nr/   r   r   r   r   r   l  ra   r   r   r   r6      c                 S   r   r{   r   r   r   r   r   r   w  r   z.TestCase.test_simple_compare.<locals>.<lambda>c                 S   r   r{   r   r   r   r   r   r   x  r   c                 S   r   r{   r   r   r   r   r   r   y  r   c                 S   r   r{   r   r   r   r   r   r   z  r   r   r   r   r   Tc                   @   r`   )z'TestCase.test_simple_compare.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   c                 S      | |kS r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S      | |kS r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   )	r!   r   r"   r   r   r<   rb   r   
assertTruer   r   r   r   test_simple_comparee  st   zTestCase.test_simple_comparec              
   C   s.  t G dd d}t G dd d|}tdd dfdd d	fgD ])\}\}}| j|d
 | ||d|d| W d    n1 sEw   Y  q!tdd dd dd dd gD ]9\}}| j|d
' | td ||d|d W d    n1 sw   Y  W d    n1 sw   Y  q[d S )Nc                   @   r-   )z+TestCase.test_compare_subclasses.<locals>.Br*   Nr/   r   r   r   r   r^     r2   r^   c                   @   r   )z+TestCase.test_compare_subclasses.<locals>.CNr   r   r   r   r   r     r   r   c                 S   r   r{   r   r   r   r   r   r     r   z2TestCase.test_compare_subclasses.<locals>.<lambda>Fc                 S   r   r{   r   r   r   r   r   r     r   Tr   r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   c                 S   r   r{   r   r   r   r   r   r     r   z.not supported between instances of 'B' and 'C')r!   r   r   r"   r<   rb   )r&   r^   r   r   r   expectedr   r   r   test_compare_subclasses  s4   
z TestCase.test_compare_subclassesc              
   C   s  dD ]\}}}| j ||d |dkr7| td t||dG dd d}W d    n1 s1w   Y  nt||dG dd d}|dkrl| d	|j | d
|j | d|j | d|j | d|j nO|dkr| d	|j | d
|j | d|j | d|j | d|j n'|dkr| d	|j | d
|j | d|j | d|j | d|j W d    n1 sw   Y  qd S )N))FFneither)FT	exception)TFeq_only)TTboth)eqr   r   z eq must be true if order is truec                   @   r   z!TestCase.test_eq_order.<locals>.CNr   r   r   r   r   r     r   r   c                   @   r   r   r   r   r   r   r   r     r   r   rs   __lt____le____gt____ge__r   r   )r   r<   r=   r!   assertNotInr   rI   )r&   r   r   resultr   r   r   r   test_eq_order  s@   

zTestCase.test_eq_orderc                 C   s\   t G dd d}| |djd | td |  W d    d S 1 s'w   Y  d S )Nc                   @   s   e Zd ZU e Zeed< dS )z)TestCase.test_field_no_default.<locals>.Cr.   Nr   r   r   r:   r.   r0   r1   r   r   r   r   r     rM   r   r   8__init__\(\) missing 1 required positional argument: 'x')r!   r"   r.   r<   rb   r   r   r   r   test_field_no_default  s   "zTestCase.test_field_no_defaultc                    sf   t   tG  fddd}| |j  |d}| |jd |`| |j  | | j  d S )Nc                           e Zd ZU e dZeed< dS )z&TestCase.test_field_default.<locals>.Cr8   r.   N)r   r   r   r:   r.   r   r1   r   r   r   r   r        
 r   r~   )r   r!   assertIsr.   r"   r   r   r   r   test_field_default  s   zTestCase.test_field_defaultc                 C   s   t G dd d}| t |  W d    n1 sw   Y  |d}| t|d t G dd d}|dd}| t|d d S )Nc                   @       e Zd ZU eddZeed< dS )$TestCase.test_not_in_repr.<locals>.CFrA   r.   Nr   r   r   r   r   r     r   r   r~   z&TestCase.test_not_in_repr.<locals>.C()c                   @   s(   e Zd ZU eddZeed< eed< dS )r   Fr   r.   rV   Nr   r   r   r   r   r     s   
    z*TestCase.test_not_in_repr.<locals>.C(y=20))r!   assertRaisesrb   r"   rA   r   r   r   r   test_not_in_repr  s   
zTestCase.test_not_in_reprc                 C   sp   t G dd d}| | |dd | |dd|dd | |d|dd | |dd|dd d S )	Nc                   @   s.   e Zd ZU dZeed< edddZeed< dS )z'TestCase.test_not_in_compare.<locals>.Cr   r.   F   )comparer8   rV   N)r   r   r   r.   r0   r1   r:   rV   r   r   r   r   r   
  s   
 r   r   r   r6   r~   rY   r   r!   r"   r   r   r   r   r   test_not_in_compare	  s   zTestCase.test_not_in_comparec              	      s   dD ]L\ }| j  d8 tddG  fddd}|dkr/| t|dtd	 n|d
kr?| t|dtd W d    n1 sIw   Y  qd S )N))TFr:   )TTr:   )FFabsent)FTr  )NFr  )NTr:   )r   r   Trw   c                       s$   e Zd ZU e ddZeed< dS )z)TestCase.test_hash_field_rules.<locals>.Cr   )r   r   r8   r.   Nr   r   r   Zhash_r   r   r   !     
 r   r:   r   )r   r  r   )r   r!   r"   r   )r&   r   r   r   r  r   test_hash_field_rules  s   zTestCase.test_hash_field_rulesc                 C   sf   t G dd d}| d| j t G dd d}| d|dj | t|ddddd	 d S )
Nc                   @   r   ).TestCase.test_init_false_no_default.<locals>.CFr@   r.   Nr   r   r   r   r   r   1  r   r   r.   c                   @   s@   e Zd ZU eed< dZeed< eddZeed< dZeed< d	S )
r  r.   r   rV   Fr  r   r~   tN)	r   r   r   r0   r1   rV   r:   r   r	  r   r   r   r   r   7  s
   
 r   r   r   r~   )r	  r.   rV   )r!   r   r   r"   varsr   r   r   r   test_init_false_no_default.  s    z#TestCase.test_init_false_no_defaultc                 C   s`  t G dd d}t|}| |t |D ]}| t|t | |j|j	 q| 
t|d | 
|d jd | 
|d jt | t|d | |d j | |d j | 
|d jd | 
|d jt | t|d | |d j | |d j | 
|d jd	 | 
|d jt | t|d	 | |d j | |d j d S )
Nc                   @   s<   e Zd ZU eed< edddZeed< eddZeed< dS )z%TestCase.test_class_marker.<locals>.Cr.   FNr@   r8   rV   r   r   )	r   r   r   r0   r1   r:   rV   r   r   r   r   r   r   r   B  s   
 r   rY   r   r.   r6   rV   r   r   )r!   r$   assertIsInstancetupler   rH   ZFieldrI   rC   r1   r"   r#   r0   assertFalsehasattrr   r@   rA   r   assertIsNoner   )r&   r   Z
the_fieldsfr   r   r   test_class_markerA  s.   zTestCase.test_class_markerc                 C   s   t G dd d}t G dd d|}| dd t|D g d t G dd	 d	|}| d
d t|D g d t G dd d|}| dd t|D g d d S )Nc                   @   s2   e Zd ZU dZeed< dZeed< dZeed< dS )z$TestCase.test_field_order.<locals>.BB:ar   B:br   B:cr   N)r   r   r   r   r   r1   r   r   r   r   r   r   r^   c     
 r^   c                   @   r\   )z$TestCase.test_field_order.<locals>.CC:br   N)r   r   r   r   r   r1   r   r   r   r   r   i  r_   r   c                 S      g | ]}|j |jfqS r   rC   r8   r   r  r   r   r   r   m      z-TestCase.test_field_order.<locals>.<listcomp>)r   r  )r   r  )r   r  c                   @   r\   )z$TestCase.test_field_order.<locals>.DD:cr   N)r   r   r   r   r   r1   r   r   r   r   rL   r  r_   rL   c                 S   r  r   r  r  r   r   r   r   v  r  )r  r   r  r   r  c                   @   r   )z$TestCase.test_field_order.<locals>.EE:ar   E:ddN)r   r   r   r   r   r1   r#  r   r   r   r   E{  r   r$  c                 S   r  r   r  r  r   r   r   r     r  ))r   r!  r  r   )r#  r"  r!   r"   r$   )r&   r^   r   rL   r$  r   r   r   test_field_orderb  s"   zTestCase.test_field_orderc                    s\   t   tG  fddd}| t|d | t|d | |j  | |jd d S )Nc                       sF   e Zd ZU eed< eddZeed<  Zeed< eddZ	eed< d	S )
z$TestCase.test_class_attrs.<locals>.Cr.   Fr   rV   r   ro   r   r	  N)
r   r   r   r0   r1   r:   rV   r   r   r	  r   r   r   r   r     s
   
 r   r.   rV   ro   )r   r!   r  r  r   r   r"   r	  r   r   r   r   test_class_attrs  s   zTestCase.test_class_attrsc              
      s  t g dgfti ddiftt tdgffD ]\| jd | td d tG fddd}W d    n1 sBw   Y  | td d tG fd	dd}W d    n1 shw   Y  G d
d d | td tG  fddd}W d    n1 sw   Y  tG fddd}tG  fddd}W d    n1 sw   Y  qd S )Nr6   r   typzmutable default z for field x is not allowedc                          e Zd ZU  Zed< dS )8TestCase.test_disallowed_mutable_defaults.<locals>.Pointr.   N)r   r   r   r.   r1   r   )emptyr)  r   r   Point  r_   r-  z for field y is not allowedc                       r*  )r+  rV   N)r   r   r   rV   r1   r   )	non_emptyr)  r   r   r-    r_   c                   @   r   )z;TestCase.test_disallowed_mutable_defaults.<locals>.SubclassNr   r   r   r   r   Subclass  r   r/  z7mutable default .*Subclass'> for field z is not allowedc                       s   e Zd ZU   Zed< dS )r+  r   N)r   r   r   r   r1   r   r/  r)  r   r   r-    rM   c                       s    e Zd ZU   Ze  ed< dS )4TestCase.test_disallowed_mutable_defaults.<locals>.Cr   N)r   r   r   r   r   r1   r   r(  r   r   r     r   r   c                       s    e Zd ZU   Ze ed< dS )r1  r.   N)r   r   r   r.   r   r1   r   r0  r   r   r     r   )listdictsetr   r<   r=   r!   r&   r-  r   r   )r/  r,  r.  r)  r    test_disallowed_mutable_defaults  s>   

	
	z)TestCase.test_disallowed_mutable_defaultsc                    s   G dd d t G  fddd}  }||}||}| || |jjddg | || | |jjddg | |j|j d S )Nc                   @   ry   )z<TestCase.test_deliberately_mutable_defaults.<locals>.Mutablec                 S   s
   g | _ d S r{   lrk   r   r   r   r        
zETestCase.test_deliberately_mutable_defaults.<locals>.Mutable.__init__Nr   r   r   r   r   r   r   r   Mutable      r;  c                          e Zd ZU  ed< dS )z6TestCase.test_deliberately_mutable_defaults.<locals>.Cr.   Nr   r   r   r1   r   r;  r   r   r     r2   r   r6   r   )r!   r"   r.   r8  extendr   )r&   r   lstZo1Zo2r   r?  r   "test_deliberately_mutable_defaults  s   z+TestCase.test_deliberately_mutable_defaultsc                 C   s*   t  G dd d}| |djd d S )Nc                   @   r-   )z#TestCase.test_no_options.<locals>.Cr.   Nr/   r   r   r   r   r     r2   r   r3   r4   r   r   r   r   test_no_options  s   zTestCase.test_no_optionsc                 C   sR   t G dd d}| |ddd t G dd d}| |dd|dd d S )	Nc                   @   r`   )z&TestCase.test_not_tuple.<locals>.Pointr.   rV   Nr/   r   r   r   r   r-    ra   r-  r6   r   r6   r   c                   @   r`   )z"TestCase.test_not_tuple.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   rY   )r!   r   r5  r   r   r   test_not_tuple  s   zTestCase.test_not_tuplec                 C   s   t G dd d}t G dd d}| |ddd|ddd | |dd	dd
 | td |ddd\}}}W d    n1 sDw   Y  t G dd d}| |ddd|  d S )Nc                   @   &   e Zd ZU eed< eed< eed< dS )z2TestCase.test_not_other_dataclass.<locals>.Point3Dr.   rV   r   Nr/   r   r   r   r   Point3D     
 rG  c                   @   rF  )z/TestCase.test_not_other_dataclass.<locals>.DateyearmonthdayNr/   r   r   r   r   Date  rH  rL  i     rY   r6   r   )r6   r   rY   unpackr   r   c                   @   s2   e Zd ZU dZeed< dZeed< dZeed< dS )z4TestCase.test_not_other_dataclass.<locals>.Point3Dv1r   r.   rV   r   N)r   r   r   r.   r0   r1   rV   r   r   r   r   r   	Point3Dv1  r  rO  r   )r!   r   r<   rb   )r&   rG  rL  r.   rV   r   rO  r   r   r   test_not_other_dataclass  s   z!TestCase.test_not_other_dataclassc                    sn   G dd d    fdd}t G  fddd}|| t dddG  fd	dd}|| d S )
Nc                   @   r   )z-TestCase.test_function_annotations.<locals>.FNr   r   r   r   r   F  rK   rQ  c                    s   | jd t  | jd t  | jd    | jd t  | jd t t| j}	|j
d  t|j }t|} |jd t|} |jd 	|jt  |jtjj  |jtjj t|} |jd 	|jt  |jtjj  |jtjj t|} |jd 	|j   |jtjj t|} |jd 	|jt  |jtjj tt| d S )Nr*   jkr8  r   r&   )r"   r1   r0   r   floatcomplexr   r   r   r   Zreturn_annotationr   r   valuesr   rC   
annotationr8   Z	Parameterr,  kindZPOSITIONAL_OR_KEYWORDr   StopIteration)r   r   paramsZparam)rQ  r&   r   r   validate_class  s:   z:TestCase.test_function_annotations.<locals>.validate_classc                       P   e Zd ZU eed< eed< Z ed< eddZe	ed< eddd	Z
eed
< dS z-TestCase.test_function_annotations.<locals>.Cr*   rR  rS  Nr   r8  y      @      @Fr8   r@   r   r   r   r   r0   r1   r   rS  r:   r8  rT  r   rU  r   rQ  r  r   r   r   ?     
 r   T)re   rx   c                       r\  r]  r_  r   r`  r   r   r   J  ra  )r!   )r&   r[  r   r   )rQ  r  r&   r   test_function_annotations  s   +
z"TestCase.test_function_annotationsc                 C      t G dd d}| td |  W d    n1 sw   Y  | d|j t G dd d}| td |  W d    n1 sFw   Y  | d|j d S )Nc                   @       e Zd ZU eedZeed< dS )z(TestCase.test_missing_default.<locals>.Cr   r.   Nr   r   r   r:   rD   r.   r0   r1   r   r   r   r   r   W  r   r   3__init__\(\) missing 1 required positional argumentr.   c                   @   r-   )z(TestCase.test_missing_default.<locals>.Dr.   Nr/   r   r   r   r   rL   `  r2   rL   r!   r<   rb   r   r   rO   r   r   r   test_missing_defaultT  s    zTestCase.test_missing_defaultc                 C   rc  )Nc                   @   rd  )z0TestCase.test_missing_default_factory.<locals>.Cr9   r.   Nre  r   r   r   r   r   m  r   r   rf  r.   c                   @   s"   e Zd ZU eeedZeed< dS )z0TestCase.test_missing_default_factory.<locals>.Dr7   r.   Nre  r   r   r   r   rL   v  r;   rL   rg  rO   r   r   r   test_missing_default_factoryi  s    z%TestCase.test_missing_default_factoryc                 C   s   |  dtt d S )NzMISSING_TYPE object)rI   rA   rD   rk   r   r   r   test_missing_repr     zTestCase.test_missing_reprc                 C   sb   t G dd d}| t|jdg | |d d | |djd | |djd d S )Nc                   @   s6   e Zd ZU eed< defddZedefddZdS )z7TestCase.test_dont_include_other_annotations.<locals>.Cr*   returnc                 S   rh   Nr   r   rk   r   r   r   r     rm   z;TestCase.test_dont_include_other_annotations.<locals>.C.fooc                 S   rh   Nr   r   rk   r   r   r   bar     z;TestCase.test_dont_include_other_annotations.<locals>.C.barN)r   r   r   r0   r1   r   propertyrp  r   r   r   r   r     s
   
 r   r*   r~   r   r   )r!   r"   r2  r1   r   rp  r*   r   r   r   r   #test_dont_include_other_annotations  s   z,TestCase.test_dont_include_other_annotationsc                 C   s,  t G dd d}| t |  W d    n1 sw   Y  t G dd d}| t |  W d    n1 s=w   Y  |d t ddG dd d}|  t G dd d}| | jd	 | |d
jd t ddG dd d}| t |  W d    d S 1 sw   Y  d S )Nc                   @   ry   )"TestCase.test_post_init.<locals>.Cc                 S      t  r{   r   rk   r   r   r   __post_init__     0TestCase.test_post_init.<locals>.C.__post_init__Nr   r   r   rw  r   r   r   r   r     r}   r   c                   @   "   e Zd ZU dZeed< dd ZdS )rt  r~   r*   c                 S   s   | j dkrt d S Nr~   )r*   r   rk   r   r   r   rw    s   
ry  N)r   r   r   r*   r0   r1   rw  r   r   r   r   r     r[   r   Fr  c                   @   ry   )rt  c                 S   ru  r{   rv  rk   r   r   r   rw    rx  ry  Nrz  r   r   r   r   r     r}   c                   @   r{  )rt  r   r.   c                 S      |  j d9  _ d S Nr   rR   rk   r   r   r   rw       ry  Nr   r   r   r.   r0   r1   rw  r   r   r   r   r     r[   r   r   r   Trd   c                   @   r{  )rt  r   r.   c                 S   r}  r~  rR   rk   r   r   r   rw    r  ry  Nr  r   r   r   r   r     r[   )r!   r   r   r"   r.   FrozenInstanceErrorr   r   r   r   test_post_init  s.   "zTestCase.test_post_initc                 C   s   G dd d}t G dd d|}| | jd t G dd d|}| t |  W d    n1 s6w   Y  t G dd d|}| t |  W d    d S 1 sYw   Y  d S )Nc                   @   ry   )z(TestCase.test_post_init_super.<locals>.Bc                 S   ru  r{   rv  rk   r   r   r   rw    rx  z6TestCase.test_post_init_super.<locals>.B.__post_init__Nrz  r   r   r   r   r^     r<  r^   c                   @   ry   )(TestCase.test_post_init_super.<locals>.Cc                 S   
   d| _ d S ro  rR   rk   r   r   r   rw    r9  6TestCase.test_post_init_super.<locals>.C.__post_init__Nrz  r   r   r   r   r     r}   r   r   c                       s   e Zd Z fddZ  ZS )r  c                    s   t    d S r{   )superrw  rk   	__class__r   r   rw       r  )r   r   r   rw  __classcell__r   r   r  r   r     s    c                   @   r   )r  Nr   r   r   r   r   r     r   )r!   r"   r.   r   r   r&   r^   r   r   r   r   test_post_init_super  s   "zTestCase.test_post_init_superc                    sP   d t G  fddd}|   |dd}| |j|jfd |   d S )NFc                       s.   e Zd ZU eed< eed< e fddZdS )z/TestCase.test_post_init_staticmethod.<locals>.Cr.   rV   c                      s   d d S NTr   r   flagr   r   rw    s   z=TestCase.test_post_init_staticmethod.<locals>.C.__post_init__N)r   r   r   r0   r1   staticmethodrw  r   r  r   r   r     s
   
 r   rY   r   rY   r   )r!   r  r"   r.   rV   r   r   r   r  r   test_post_init_staticmethod  s   

z$TestCase.test_post_init_staticmethodc                 C   sL   t G dd d}| |j |dd}| |j|jfd | |j d S )Nc                   @   s.   e Zd ZU dZeed< eed< edd ZdS )z.TestCase.test_post_init_classmethod.<locals>.CFr.   rV   c                 S   r  r  r  r   r   r   r   rw    s   
z<TestCase.test_post_init_classmethod.<locals>.C.__post_init__N)r   r   r   r  r0   r1   classmethodrw  r   r   r   r   r     s   
 r   rY   r   r  )r!   r  r  r"   r.   rV   r   r   r   r   r   test_post_init_classmethod  s   
z#TestCase.test_post_init_classmethodc                 C   s   t G dd d}|d}| t|d | tt|d | t|jd | |jd | |jd | |jd	 | |j	d
 | jd7  _| |jd |d}| |j
|jfd | |jd | |jd | |jd	 | |j	d
 d S )Nc                   @   s^   e Zd ZU eed< dZeed< dZee ed< dZee ed< dZ	ee ed	< d
Z
eed< dS )z"TestCase.test_class_var.<locals>.Cr.   r~   rV     r     w  r	    sN)r   r   r   r0   r1   rV   r   r   r  r	  r  r   r   r   r   r     s   
 r   r   z-TestCase.test_class_var.<locals>.C(x=5, y=10)r   rM  r  r  r  r  r6     r   r   r~   )r!   r"   rA   r#   r$   r1   r   r  r	  r  r.   rV   r   r   r   r   test_class_var  s$   zTestCase.test_class_varc                 C   $   t G dd d}| d|j d S )Nc                   @      e Zd ZU ee ed< dS )z-TestCase.test_class_var_no_default.<locals>.Cr.   N)r   r   r   r   r0   r1   r   r   r   r   r     r_   r   r.   r!   r   r   r   r   r   r   test_class_var_no_default     z"TestCase.test_class_var_no_defaultc                 C   R   |  td tG dd d}| d|j W d    d S 1 s"w   Y  d S )Ncannot have a default factoryc                   @   $   e Zd ZU eedZee ed< dS )z2TestCase.test_class_var_default_factory.<locals>.Cri  r.   Nr   r   r   r:   r0   r.   r   r1   r   r   r   r   r   &  r  r   r.   r<   rb   r!   r   r   r   r   r   r   test_class_var_default_factory!     "z'TestCase.test_class_var_default_factoryc                 C   D   t G dd d}| |jd t G dd d}| |jd d S )Nc                   @      e Zd ZU dZee ed< dS )/TestCase.test_class_var_with_default.<locals>.Cr~   r.   N)r   r   r   r.   r   r0   r1   r   r   r   r   r   .     
 r   r~   c                   @   $   e Zd ZU eddZee ed< dS )r  r~   r   r.   N)r   r   r   r:   r.   r   r0   r1   r   r   r   r   r   3  r  r4   r   r   r   r   test_class_var_with_default,     z$TestCase.test_class_var_with_defaultc                 C   s   t ddG dd d}|d}| t|dd | tt|d | t|jd | |jd | |jd	 | |jd
 | jd7  _| |jd |d}| |j	|j
fd | |jd | |jd	 | |jd
 d S )NTrd   c                   @   sR   e Zd ZU eed< dZeed< dZee ed< dZee ed< dZ	ee ed	< d
S )z)TestCase.test_class_var_frozen.<locals>.Cr.   r~   rV   r  r   r  r  r  r	  N)
r   r   r   r0   r1   rV   r   r   r  r	  r   r   r   r   r   :  s   
 r   r   z4TestCase.test_class_var_frozen.<locals>.C(x=5, y=10)r   r  r  r  r6   r  r   r  )r!   r"   rA   r#   r$   r1   r   r  r	  r.   rV   r   r   r   r   test_class_var_frozen8  s    zTestCase.test_class_var_frozenc                 C   r  )Nc                   @   r  )z,TestCase.test_init_var_no_default.<locals>.Cr.   N)r   r   r   InitVarr0   r1   r   r   r   r   r   U  r_   r   r.   r  r   r   r   r   test_init_var_no_defaultS  r  z!TestCase.test_init_var_no_defaultc                 C   r  )Nr  c                   @   r  )z1TestCase.test_init_var_default_factory.<locals>.Cri  r.   N)r   r   r   r:   r0   r.   r  r1   r   r   r   r   r   `  r  r   r.   r  r   r   r   r   test_init_var_default_factory[  r  z&TestCase.test_init_var_default_factoryc                 C   r  )Nc                   @   r  ).TestCase.test_init_var_with_default.<locals>.Cr~   r.   N)r   r   r   r.   r  r0   r1   r   r   r   r   r   h  r  r   r~   c                   @   r  )r  r~   r   r.   N)r   r   r   r:   r.   r  r0   r1   r   r   r   r   r   m  r  r4   r   r   r   r   test_init_var_with_defaultf  r  z#TestCase.test_init_var_with_defaultc                 C   s.   t G dd d}|dd}| |jd d S )Nc                   @   s2   e Zd ZU dZeed< dZee ed< dd ZdS )z!TestCase.test_init_var.<locals>.CNr.   
init_paramc                 S   s   | j d u r|d | _ d S d S r~  rR   )r&   r  r   r   r   rw  x  s   
z/TestCase.test_init_var.<locals>.C.__post_init__)	r   r   r   r.   r0   r1   r  r  rw  r   r   r   r   r   s  s   
 r   r~   )r  r   r4   r   r   r   r   test_init_varr  s   
zTestCase.test_init_varc                 C   sr   |  tt jt |  ttt d |  tttt  d |  tttt  d |  ttttB  d d S )Ndataclasses.InitVar[int]z%dataclasses.InitVar[typing.List[int]]zdataclasses.InitVar[list[int]]zdataclasses.InitVar[int | str])r"   r  r0   rH   rA   r   r2  r   rk   r   r   r   test_init_var_preserve_type  s   z$TestCase.test_init_var_preserve_typec                 C   sl   t G dd d}|dd}| t|ddi t G dd d|}|ddd	d
}| t|ddd d S )Nc                   @   s"   e Zd ZU eed< ee ed< dS )z0TestCase.test_init_var_inheritance.<locals>.Baser.   	init_baseN)r   r   r   r0   r1   r  r   r   r   r   r     rX   r   r   r~   r.   c                   @   *   e Zd ZU eed< ee ed< dd ZdS )z-TestCase.test_init_var_inheritance.<locals>.CrV   init_derivedc                 S   s   | j | | _ | j| | _d S r{   r.   rV   )r&   r  r  r   r   r   rw    s   z;TestCase.test_init_var_inheritance.<locals>.C.__post_init__Nr   r   r   r0   r1   r  rw  r   r   r   r   r        
 r      2   3      e   r  )r!   r"   r
  )r&   r   r   r   r   r   r   r   test_init_var_inheritance  s   
z"TestCase.test_init_var_inheritancec                    s  t G dd d}|d}|d}| |jd | |jg  | || | |j|j | t|ddgddgf g  t G  fddd}|d}|d}| |jd | |jg  | || | |j|j | t|ddgddgf t G dd d}| t| d | | jg  t d	d
G dd d}| t| g f | t| td t G dd d}| t| g f t G dd d}| | |dg d S )Nc                   @   s(   e Zd ZU eed< eedZeed< dS )(TestCase.test_default_factory.<locals>.Cr.   ri  rV   N)r   r   r   r0   r1   r:   r2  rV   r   r   r   r   r        
 r   rY   r   r6   c                       s0   e Zd ZU eed< e fdddZeed< dS )r  r.   c                      s    S r{   r   r   r7  r   r   r         z1TestCase.test_default_factory.<locals>.C.<lambda>ri  rV   N)r   r   r   r0   r1   r:   rV   r2  r   r7  r   r   r     s   
 c                   @   "   e Zd ZU eeddZeed< dS )r  F)r9   rA   r.   Nr   r   r   r:   r2  r.   r1   r   r   r   r   r     r;   z*TestCase.test_default_factory.<locals>.C()Trw   c                   @   r  )r  F)r9   r   r.   Nr  r   r   r   r   r     r;   r   c                   @   r  )r  Fr9   r@   r.   Nr  r   r   r   r   r     r;   c                   @   r  )r  F)r9   r   r.   Nr  r   r   r   r   r     r;   )	r!   r"   r.   rV   assertIsNotastupler   rA   r   )r&   r   Zc0c1r   r7  r   test_default_factory  sB   zTestCase.test_default_factoryc                    sL   t   tG  fddd}| j |  jd | j |  jd d S )Nc                       "   e Zd ZU e ddZeed< dS )z5TestCase.test_default_factory_with_no_init.<locals>.CFr  r.   N)r   r   r   r:   r.   r2  r1   r   factoryr   r   r     r;   r   r6   r   r   r!   r.   r"   
call_countr   r   r  r   !test_default_factory_with_no_init  s   z*TestCase.test_default_factory_with_no_initc                    sl   t   tG  fddd}| j |  jd | |djd |  jd | j |  jd d S )Nc                       r   )zBTestCase.test_default_factory_not_called_if_value_given.<locals>.Cri  r.   Nr   r   r  r   r   r     r   r   r6   r~   r   r  r   r   r  r   .test_default_factory_not_called_if_value_given  s   z7TestCase.test_default_factory_not_called_if_value_givenc                 C   s~   t G dd d}t G dd d|}| | ji  | | ji  | | jd t G dd d|}| | ji  d S )Nc                   @       e Zd ZU eedZeed< dS )z2TestCase.test_default_factory_derived.<locals>.Foori  r.   N)r   r   r   r:   r3  r.   r1   r   r   r   r   Foo  r   r  c                   @   r\   )z2TestCase.test_default_factory_derived.<locals>.Barr6   rV   Nr   r   r   rV   r0   r1   r   r   r   r   Bar  r_   r  r6   c                   @   r   )z2TestCase.test_default_factory_derived.<locals>.BazNr   r   r   r   r   Baz  r   r  )r!   r"   r.   rV   )r&   r  r  r  r   r   r   test_default_factory_derived  s   z%TestCase.test_default_factory_derivedc                 C   s   t G dd d}G dd d|}t G dd d|}|dd}| |j|jfd	 | td
 |j W d    n1 s>w   Y  G dd d|}|dd}| |j|jfd d S )Nc                   @   r-   )z3TestCase.test_intermediate_non_dataclass.<locals>.Ar.   Nr/   r   r   r   r   A  r2   r  c                   @   r-   )z3TestCase.test_intermediate_non_dataclass.<locals>.BrV   Nr/   r   r   r   r   r^        
 r^   c                   @   r-   )z3TestCase.test_intermediate_non_dataclass.<locals>.Cr   Nr/   r   r   r   r   r     r2   r   r6   rY   )r6   rY   zobject has no attributec                   @   r-   )z3TestCase.test_intermediate_non_dataclass.<locals>.Dr	  Nr/   r   r   r   r   rL   (  r  rL   r   r   )r   r   )r!   r"   r.   r   r<   AttributeErrorrV   )r&   r  r^   r   r   rL   r#  r   r   r   test_intermediate_non_dataclass  s   

z(TestCase.test_intermediate_non_dataclassc                 C   D   |  td tG dd d}W d    d S 1 sw   Y  d S )Nr  c                   @   r  )z1TestCase.test_classvar_default_factory.<locals>.Cri  r.   Nr  r   r   r   r   r   1  r  r   r<   rb   r!   r   r   r   r   test_classvar_default_factory-  s   "z&TestCase.test_classvar_default_factoryc                    s   G dd d}|  td |  tt |  t| |  t|  tG dd d tG  fddd} d}||d	}| t  | t| |  t|j | t|j |  t|j d S )
Nc                   @   r   )z0TestCase.test_is_dataclass.<locals>.NotDataClassNr   r   r   r   r   NotDataClass6  rK   r  r   c                   @   r-   )z%TestCase.test_is_dataclass.<locals>.Cr.   Nr/   r   r   r   r   r   >  r2   r   c                       s   e Zd ZU  ed< eed< dS )z%TestCase.test_is_dataclass.<locals>.Dr#  eNr   r   r   r1   r0   r   r   r   r   rL   B  ra   rL   r~   r   )r  is_dataclassr0   r!   r   r.   r#  r  )r&   r  rL   r   r#  r   r  r   test_is_dataclass5  s    
zTestCase.test_is_dataclassc              
   C   s(  G dd d}|  t| | }G dd d}| }g |_||fD ]o}| j|d_ |  t| | td t| W d    n1 sGw   Y  | td t| W d    n1 saw   Y  | td t|dd W d    n1 s}w   Y  W d    n1 sw   Y  q"d S )	Nc                   @   ry   )zATestCase.test_is_dataclass_when_getattr_always_returns.<locals>.Ac                 S   rh   Nr   r   )r&   keyr   r   r   __getattr__S  rm   zMTestCase.test_is_dataclass_when_getattr_always_returns.<locals>.A.__getattr__N)r   r   r   r  r   r   r   r   r  R  r<  r  c                   @   r   )zATestCase.test_is_dataclass_when_getattr_always_returns.<locals>.BNr   r   r   r   r   r^   Y  rK   r^   )objz'should be called on dataclass instancesr   rR   )	r  r  rN   r   r<   rb   asdictr  replace)r&   r  r   r^   r   r  r   r   r   -test_is_dataclass_when_getattr_always_returnsP  s,   

z6TestCase.test_is_dataclass_when_getattr_always_returnsc                 C   sR   t G dd dtj}| t| |tt}| tt| | t| d S )Nc                   @   r`   )z2TestCase.test_is_dataclass_genericalias.<locals>.AoriginargsN)r   r   r   rH   r1   r   r   r   r   r  k  ra   r  )r!   typesGenericAliasr   r  r2  r0   rH   )r&   r  r   r   r   r   test_is_dataclass_genericaliasj  s   
z'TestCase.test_is_dataclass_genericaliasc                 C   s0   t G dd d}| t|t|dd d S )Nc                   @      e Zd ZU eed< eed< dS )z:TestCase.test_helper_fields_with_class_instance.<locals>.Cr.   rV   N)r   r   r   r0   r1   rT  r   r   r   r   r   x  ra   r   r   g        r%  r   r   r   r   &test_helper_fields_with_class_instanceu  s   z/TestCase.test_helper_fields_with_class_instancec                 C   s   |  td td W d    n1 sw   Y  G dd d}|  td t| W d    n1 s6w   Y  |  td t|  W d    d S 1 sRw   Y  d S )Nzdataclass type or instancer   c                   @   r   )z0TestCase.test_helper_fields_exception.<locals>.CNr   r   r   r   r   r     r   r   )r<   rb   r$   r   r   r   r   test_helper_fields_exception  s   

"z%TestCase.test_helper_fields_exceptionc              
   C   sl   t  }ztt W n ty# } ztj||d W Y d }~nd }~ww | }| d| | d| d S )N)filer  rN   )	ioStringIOr$   r   rb   	tracebackprint_exceptiongetvaluer   )r&   stdoutexcZprinted_tracebackr   r   r   *test_clean_traceback_from_fields_exception  s   z3TestCase.test_clean_traceback_from_fields_exceptionc                 C   s   t G dd d}|dd}| t|ddd | t|t| | t|t| d|_| t|ddd | tt|t d S )Nc                   @   r`   )z&TestCase.test_helper_asdict.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   r6   r   r  r3   )r!   r"   r  r  r.   r   rH   r3  r   r   r   r   test_helper_asdict  s   
zTestCase.test_helper_asdictc                 C      t G dd d}| td t| W d    n1 sw   Y  | td tt W d    d S 1 s9w   Y  d S )Nc                   @   r`   )z8TestCase.test_helper_asdict_raises_on_classes.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   dataclass instance)r!   r<   rb   r  r0   r   r   r   r   $test_helper_asdict_raises_on_classes     

"z-TestCase.test_helper_asdict_raises_on_classesc                 C   sx   t G dd d}g }|d|}t|}| |d | | |d | |d}t|}|d d | |jg  d S )Nc                   @   ,   e Zd ZU eed< eedZee ed< dS )z2TestCase.test_helper_asdict_copy_values.<locals>.Cr.   ri  rV   N	r   r   r   r0   r1   r:   r2  rV   r   r   r   r   r   r        
 r   r6   rV   )r!   r  r"   r  appendrV   )r&   r   initialr   r#  r   r   r   test_helper_asdict_copy_values     
z'TestCase.test_helper_asdict_copy_valuesc                    s   t G dd d t G  fddd}|d dd}t|}| |ddddd	 | t|t| d
|j_| t|ddd
dd	 d S )Nc                   @   r`   )z2TestCase.test_helper_asdict_nested.<locals>.UserIdtokengroupNr/   r   r   r   r   UserId  ra   r  c                          e Zd ZU eed<  ed< dS )z0TestCase.test_helper_asdict_nested.<locals>.UserrC   rB   Nr   r   r  r   r   User  ra   r  Joe{   r6   )r  r  rC   rB   r   )r!   r  r"   r  rB   r  )r&   r  ur#  r   r  r   test_helper_asdict_nested  s   z"TestCase.test_helper_asdict_nestedc           	         s  t G dd d t G  fddd}t G  fddd}t G  fddd} d	d
} dd}|d||g}|d||f}|d||d}| t|dd	d
ddddgd | t|dd	d
ddddfd | t|dd	d
dddddd d S )Nc                   @   r  )z<TestCase.test_helper_asdict_builtin_containers.<locals>.UserrC   rB   Nr   r   r   r   r1   r0   r   r   r   r   r    ra   r  c                       "   e Zd ZU eed< e  ed< dS )zATestCase.test_helper_asdict_builtin_containers.<locals>.GroupListrB   usersNr   r   r   r0   r1   r   r   r  r   r   	GroupList  rX   r  c                       &   e Zd ZU eed< e df ed< dS )zBTestCase.test_helper_asdict_builtin_containers.<locals>.GroupTuplerB   .r  Nr   r   r   r0   r1   r   r   r  r   r   
GroupTuple     
 r"  c                       &   e Zd ZU eed< ee f ed< dS )zATestCase.test_helper_asdict_builtin_containers.<locals>.GroupDictrB   r  Nr   r   r   r0   r1   r	   r   r   r  r   r   	GroupDict  r#  r&  Alicer6   Bobr   r   r   secondr  )rB   r  r!   r"   r  	r&   r  r"  r&  r   r   glgtgdr   r  r   %test_helper_asdict_builtin_containers  s,   



z.TestCase.test_helper_asdict_builtin_containersc                    sx   t G dd d t G  fddd}| t| dgdddgii | t| ddiddddiii d S )	Nc                   @   r-   )zDTestCase.test_helper_asdict_builtin_object_containers.<locals>.Childr#  Nr   r   r   r   r1   r   r   r   r   Child  r2   r2  c                       r=  )zETestCase.test_helper_asdict_builtin_object_containers.<locals>.ParentchildNr>  r   r2  r   r   Parent  r2   r5  r6   r3  r#  r   r+  r&   r5  r   r4  r   ,test_helper_asdict_builtin_object_containers  s   $,z5TestCase.test_helper_asdict_builtin_object_containersc                 C   s   t G dd d}|dd}t|td}| |tddg | |t|td d|_t|td}| |td	dg | t|t d S )
Nc                   @   r`   )z.TestCase.test_helper_asdict_factory.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   r6   r   Zdict_factory)r.   r6   )rV   r   r3   )r.   r3   )r!   r  r   r"   r  r.   r   rH   r&   r   r   r#  r   r   r   test_helper_asdict_factory  s   
z#TestCase.test_helper_asdict_factoryc                    s   t dd tG  fddd}|d d|d dd	d
d}t|}| |d dd dd	d
ddd t|td}| |d dd dd	d
ddd | t|t | t|d d t d S )NTa b cc                       r  )z1TestCase.test_helper_asdict_namedtuple.<locals>.Cr.   rV   Nr   r   r;  r   r   r     ra   r   outerr6   innerr        r   r  r8  rV   )r   r!   r  r"   r   r   rH   r9  r   r=  r   test_helper_asdict_namedtuple  s0   
 

	z&TestCase.test_helper_asdict_namedtuplec                 C   sN   t G dd d}tdd}||ddi}| t|d|dddii d S )	Nc                   @   r-   )z5TestCase.test_helper_asdict_namedtuple_key.<locals>.Cr  N)r   r   r   r3  r1   r   r   r   r   r   +  r2   r   r;  r   zan ar   r  r   )r!   r   r"   r  )r&   r   r;  r   r   r   r   !test_helper_asdict_namedtuple_key'  s
   
"z*TestCase.test_helper_asdict_namedtuple_keyc                    s   G dd dt dd tG  fddd} d}||}t|}| |d dd	i | |d | | |d  d d S )
Nc                   @   ry   )z9TestCase.test_helper_asdict_namedtuple_derived.<locals>.Tc                 S      | j S r{   rC  rk   r   r   r   my_a6  rx  z>TestCase.test_helper_asdict_namedtuple_derived.<locals>.T.my_aN)r   r   r   rF  r   r   r   r   r;  5  r<  r;  ZTbaser   c                       r=  )z9TestCase.test_helper_asdict_namedtuple_derived.<locals>.Cr  Nr>  r   r=  r   r   r   9  r2   r   rM  r  rC  )r   r!   r  r"   r  rF  )r&   r   r	  r   r#  r   r=  r   %test_helper_asdict_namedtuple_derived4  s   z.TestCase.test_helper_asdict_namedtuple_derivedc                 C   s   t G dd d}|d}| t|d | t|t| | t|t| d|_| t|d | tt|t d S )Nc                   @   rT   )z'TestCase.test_helper_astuple.<locals>.Cr.   r   rV   NrW   r   r   r   r   r   H  rX   r   r6   )r6   r   r3   )r6   r3   )r!   r"   r  r  rV   r   rH   r  r   r   r   r   test_helper_astupleF  s   zTestCase.test_helper_astuplec                 C   r  )Nc                   @   r`   )z9TestCase.test_helper_astuple_raises_on_classes.<locals>.Cr.   rV   Nr/   r   r   r   r   r   W  ra   r   r  )r!   r<   rb   r  r0   r   r   r   r   %test_helper_astuple_raises_on_classesU  r  z.TestCase.test_helper_astuple_raises_on_classesc                 C   sx   t G dd d}g }|d|}t|}| |d | | |d | |d}t|}|d d | |jg  d S )Nc                   @   r  )z3TestCase.test_helper_astuple_copy_values.<locals>.Cr.   ri  rV   Nr	  r   r   r   r   r   a  r
  r   r6   )r!   r  r"   r  r  rV   )r&   r   r  r   r	  r   r   r   test_helper_astuple_copy_values`  r  z(TestCase.test_helper_astuple_copy_valuesc                    s|   t G dd d t G  fddd}|d dd}t|}| |d | t|t| d	|j_| t|d
 d S )Nc                   @   r`   )z3TestCase.test_helper_astuple_nested.<locals>.UserIdr  r  Nr/   r   r   r   r   r  p  ra   r  c                       r  )z1TestCase.test_helper_astuple_nested.<locals>.UserrC   rB   Nr   r   r  r   r   r  t  ra   r  r  r  r6   )r  )r  r6   r   )r  )r  r   )r!   r  r"   r  rB   r  )r&   r  r  r	  r   r  r   test_helper_astuple_nestedo  s   z#TestCase.test_helper_astuple_nestedc           	         s   t G dd d t G  fddd}t G  fddd}t G  fddd} d	d
} dd}|d||g}|d||f}|d||d}| t|dddgf | t|d | t|ddddf d S )Nc                   @   r  )z=TestCase.test_helper_astuple_builtin_containers.<locals>.UserrC   rB   Nr  r   r   r   r   r    ra   r  c                       r  )zBTestCase.test_helper_astuple_builtin_containers.<locals>.GroupListrB   r  Nr  r   r  r   r   r    rX   r  c                       r   )zCTestCase.test_helper_astuple_builtin_containers.<locals>.GroupTuplerB   .r  Nr!  r   r  r   r   r"    r#  r"  c                       r$  )zBTestCase.test_helper_astuple_builtin_containers.<locals>.GroupDictrB   r  Nr%  r   r  r   r   r&    r#  r&  r'  r6   r(  r   r   r)  r'  r6   r(  r   )r   )rL  rM  r!   r"   r  r,  r   r  r   &test_helper_astuple_builtin_containers  s    

z/TestCase.test_helper_astuple_builtin_containersc                    sp   t G dd d t G  fddd}| t| dgdgff | t| ddiddiff d S )Nc                   @   r-   )zETestCase.test_helper_astuple_builtin_object_containers.<locals>.Childr#  Nr1  r   r   r   r   r2    r2   r2  c                       r=  )zFTestCase.test_helper_astuple_builtin_object_containers.<locals>.Parentr3  Nr>  r   r4  r   r   r5    r2   r5  r6   r   rN  r6  r   r4  r   -test_helper_astuple_builtin_object_containers  s    (z6TestCase.test_helper_astuple_builtin_object_containersc                    s   t G dd d}tdd  fdd}|dd}t||d	}| | dd | |t||d	 d
|_t||d	}| | d
d | t|  d S )Nc                   @   r`   )z/TestCase.test_helper_astuple_factory.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   NTzx yc                    s    |  S r{   r   )rA  rQ  r   r   nt     z0TestCase.test_helper_astuple_factory.<locals>.ntr6   r   Ztuple_factoryr3   )r!   r   r  r"   r  r.   r   rH   )r&   r   rS  r   r	  r   rR  r   test_helper_astuple_factory  s   

z$TestCase.test_helper_astuple_factoryc                    s   t dd tG  fddd}|d d|d dd	d
d}t|}| |d dddf t|td}| |d dd dd	d
gdg d S )Nr;  r<  c                       r  )z2TestCase.test_helper_astuple_namedtuple.<locals>.Cr.   rV   Nr   r   r=  r   r   r     ra   r   r>  r6   r?  r  r@  rA  r   )r?  )r  r@  rA  rU  )r   r!   r  r"   r2  )r&   r   r   r	  r   r=  r   test_helper_astuple_namedtuple  s   
 (z'TestCase.test_helper_astuple_namedtuplec                 C   sN   dt t di}tdd|}t|}| || | t|ddddd d S )Nr1   r  r   r   r6   r   )r0   rH   r!   r"   r  r&   Zcls_dictr   Zcls1r   r   r   test_dynamic_class_creation  s
    z$TestCase.test_dynamic_class_creationc                 C   sT   t t dtddd}tdd|}t|}| || | t|dddd d S )Nr  r   r   )r1   rV   r   r   r6   )r0   r:   rH   r!   r"   r  rX  r   r   r   'test_dynamic_class_creation_using_field  s   z0TestCase.test_dynamic_class_creation_using_fieldc                    s   t G dd d}g   fdd}||_|dd}| d d  | d d  | d	g f d
  | dg f d  | d  | d d  d S )Nc                   @   sj   e Zd ZU eed< e Zeed< eeddZeed< eedZ	eed< eddd	Z
eed
< dZeed< dS )z&TestCase.test_init_in_order.<locals>.Cr   r   Fr  r   ri  r#  r   r^  r  r  N)r   r   r   r0   r1   r:   r   r2  r   r#  r  r  r   r   r   r   r     s   
 r   c                    s     ||f d S r{   )r  r&   rC   valueZcallsr   r   setattr  r  z,TestCase.test_init_in_order.<locals>.setattrr   r6   )r   r   )r   r6   r   r   r#  rY   )r  r   )r  r   r   )r!   __setattr__r"   r   )r&   r   r^  r   r   r]  r   test_init_in_order  s   
zTestCase.test_init_in_orderc                 C   s   t G dd d}|d}| d|j | d|j | d|j | d|j | |jd | d	|j | |jd | d|j | |jd | d|j | |jg  | d|j | |j	g  | d|j | d	|j | |jd d S )
Nc                   @   s\   e Zd ZU eed< eeddZeed< eedZeed< edddZ	eed	< d
Z
eed< dS )z'TestCase.test_items_in_dicts.<locals>.Cr   Fr  r   ri  r   r   r^  r#  r   r  N)r   r   r   r0   r1   r:   r2  r   r   r#  r  r   r   r   r   r     s   
 r   r   r   r   r   r#  r   r  )
r!   r   r   rI   r"   r#  r  r   r   r   r   r   r   r   test_items_in_dicts  s&   zTestCase.test_items_in_dictsc                 C   s*   t G dd d}| |djd d S )Nc                   @   s"   e Zd ZU eed< edd ZdS )z:TestCase.test_alternate_classmethod_constructor.<locals>.Cr.   c                 S   s   d}| |S )Nr   r   )r   filenameZvalue_in_filer   r   r   	from_file  s   zDTestCase.test_alternate_classmethod_constructor.<locals>.C.from_fileN)r   r   r   r0   r1   r  rc  r   r   r   r   r     s   
 r   rb  r   )r!   r"   rc  r.   r   r   r   r   &test_alternate_classmethod_constructor  s   	z/TestCase.test_alternate_classmethod_constructorc                 C   s   t G dd d}| t|d j | tt|d jd | td dt|d jd< W d    d S 1 s;w   Y  d S )Nc                   @   r-   )z/TestCase.test_field_metadata_default.<locals>.Cr*   Nr/   r   r   r   r   r   '  r2   r   r    does not support item assignmentrY   test)r!   r  r$   metadatar"   r#   r<   rb   r   r   r   r   test_field_metadata_default$  s   "z$TestCase.test_field_metadata_defaultc                    sF  |  t tG dd d}W d    n1 sw   Y  i  tG  fddd}| t|d j | tt|d jd d d< | tt|d jd | t|d jd d | td dt|d jd	< W d    n1 szw   Y  d
ddd tG  fddd}| tt|d jd | t|d jd	 d
 | t|d jd d | t|d jd d d d< | tt|d jd | t|d jd d |  t	 t|d jd  W d    n1 sw   Y  | td dt|d jd	< W d    d S 1 sw   Y  d S )Nc                   @   r   )/TestCase.test_field_metadata_mapping.<locals>.Cr   rg  r*   Nr   r   r   r:   r*   r0   r1   r   r   r   r   r   5  r   r   c                       r   ri  rj  r*   Nrk  r   r#  r   r   r   ;  r   r   r6   r   re  rY   rf  r~   Z42Zthree)rf  rp  rY   c                       r   rl  rk  r   rm  r   r   r   J  r   rp  r   Zbaz)
r   rb   r!   r  r$   rg  r"   r#   r<   KeyErrorr   r   rm  r   test_field_metadata_mapping1  sF   $z$TestCase.test_field_metadata_mappingc                    s   G dd d t G  fddd}| tt|d jd | t|d jd d | t t|d jd	  W d    n1 sEw   Y  | t|d jd
 d d S )Nc                   @   $   e Zd Zdd Zdd Zdd ZdS )zDTestCase.test_field_metadata_custom_mapping.<locals>.SimpleNameSpacec                 [   s   | j | d S r{   )r   update)r&   kwr   r   r   r   _  s   zMTestCase.test_field_metadata_custom_mapping.<locals>.SimpleNameSpace.__init__c                 S   s   |dkrdS t | |S )Nxyzzyplugh)r   )r&   itemr   r   r   __getitem__b  s   
zPTestCase.test_field_metadata_custom_mapping.<locals>.SimpleNameSpace.__getitem__c                 S   s
   | j  S r{   )r   __len__rk   r   r   r   rw  g  r9  zLTestCase.test_field_metadata_custom_mapping.<locals>.SimpleNameSpace.__len__N)r   r   r   r   rv  rw  r   r   r   r   SimpleNameSpace^  s    rx  c                       s&   e Zd ZU e dddZeed< dS )z6TestCase.test_field_metadata_custom_mapping.<locals>.Cr~   rC  rj  r*   Nrk  r   rx  r   r   r   j     
 r   r   r6   r   r~   r   rs  rt  )r!   r"   r#   r$   rg  r   r  r   r   ry  r   "test_field_metadata_custom_mapping\  s   z+TestCase.test_field_metadata_custom_mappingc                    sX   t d tG  fdddt  }|d}| |jd | |jd t|t  }d S )Nr;  c                       s"   e Zd ZU  ed< dZeed< dS )z5TestCase.test_generic_dataclasses.<locals>.LabeledBoxcontent	<unknown>labelN)r   r   r   r1   r~  r   r   r=  r   r   
LabeledBoxx  rX   r  r3   r}  )r   r!   r
   r"   r|  r~  r   r0   )r&   r  ZboxAliasr   r=  r   test_generic_dataclassesu  s   z!TestCase.test_generic_dataclassesc                    s   t d t dtG  fdddt f }tG dd d|tf }|t }|ddd	}| t|d
 G dd d|tf }|t }|dd}| | d d S )NSr;  c                       s   e Zd ZU ed<  ed< dS )z-TestCase.test_generic_extending.<locals>.Baser.   rV   Nr>  r   r  r;  r   r   r     ra   r   c                   @   r-   )z4TestCase.test_generic_extending.<locals>.DataDerivedZ	new_fieldNr   r   r   r   r   DataDerived  r2   r  r   test1test2)r   r  r  c                   @   ry   )z7TestCase.test_generic_extending.<locals>.NonDataDerivedc                 S   rE  r{   rV   rk   r   r   r   
new_method  rx  zBTestCase.test_generic_extending.<locals>.NonDataDerived.new_methodN)r   r   r   r  r   r   r   r   NonDataDerived  r<  r  r~         ?)	r   r!   r
   r0   r   r"   r  rT  r  )r&   r   r  r  r   r  r   r  r   test_generic_extending  s    
zTestCase.test_generic_extendingc                    s   t d tG  fdddt  }tdd fdt  d fg|t t  fddid	}| |t d
djd  | |t d
ddjd | |t d
ddj	d |  }| |t d
dj
d
 | |j||ttf d S )Nr;  c                       r=  )z-TestCase.test_generic_dynamic.<locals>.Parentr.   Nr>  r   r=  r   r   r5    r2   r5  r2  rV   r   rr   r3   )bases	namespacer6   r   rY   )r   r!   r
   r   r   r0   r   r   r"   rr   r.   __mro__r   )r&   r5  r2  r  r   r=  r   test_generic_dynamic  s   zTestCase.test_generic_dynamicc              
   C   s6  t G dd dat G dd dat G dd datd}d|_tdtddtd|tdtdg d	g}|D ]^}ttjd D ]T}| j||d
C t	t
||}| |j|j | |j|j | || d|_t	t
||}| |j|j | |j|j W d    n1 sw   Y  qCq:d S )Nc                   @   rT   )Pr.   r   rV   NrW   r   r   r   r   r    rX   r  c                   @   *   e Zd ZU eed< edddZeed< dS )Qr.   r   Fr^  rV   Nr   r   r   r0   r1   r:   rV   r   r   r   r   r       
 r  c                   @   r  )Rr.   ri  rV   Nr	  r   r   r   r   r    r
  r  r6   r   )r   rY   r   )sampleprotor3   )r!   r  r  r  rV   rangepickleHIGHEST_PROTOCOLr   loadsdumpsr"   r.   r  )r&   qZsamplesr  r  Z
new_sampleZanother_new_sampler   r   r   test_dataclasses_pickleable  s0   ,z$TestCase.test_dataclasses_pickleablec                 C   s   t ddddG dd d}| |jjd dD ]}| t||jd|  q| td |  W d    d S 1 s=w   Y  d S )	NT)r   rx   re   c                   @   r`   )z.TestCase.test_dataclasses_qualnames.<locals>.Ar.   rV   Nr/   r   r   r   r   r    ra   r  r   )
rs   r   r   r   r   rl   r   __repr__r_  __delattr__z/TestCase.test_dataclasses_qualnames.<locals>.A.zA\.__init__\(\) missing)r!   r"   r   r   r   r   r<   rb   )r&   r  functionr   r   r   test_dataclasses_qualnames  s   "z#TestCase.test_dataclasses_qualnamesN)fr   r   r   r(   r+   r5   r?   rF   rJ   rP   rS   rc   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r&  r'  r6  rB  rC  rE  rP  rb  rh  rj  rk  rs  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  r7  r:  rB  rD  rG  rH  rI  rJ  rK  rO  rP  rV  rW  rY  rZ  r`  ra  rd  rh  ro  r{  r  r  r  r  r  r   r   r   r   r      s    
,5!6(!$-F/9

!+r   c                   @   rp  )TestFieldNoAnnotationc                 C   r  )N)'f' is a field but has no type annotationc                   @      e Zd Ze ZdS )z>TestFieldNoAnnotation.test_field_without_annotation.<locals>.CNr   r   r   r:   r  r   r   r   r   r         
r   r  r   r   r   r   test_field_without_annotation  s   "z3TestFieldNoAnnotation.test_field_without_annotationc                 C   sX   t G dd d}| td t G dd d|}W d    d S 1 s%w   Y  d S )Nc                   @   r-   )zUTestFieldNoAnnotation.test_field_without_annotation_but_annotation_in_base.<locals>.Br  Nr/   r   r   r   r   r^     r2   r^   r  c                   @   r  )zUTestFieldNoAnnotation.test_field_without_annotation_but_annotation_in_base.<locals>.CNr  r   r   r   r   r     r  r   r!   r<   rb   r  r   r   r   4test_field_without_annotation_but_annotation_in_base  s   "zJTestFieldNoAnnotation.test_field_without_annotation_but_annotation_in_basec                 C   sT   G dd d}|  td tG dd d|}W d    d S 1 s#w   Y  d S )Nc                   @   r-   )zcTestFieldNoAnnotation.test_field_without_annotation_but_annotation_in_base_not_dataclass.<locals>.Br  Nr/   r   r   r   r   r^     r  r^   r  c                   @   r  )zcTestFieldNoAnnotation.test_field_without_annotation_but_annotation_in_base_not_dataclass.<locals>.CNr  r   r   r   r   r      r  r   r  r  r   r   r   Btest_field_without_annotation_but_annotation_in_base_not_dataclass  s   "zXTestFieldNoAnnotation.test_field_without_annotation_but_annotation_in_base_not_dataclassN)r   r   r   r  r  r  r   r   r   r   r    s    r  c                   @   sl   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd ZdS )TestDocStringc                 C   s    |  |dd|dd d S )N  )r"   r  )r&   r   r   r   r   r   assertDocStrEqual  s    zTestDocString.assertDocStrEqualc                 C   $   t G dd d}| |jd d S )Nc                   @   r\   )z?TestDocString.test_existing_docstring_not_overridden.<locals>.CLorem ipsumr.   N)r   r   r   __doc__r0   r1   r   r   r   r   r        
 r   r  )r!   r"   r  r   r   r   r   &test_existing_docstring_not_overridden     z4TestDocString.test_existing_docstring_not_overriddenc                 C   r  )Nc                   @   r   )z1TestDocString.test_docstring_no_fields.<locals>.CNr   r   r   r   r   r     r   r   zC()r!   r  r  r   r   r   r   test_docstring_no_fields     z&TestDocString.test_docstring_no_fieldsc                 C   r  )Nc                   @   r-   )z1TestDocString.test_docstring_one_field.<locals>.Cr.   Nr/   r   r   r   r   r     r2   r   zC(x:int)r  r   r   r   r   test_docstring_one_field  r  z&TestDocString.test_docstring_one_fieldc                 C   r  )Nc                   @   r`   )z2TestDocString.test_docstring_two_fields.<locals>.Cr.   rV   Nr/   r   r   r   r   r   #  ra   r   zC(x:int, y:int)r  r   r   r   r   test_docstring_two_fields"  r  z'TestDocString.test_docstring_two_fieldsc                 C   r  )Nc                   @   s&   e Zd ZU eed< eed< eed< dS )z4TestDocString.test_docstring_three_fields.<locals>.Cr.   rV   r   Nr   r   r   r0   r1   r   r   r   r   r   r   +  rH  r   zC(x:int, y:int, z:str)r  r   r   r   r   test_docstring_three_fields*  s   z)TestDocString.test_docstring_three_fieldsc                 C   r  )Nc                   @   r\   )z>TestDocString.test_docstring_one_field_with_default.<locals>.CrY   r.   NrZ   r   r   r   r   r   4  r_   r   z
C(x:int=3)r  r   r   r   r   %test_docstring_one_field_with_default3  r  z3TestDocString.test_docstring_one_field_with_defaultc                 C   r  )Nc                   @   s&   e Zd ZU dZeeedf ed< dS )zCTestDocString.test_docstring_one_field_with_default_none.<locals>.CNr.   )r   r   r   r.   r   r0   rH   r1   r   r   r   r   r   ;  rz  r   zC(x:Optional[int]=None)r  r   r   r   r   *test_docstring_one_field_with_default_none:  r  z8TestDocString.test_docstring_one_field_with_default_nonec                 C   r  )Nc                   @   r  )z2TestDocString.test_docstring_list_field.<locals>.Cr.   N)r   r   r   r   r0   r1   r   r   r   r   r   B  r_   r   zC(x:List[int])r  r   r   r   r   test_docstring_list_fieldA  r  z'TestDocString.test_docstring_list_fieldc                 C   r  )Nc                   @   s$   e Zd ZU eedZee ed< dS )zGTestDocString.test_docstring_list_field_with_default_factory.<locals>.Cri  r.   N)	r   r   r   r:   r2  r.   r   r0   r1   r   r   r   r   r   I  r  r   zC(x:List[int]=<factory>)r  r   r   r   r   .test_docstring_list_field_with_default_factoryH  r  z<TestDocString.test_docstring_list_field_with_default_factoryc                 C   r  )Nc                   @   r-   )z3TestDocString.test_docstring_deque_field.<locals>.Cr.   N)r   r   r   r   r1   r   r   r   r   r   P  r2   r   zC(x:collections.deque)r  r   r   r   r   test_docstring_deque_fieldO  r  z(TestDocString.test_docstring_deque_fieldc                 C   r  )Nc                   @   r  )zHTestDocString.test_docstring_deque_field_with_default_factory.<locals>.Cri  r.   N)r   r   r   r:   r   r.   r1   r   r   r   r   r   W  r   r   z C(x:collections.deque=<factory>)r  r   r   r   r   /test_docstring_deque_field_with_default_factoryV  r  z=TestDocString.test_docstring_deque_field_with_default_factoryN)r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r    s    	r  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestInitc                 C   s   G dd d}t G dd d|}|d}| |jd | dt| t ddG d	d d|}| }| |jd | |jd
 d S )Nc                   @   ry   )z&TestInit.test_base_has_init.<locals>.Bc                 S   r  Nro   r   rk   r   r   r   r   a  s   z/TestInit.test_base_has_init.<locals>.B.__init__Nr:  r   r   r   r   r^   `  r<  r^   c                   @   r\   )&TestInit.test_base_has_init.<locals>.Cr   r.   NrZ   r   r   r   r   r   i  r_   r   r~   r   Fr  c                   @   r\   )r  r~   r.   NrZ   r   r   r   r   r   r  r_   ro   )r!   r"   r.   r   r
  r   )r&   r^   r   r   r   r   r   test_base_has_init_  s   	zTestInit.test_base_has_initc                 C   sT   t ddG dd d}| | jd t ddG dd d}| | jd d S )NFr  c                   @   r\   ) TestInit.test_no_init.<locals>.Cr   r*   N)r   r   r   r*   r0   r1   r   r   r   r   r   z  r_   r   r   c                   @   r{  )r  r   r*   c                 S   r  NrY   r*   rk   r   r   r   r     r9  z)TestInit.test_no_init.<locals>.C.__init__N)r   r   r   r*   r0   r1   r   r   r   r   r   r     r[   rY   r!   r"   r*   r   r   r   r   test_no_inity  s   zTestInit.test_no_initc                 C   s|   t G dd d}| |djd t ddG dd d}| |djd	 t d
dG dd d}| |djd d S )Nc                   @   rf   ))TestInit.test_overwriting_init.<locals>.Cr.   c                 S      d| | _ d S r~  rR   r&   r.   r   r   r   r     r  2TestInit.test_overwriting_init.<locals>.C.__init__Nr   r   r   r0   r1   r   r   r   r   r   r     ra   r   rY   rM  Tr  c                   @   rf   )r  r.   c                 S   r  r~  rR   r  r   r   r   r     r  r  Nr  r   r   r   r   r     ra   r      Fc                   @   rf   )r  r.   c                 S   r  r~  rR   r  r   r   r   r     r  r  Nr  r   r   r   r   r     ra   r   r~   r4   r   r   r   r   test_overwriting_init  s   zTestInit.test_overwriting_initc                 C   s`   G dd dt }tG dd d|}| |djd tG dd d|}| |djd d S )	Nc                   @   r-   )z.TestInit.test_inherit_from_protocol.<locals>.Pr   Nr/   r   r   r   r   r    r  r  c                   @   r-   )z.TestInit.test_inherit_from_protocol.<locals>.Cr   Nr/   r   r   r   r   r     r2   r   r   c                   @   ry   )z.TestInit.test_inherit_from_protocol.<locals>.Dc                 S   s   |d | _ d S r~  rC  )r&   r   r   r   r   r     r  z7TestInit.test_inherit_from_protocol.<locals>.D.__init__Nr:  r   r   r   r   rL     r}   rL   r~   )r   r!   r"   r   )r&   r  r   rL   r   r   r   test_inherit_from_protocol  s   z#TestInit.test_inherit_from_protocolN)r   r   r   r  r  r  r  r   r   r   r   r  ^  s
    r  c                   @   rp  )TestReprc                 C   s   t G dd d}t G dd d|}|d}| t|d t G dd d|}| t| d	 t G d
d d}| t|dd | t| d d S )Nc                   @   r-   )zTestRepr.test_repr.<locals>.Br.   Nr/   r   r   r   r   r^     r2   r^   c                   @   r\   )TestRepr.test_repr.<locals>.Cr~   rV   Nr  r   r   r   r   r     r_   r   r   z(TestRepr.test_repr.<locals>.C(x=4, y=10)c                   @   r\   )zTestRepr.test_repr.<locals>.Dr   r.   NrZ   r   r   r   r   rL     r_   rL   z)TestRepr.test_repr.<locals>.D(x=20, y=10)c                   @   s0   e Zd ZeG dd dZeG dd dZdS )r  c                   @   r-   )zTestRepr.test_repr.<locals>.C.Dr*   Nr/   r   r   r   r   rL     r2   rL   c                   @   r   )zTestRepr.test_repr.<locals>.C.ENr   r   r   r   r   r$    r   r$  N)r   r   r   r!   rL   r$  r   r   r   r   r     s
    r   z$TestRepr.test_repr.<locals>.C.D(i=0)z!TestRepr.test_repr.<locals>.C.E())r!   r"   rA   rL   r$  )r&   r^   r   r'   rL   r   r   r   	test_repr  s   zTestRepr.test_reprc                 C   sb   t ddG dd d}| t dt|d t ddG dd d}| t|dd d S )	NFr   c                   @   r-   ) TestRepr.test_no_repr.<locals>.Cr.   Nr/   r   r   r   r   r     r2   r   z+.TestRepr.test_no_repr.<locals>.C object atrY   c                   @   rf   )r  r.   c                 S   rh   )NC-classr   rk   r   r   r   r    rm   z)TestRepr.test_no_repr.<locals>.C.__repr__Nr   r   r   r0   r1   r  r   r   r   r   r     ra   r  )r!   rI   r   rA   r"   r   r   r   r   test_no_repr  s   
zTestRepr.test_no_reprc                 C   s   t G dd d}| t|dd t ddG dd d}| t|dd t ddG d	d d}| t|dd d S )
Nc                   @   rf   ))TestRepr.test_overwriting_repr.<locals>.Cr.   c                 S   rh   Nr.   r   rk   r   r   r   r    rm   2TestRepr.test_overwriting_repr.<locals>.C.__repr__Nr  r   r   r   r   r     ra   r   r   r.   Tr   c                   @   rf   )r  r.   c                 S   rh   r  r   rk   r   r   r   r    rm   r  Nr  r   r   r   r   r     ra   Fc                   @   rf   )r  r.   c                 S   rh   r  r   rk   r   r   r   r    rm   r  Nr  r   r   r   r   r     ra   r   r   r   r   r   test_overwriting_repr  s   zTestRepr.test_overwriting_reprN)r   r   r   r  r  r  r   r   r   r   r    s    r  c                   @      e Zd Zdd Zdd ZdS )TestEqc                 C   sl   t ddG dd d}| |d|d |d}| || t ddG dd d}| |dd d S )	NFr   c                   @   r-   )TestEq.test_no_eq.<locals>.Cr.   Nr/   r   r   r   r   r     r2   r   r   rY   c                   @   rf   )r  r.   c                 S      |dkS r|  r   rq   r   r   r   rs   		  rT  z#TestEq.test_no_eq.<locals>.C.__eq__Nru   r   r   r   r   r   	  ra   r~   )r!   r   r"   r   r   r   r   
test_no_eq  s   zTestEq.test_no_eqc                 C   s   t G dd d}| |dd | |dd t ddG dd d}| |dd | |dd t d	dG d
d d}| |dd | |dd d S )Nc                   @   rf   )%TestEq.test_overwriting_eq.<locals>.Cr.   c                 S   r  r  r   rq   r   r   r   rs   	  rT  ,TestEq.test_overwriting_eq.<locals>.C.__eq__Nru   r   r   r   r   r   	  ra   r   r6   rY   Tr  c                   @   rf   )r  r.   c                 S   r  rn  r   rq   r   r   r   rs   	  rT  r  Nru   r   r   r   r   r   	  ra   r   Fc                   @   rf   )r  r.   c                 S   r  ro  r   rq   r   r   r   rs   $	  rT  r  Nru   r   r   r   r   r   !	  ra   r   r  r   r   r   r   test_overwriting_eq	  s   zTestEq.test_overwriting_eqN)r   r   r   r  r  r   r   r   r   r    s    r  c                   @   rp  )TestOrderingc                 C   sZ   t tG dd d}| |dd | |dd | |dd | |dd d S )Nc                   @   rf   )z5TestOrdering.test_functools_total_ordering.<locals>.Cr.   c                 S   s
   | j |kS r{   rR   rq   r   r   r   r   1	  s   
z<TestOrdering.test_functools_total_ordering.<locals>.C.__lt__Nr   r   r   r0   r1   r   r   r   r   r   r   -	  s   
 r   r   r6   )r   r!   r   r   r   r   r   r   r   r   test_functools_total_ordering+	  s   z*TestOrdering.test_functools_total_orderingc                 C   s   t ddG dd d}| d|j | d|j | d|j | d|j t ddG d	d d}| d|j | d|j | d|j d S )
NFr   c                   @   r-   )%TestOrdering.test_no_order.<locals>.Cr.   Nr/   r   r   r   r   r   =	  r2   r   r   r   r   r   c                   @   rf   )r  r.   c                 S   rh   rp   r   rq   r   r   r   r   J	  rm   z,TestOrdering.test_no_order.<locals>.C.__lt__Nr  r   r   r   r   r   G	  ra   r  r   r   r   r   test_no_order;	  s   zTestOrdering.test_no_orderc                 C   s  |  td tddG dd d}W d    n1 sw   Y  |  td tddG dd d}W d    n1 s?w   Y  |  td tddG d	d d}W d    n1 saw   Y  |  td
 tddG dd d}W d    d S 1 sw   Y  d S )NzACannot overwrite attribute __lt__.*using functools.total_orderingTr   c                   @   rf   ).TestOrdering.test_overwriting_order.<locals>.Cr.   c                 S   rz   r{   r   rk   r   r   r   r   X	  rm   z5TestOrdering.test_overwriting_order.<locals>.C.__lt__Nr  r   r   r   r   r   U	  ra   r   zACannot overwrite attribute __le__.*using functools.total_orderingc                   @   rf   )r  r.   c                 S   rz   r{   r   rk   r   r   r   r   a	  rm   z5TestOrdering.test_overwriting_order.<locals>.C.__le__N)r   r   r   r0   r1   r   r   r   r   r   r   ^	  ra   zACannot overwrite attribute __gt__.*using functools.total_orderingc                   @   rf   )r  r.   c                 S   rz   r{   r   rk   r   r   r   r   j	  rm   z5TestOrdering.test_overwriting_order.<locals>.C.__gt__N)r   r   r   r0   r1   r   r   r   r   r   r   g	  ra   zACannot overwrite attribute __ge__.*using functools.total_orderingc                   @   rf   )r  r.   c                 S   rz   r{   r   rk   r   r   r   r   s	  rm   z5TestOrdering.test_overwriting_order.<locals>.C.__ge__N)r   r   r   r0   r1   r   r   r   r   r   r   p	  ra   r  r   r   r   r   test_overwriting_orderQ	  s0   			"z#TestOrdering.test_overwriting_orderN)r   r   r   r  r  r  r   r   r   r   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S )TestHashc                 C   s6   t ddG dd d}| t|ddtd d S )NTrw   c                   @   r  )z$TestHash.test_unsafe_hash.<locals>.Cr.   rV   Nr  r   r   r   r   r   x	  ra   r   r6   r   )r6   r   r!   r"   r   r   r   r   r   test_unsafe_hashw	  s   zTestHash.test_unsafe_hashc           	         s   dd } fdd}t g ddD ]9\}\}}}}}|||||d| |||||d| ||||||||d| ||||||||d| qd S )	Nc                 S   s   | d u rd S | r
dS dS )N)rY   r   r   )r\  r   r   r   non_bool	  s
   z*TestHash.test_hash_rules.<locals>.non_boolc              	      sz   j | |||d |dkr-|rt|||dG dd d}nt|||dG dd d}|dkrA d|j  |jd  nJ|d	krO|sN d|j nD|d
krc d|j  |jd  n@|dkr td t|||dG dd d}W d    n(1 sw   Y  W d    d S W d    d S W d    d S W d    d S W d    d S 1 sw   Y  d S )N)caserx   r   re   r   )rx   r   re   c                   @   ry   )1TestHash.test_hash_rules.<locals>.test.<locals>.Cc                 S   rh   r  r   rk   r   r   r   rl   	  rm   :TestHash.test_hash_rules.<locals>.test.<locals>.C.__hash__Nr|   r   r   r   r   r   	  r}   r   c                   @   r   )r  Nr   r   r   r   r   r   	  r   r   rl   r  nonerv   c                   @   ry   )r  c                 S   rh   r  r   rk   r   r   r   rl   	  rm   r  Nr|   r   r   r   r   r   	  r}   )	r   r!   rI   r   ZassertIsNotNoner   r  r<   rb   )r  rx   r   re   Z	with_hashr   r   rk   r   r   rf  	  sB   
 !"z&TestHash.test_hash_rules.<locals>.test))FFFr  r  )FFTr  r  )FTFr  r  )FTTr   r  )TFFr   r   )TFTr   r   )TTFr   r   )TTTr   r   r6   FT)r   )	r&   r  rf  r  rx   r   re   Zres_no_defined_hashZres_defined_hashr   rk   r   test_hash_rules~	  s   1	
 zTestHash.test_hash_rulesc                 C   s   t G dd d}| |d|d | |d|d t ddG dd d}| |d|d | t|dt|d t ddd	G d
d d}| |d|d | |d|d | t|dt|d d S )Nc                   @   rf   ) TestHash.test_eq_only.<locals>.Cr*   c                 S      | j |j kS r{   r  rq   r   r   r   rs   	     'TestHash.test_eq_only.<locals>.C.__eq__Nru   r   r   r   r   r   	  ra   r   r6   r   Trw   c                   @   rf   )r  r*   c                 S   r  r{   r  rq   r   r   r   rs   	  r  r  Nru   r   r   r   r   r   	  ra   r  )rx   r   c                   @   rf   )r  r*   c                 S   s   | j dko
| j |j kS r  r  rq   r   r   r   rs   	  s   r  Nru   r   r   r   r   r   	  ra   rY   )r!   r"   r   r   r   r   r   r   test_eq_only	  s   
 zTestHash.test_eq_onlyc                 C   s`   t ddG dd d}| t| td t ddG dd d}| t| td d S )NTrd   c                   @   r   z%TestHash.test_0_field_hash.<locals>.CNr   r   r   r   r   r   	  r   r   r   rw   c                   @   r   r   r   r   r   r   r   r   	  r   r  r   r   r   r   test_0_field_hash	  s   zTestHash.test_0_field_hashc                 C   s   t ddG dd d}| t|dtd | t|dtd t dd	G d
d d}| t|dtd | t|dtd d S )NTrd   c                   @   r-   z%TestHash.test_1_field_hash.<locals>.Cr.   Nr/   r   r   r   r   r   	  r2   r   r   )r   r3   r3   rw   c                   @   r-   r  r/   r   r   r   r   r   
  r2   r  r   r   r   r   test_1_field_hash	  s   zTestHash.test_1_field_hashc                 C   s6  G dd d}d d t dfd d |dfd dt dfd d|dfd dt dfd d|dfdd t dfdd |dfddt dfdd|dfddt dfdd|dfdd t dfdd |dfddt dfdd|dfddt dfdd|dffD ]\}}}}| j||||d	 |d u r|d u rtG d
d d|}n2|d u rt|dG dd d|}n |d u rt|dG dd d|}nt||dG dd d|}|dkr|d}| td t| W d    n1 sw   Y  n-|dkr| t|dd n|dkr| |jt j n|dkr| t|dtd W d    n	1 sw   Y  qcd S )Nc                   @   ry   )z(TestHash.test_hash_no_args.<locals>.Basec                 S   rh   ri   r   rk   r   r   r   rl   
  rm   z1TestHash.test_hash_no_args.<locals>.Base.__hash__Nr|   r   r   r   r   r   
  r<  r   Z
unhashableFr   baseTr  )re   r   r  r   c                   @   r-   z%TestHash.test_hash_no_args.<locals>.Cr*   Nr/   r   r   r   r   r   +
  r2   r   r  c                   @   r-   r  r/   r   r   r   r   r   /
  r2   rd   c                   @   r-   r  r/   r   r   r   r   r   3
  r2   )re   r   c                   @   r-   r  r/   r   r   r   r   r   7
  r2   r~   unhashable typerj   r3   r  )	r   r   r!   r<   rb   r   r"   r   rl   )r&   r   re   r   r  r   r   r   r   r   r   test_hash_no_args
  s`   




















zTestHash.test_hash_no_argsN)	r   r   r   r  r  r  r  r  r  r   r   r   r   r  v	  s    N#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S )
TestFrozenc                 C   sp   t ddG dd d}|d}| |jd | t d|_W d    n1 s*w   Y  | |jd d S )NTrd   c                   @   r-   )z!TestFrozen.test_frozen.<locals>.Cr*   Nr/   r   r   r   r   r   T
  r2   r   r~   r   )r!   r"   r*   r   r  r   r   r   r   test_frozenS
  s   zTestFrozen.test_frozenc                 C   s   t ddG dd d}t ddG dd d|}|dd}| t d	|_W d    n1 s1w   Y  | t d
|_W d    n1 sIw   Y  | |jd | |jd d S )NTrd   c                   @   r-   )z"TestFrozen.test_inherit.<locals>.Cr*   Nr/   r   r   r   r   r   _
  r2   r   c                   @   r-   )z"TestFrozen.test_inherit.<locals>.DrR  Nr/   r   r   r   r   rL   c
  r2   rL   r   r~   r   rM  )r!   r   r  r*   rR  r"   r&   r   rL   r#  r   r   r   test_inherit^
  s   
zTestFrozen.test_inheritc                 C   s^   t ddG dd d}| td t G dd d|}W d    d S 1 s(w   Y  d S )NTrd   c                   @   r   )z>TestFrozen.test_inherit_nonfrozen_from_empty_frozen.<locals>.CNr   r   r   r   r   r   p
  r   r   5cannot inherit non-frozen dataclass from a frozen onec                   @   r-   )z>TestFrozen.test_inherit_nonfrozen_from_empty_frozen.<locals>.DrR  Nr/   r   r   r   r   rL   v
  r2   rL   r  rO   r   r   r   (test_inherit_nonfrozen_from_empty_frozeno
  s   "z3TestFrozen.test_inherit_nonfrozen_from_empty_frozenc                 C   sL   t G dd d}t G dd d|}|d}| |jd | || d S )Nc                   @   r   )z7TestFrozen.test_inherit_nonfrozen_from_empty.<locals>.CNr   r   r   r   r   r   {
  r   r   c                   @   r-   )z7TestFrozen.test_inherit_nonfrozen_from_empty.<locals>.DrR  Nr/   r   r   r   r   rL   
  r2   rL   rY   )r!   r"   rR  r  r  r   r   r   !test_inherit_nonfrozen_from_emptyz
  s   z,TestFrozen.test_inherit_nonfrozen_from_emptyc              
   C   s   dD ]Q}| j |dA tddG dd d}|r"G dd d|}n|}| td	 tG d
d d|}W d    n1 s?w   Y  W d    n1 sNw   Y  qd S )NTFintermediate_classTrd   c                   @   r-   )z8TestFrozen.test_inherit_nonfrozen_from_frozen.<locals>.Cr*   Nr/   r   r   r   r   r   
  r2   r   c                   @   r   )z8TestFrozen.test_inherit_nonfrozen_from_frozen.<locals>.INr   r   r   r   r   I
  r   r  r  c                   @   r   )z8TestFrozen.test_inherit_nonfrozen_from_frozen.<locals>.DNr   r   r   r   r   rL   
  r   rL   r   r!   r<   rb   r&   r  r   r  rL   r   r   r   "test_inherit_nonfrozen_from_frozen
  s"   z-TestFrozen.test_inherit_nonfrozen_from_frozenc              
   C   s   dD ]Q}| j |dA tG dd d}|rG dd d|}n|}| td tdd	G d
d d|}W d    n1 s?w   Y  W d    n1 sNw   Y  qd S )Nr  r  c                   @   r-   )z8TestFrozen.test_inherit_frozen_from_nonfrozen.<locals>.Cr*   Nr/   r   r   r   r   r   
  r2   r   c                   @   r   )z8TestFrozen.test_inherit_frozen_from_nonfrozen.<locals>.INr   r   r   r   r   r  
  r   r  z5cannot inherit frozen dataclass from a non-frozen oneTrd   c                   @   r   )z8TestFrozen.test_inherit_frozen_from_nonfrozen.<locals>.DNr   r   r   r   r   rL   
  r   rL   r  r  r   r   r   "test_inherit_frozen_from_nonfrozen
  s"   z-TestFrozen.test_inherit_frozen_from_nonfrozenc              	   C   s   dD ]U}| j |d) G dd d}|rG dd d|}n|}tddG d	d
 d
|}W d    n1 s6w   Y  |d}| t d|_W d    n1 sRw   Y  qd S )Nr  r  c                   @   r   )z4TestFrozen.test_inherit_from_normal_class.<locals>.CNr   r   r   r   r   r   
  rK   r   c                   @   r   )z4TestFrozen.test_inherit_from_normal_class.<locals>.INr   r   r   r   r   r  
  r   r  Trd   c                   @   r-   )z4TestFrozen.test_inherit_from_normal_class.<locals>.Dr*   Nr/   r   r   r   r   rL   
  r2   rL   r~   r   )r   r!   r   r  r*   )r&   r  r   r  rL   r#  r   r   r   test_inherit_from_normal_class
  s   z)TestFrozen.test_inherit_from_normal_classc                 C   s   t ddG dd d}G dd d|}|d}| |jd | |jd d|_| t d	|_W d    n1 s<w   Y  | t d	|_W d    n1 sTw   Y  | |jd | |jd | |jd d S )
NTrd   c                   @   rT   )z4TestFrozen.test_non_frozen_normal_derived.<locals>.Dr.   r~   rV   NrW   r   r   r   r   rL   
  rX   rL   c                   @   r   )z4TestFrozen.test_non_frozen_normal_derived.<locals>.SNr   r   r   r   r   r  
  rK   r  rY   r~   r   )r!   r"   r.   rV   cachedr   r  )r&   rL   r  r  r   r   r   test_non_frozen_normal_derived
  s    z)TestFrozen.test_non_frozen_normal_derivedc                 C   s   |  td tddG dd d}W d    n1 sw   Y  |  td tddG dd d}W d    n1 s?w   Y  tddG d	d d}| |d
jd d S )Nz&Cannot overwrite attribute __setattr__Trd   c                   @   rf   )-TestFrozen.test_overwriting_frozen.<locals>.Cr.   c                 S   rz   r{   r   rk   r   r   r   r_  
  rm   9TestFrozen.test_overwriting_frozen.<locals>.C.__setattr__Nr   r   r   r0   r1   r_  r   r   r   r   r   
  ra   r   z&Cannot overwrite attribute __delattr__c                   @   rf   )r  r.   c                 S   rz   r{   r   rk   r   r   r   r  
  rm   z9TestFrozen.test_overwriting_frozen.<locals>.C.__delattr__N)r   r   r   r0   r1   r  r   r   r   r   r   
  ra   Fc                   @   rf   )r  r.   c                 S   s   |d | j d< d S )Nr   r.   )r   r[  r   r   r   r_  
  r  r  Nr  r   r   r   r   r   
  ra   r~   r   )r<   rb   r!   r"   r.   r   r   r   r   test_overwriting_frozen
  s   z"TestFrozen.test_overwriting_frozenc                 C   sb   t ddG dd d}t|d | td t|i  W d    d S 1 s*w   Y  d S )NTrd   c                   @   r-   )z&TestFrozen.test_frozen_hash.<locals>.Cr.   N)r   r   r   r   r1   r   r   r   r   r   
  r2   r   rY   r  )r!   r   r<   rb   r   r   r   r   test_frozen_hash
  s   "zTestFrozen.test_frozen_hashN)r   r   r   r  r  r  r  r  r  r  r  r  r   r   r   r   r   r
  R
  s    r
  c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Ze	dddG dd dZ
e	ddG dd dZdd Zdd Zdd ZdS )	TestSlotsc                 C   s   t G dd d}| td |  W d    n1 sw   Y  |d}| |jd d|_| |jd | td d|_W d    d S 1 sLw   Y  d S )Nc                   @   r\   )z TestSlots.test_simple.<locals>.CrR   r.   Nr   r   r   	__slots__r   r1   r   r   r   r   r     r  r   r   r~   r   z'C' object has no attribute 'y')r!   r<   rb   r"   r.   r  rV   r   r   r   r   test_simple  s   "zTestSlots.test_simplec                 C   sN   t G dd d}t G dd d|}|dd}| |j|jfd d|_d S )	Nc                   @   r\   )z0TestSlots.test_derived_added_field.<locals>.BaserR   r.   Nr"  r   r   r   r   r     r  r   c                   @   r`   )z3TestSlots.test_derived_added_field.<locals>.Derivedr.   rV   Nr/   r   r   r   r   Derived  ra   r%  r6   r   rD  r~   )r!   r"   r.   rV   r   )r&   r   r%  r#  r   r   r   test_derived_added_field  s   

z"TestSlots.test_derived_added_fieldc                 C   s   t ddG dd d}|dd}| |j|jfd d|_d	|_| |j|jfd
 | td d|_W d    d S 1 s@w   Y  d S )NTslotsc                   @   r`   )z)TestSlots.test_generated_slots.<locals>.Cr.   rV   Nr/   r   r   r   r   r   +  ra   r   r6   r   rD  rY   r   r  z'C' object has no attribute 'z'r   )r!   r"   r.   rV   r<   r  r   r   r   r   r   test_generated_slots*  s   
"zTestSlots.test_generated_slotsc                 C   sJ   |  td tddG dd d}W d    d S 1 sw   Y  d S )Nz^C already specifies __slots__$Tr'  c                   @   r\   )z5TestSlots.test_add_slots_when_slots_exists.<locals>.CrR   r.   N)r   r   r   r#  r0   r1   r   r   r   r   r   <  r  r   r  r   r   r   r    test_add_slots_when_slots_exists:  s   "z*TestSlots.test_add_slots_when_slots_existsc                 C   sv   t ddG dd d}| |jd t ddG dd d|}| |jd t G d	d
 d
|}| d|jv d S )NTr'  c                   @   r-   )z2TestSlots.test_generated_slots_value.<locals>.Baser.   Nr/   r   r   r   r   r   B  r2   r   rR   c                   @   r-   )z7TestSlots.test_generated_slots_value.<locals>.DeliveredrV   Nr/   r   r   r   r   	DeliveredH  r2   r+  r  c                   @   r-   )z>TestSlots.test_generated_slots_value.<locals>.AnotherDeliveredr   Nr/   r   r   r   r   AnotherDeliveredN  r2   r,  r#  )r!   r"   r#  r   r   )r&   r   r+  r,  r   r   r   test_generated_slots_valueA  s   z$TestSlots.test_generated_slots_valuec                 C   sJ   G dd d}t |dd}| || | t|d | t|d d S )Nc                   @   r-   )z+TestSlots.test_returns_new_class.<locals>.Ar.   Nr/   r   r   r   r   r  U  r  r  Tr'  r#  )r!   r  r  r  r   r&   r  r^   r   r   r   test_returns_new_classT  s
   z TestSlots.test_returns_new_classT)re   r(  c                   @   r  )zTestSlots.FrozenSlotsClassr   rp  Nr  r   r   r   r   FrozenSlotsClass_  ra   r0  rd   c                   @   r  )z!TestSlots.FrozenWithoutSlotsClassr   rp  Nr  r   r   r   r   FrozenWithoutSlotsClassd  ra   r1  c              	   C   s   |  | jjd ttjd D ]P}| j|d@ | dd}ttj||d}| 	|| |  || | 
dd}ttj||d}| 	|| |  || W d    n1 sZw   Y  qd S )N)r   rp  r6   )r  r   )protocol)r"   r0  r#  r  r  r  r   r  r  r  r1  )r&   r  r  pr   r   r   test_frozen_picklei  s   zTestSlots.test_frozen_picklec                 C   @   t ddG dd d}|d}| |jd | |jd d S )NTr'  c                   @   s*   e Zd ZU eed< edddZeed< dS )z4TestSlots.test_slots_with_default_no_init.<locals>.Ar   r   Fr^  Nr   r   r   r   r1   r:   r   r   r   r   r   r  {  r  r  r   r   r!   r"   r   r   r&   r  r  r   r   r   test_slots_with_default_no_inity  
   z)TestSlots.test_slots_with_default_no_initc                 C   r5  )NTr'  c                   @   s.   e Zd ZU eed< edd ddZeed< dS )z<TestSlots.test_slots_with_default_factory_no_init.<locals>.Ar   c                   S   rh   )Nr   r   r   r   r   r   r     r  zETestSlots.test_slots_with_default_factory_no_init.<locals>.A.<lambda>Fr  r   Nr6  r   r   r   r   r    s   
 r  r   r   r7  r8  r   r   r   'test_slots_with_default_factory_no_init  r:  z1TestSlots.test_slots_with_default_factory_no_initN)r   r   r   r$  r&  r)  r*  r-  r/  r!   r0  r1  r4  r9  r;  r   r   r   r   r!     s    
r!  c                   @   r	  )TestDescriptorsc                    sn   G dd d t G  fddd}| |jjd t G  fddd}| |jjd | | jd d S )Nc                   @   r  )z(TestDescriptors.test_set_name.<locals>.Dc                 S      |d | _ d S r  rC   r&   ownerrC   r   r   r   __set_name__  r  z5TestDescriptors.test_set_name.<locals>.D.__set_name__c                 S   s   |d urdS | S Nr6   r   r&   instancer@  r   r   r   __get__  s   z0TestDescriptors.test_set_name.<locals>.D.__get__N)r   r   r   rA  rE  r   r   r   r   rL     s    rL   c                       s   e Zd ZU   Zeed< dS )(TestDescriptors.test_set_name.<locals>.Cr   N)r   r   r   r   r0   r1   r   rL   r   r   r     rM   r   cxc                       $   e Zd ZU e  ddZeed< dS )rF  Fr^  r   Nr   r   r   r:   r   r0   r1   r   rG  r   r   r     r  r6   r!   r"   r   rC   r   r   rG  r   test_set_name  s   
zTestDescriptors.test_set_namec                    s8   G dd d t G  fddd}| |jjd d S )Nc                   @   ry   )z.TestDescriptors.test_non_descriptor.<locals>.Dc                 S   r=  r  r>  r?  r   r   r   rA    r  z;TestDescriptors.test_non_descriptor.<locals>.D.__set_name__N)r   r   r   rA  r   r   r   r   rL     r<  rL   c                       rI  )z.TestDescriptors.test_non_descriptor.<locals>.CFr^  r   NrJ  r   rG  r   r   r     r  r   rH  rK  r   r   rG  r   test_non_descriptor  s   z#TestDescriptors.test_non_descriptorc                    sF   G dd d}|  t   _tG  fddd}|  jjd d S )Nc                   @   r   )z2TestDescriptors.test_lookup_on_instance.<locals>.DNr   r   r   r   r   rL     rK   rL   c                       r  )z2TestDescriptors.test_lookup_on_instance.<locals>.CFr^  r*   Nrk  r   rm  r   r   r     r;   r   r   r   rA  r!   r"   r  )r&   rL   r   r   rm  r   test_lookup_on_instance  s   z'TestDescriptors.test_lookup_on_instancec                    s@   G dd d t   _tG  fddd}|  jjd d S )Nc                   @   r   )z/TestDescriptors.test_lookup_on_class.<locals>.DNr   r   r   r   r   rL     rK   rL   c                       rI  )z/TestDescriptors.test_lookup_on_class.<locals>.CFr^  r*   Nrk  r   rG  r   r   r     r  r   r6   rN  r   r   rG  r   test_lookup_on_class  s
   z$TestDescriptors.test_lookup_on_classc                    sR   G dd d t   _tG  fddd} j  |d}|  jjd d S )Nc                   @   r   )z.TestDescriptors.test_init_calls_set.<locals>.DNr   r   r   r   r   rL     rK   rL   c                          e Zd ZU   Z ed< dS )z.TestDescriptors.test_init_calls_set.<locals>.Cr*   Nr   r   r   r*   r1   r   rG  r   r   r     rM   r   r   r6   )r   __set__r!   
reset_mockr"   r  r   r   rG  r   test_init_calls_set  s   
z#TestDescriptors.test_init_calls_setc                    s`   G dd d t   _t   _tG  fddd}|d} j  |j}|  jjd d S )Nc                   @   r   )z7TestDescriptors.test_getting_field_calls_get.<locals>.DNr   r   r   r   r   rL     rK   rL   c                       rQ  )z7TestDescriptors.test_getting_field_calls_get.<locals>.Cr*   NrR  r   rG  r   r   r     rM   r   r   r6   )r   rS  rE  r!   rT  r*   r"   r  )r&   r   r   r\  r   rG  r   test_getting_field_calls_get  s   
z,TestDescriptors.test_getting_field_calls_getc                    sX   G dd d t   _tG  fddd}|d} j  d|_|  jjd d S )Nc                   @   r   )z7TestDescriptors.test_setting_field_calls_set.<locals>.DNr   r   r   r   r   rL     rK   rL   c                       rQ  )z7TestDescriptors.test_setting_field_calls_set.<locals>.Cr*   NrR  r   rG  r   r   r     rM   r   r   r~   r6   )r   rS  r!   rT  r*   r"   r  r   r   rG  r   test_setting_field_calls_set  s   
z,TestDescriptors.test_setting_field_calls_setc                    sp   G dd d t   _tG  fddd} j  |d}|  jjd   |_d|_|  jjd d S )Nc                   @   r   )zFTestDescriptors.test_setting_uninitialized_descriptor_field.<locals>.DNr   r   r   r   r   rL   	  rK   rL   c                       r=  )zFTestDescriptors.test_setting_uninitialized_descriptor_field.<locals>.Cr*   Nr>  r   rG  r   r   r     r2   r   r   r   )r   rS  r!   rT  r"   r  r*   r   r   rG  r   +test_setting_uninitialized_descriptor_field  s   
z;TestDescriptors.test_setting_uninitialized_descriptor_fieldc                    sR   G dd d t G  fddd}| }| |jd |d}| |jd d S )Nc                   @   8   e Zd ZdededefddZdededdfdd	ZdS )
z-TestDescriptors.test_default_value.<locals>.DrD  r@  rm  c                 S   s   |d u rdS |j S r  _xrC  r   r   r   rE    s   z5TestDescriptors.test_default_value.<locals>.D.__get__r\  Nc                 S   
   ||_ d S r{   rZ  r&   rD  r\  r   r   r   rS  %  r9  z5TestDescriptors.test_default_value.<locals>.D.__set__r   r   r   r   r   r0   rE  rS  r   r   r   r   rL         rL   c                       rQ  )z-TestDescriptors.test_default_value.<locals>.Cr*   NrR  r   rG  r   r   r   (  rM   r   ro   r   r  r   r   rG  r   test_default_value  s   
z"TestDescriptors.test_default_valuec                    s\   G dd d t G  fddd}| td | }W d    d S 1 s'w   Y  d S )Nc                   @   rY  )
z0TestDescriptors.test_no_default_value.<locals>.DrD  r@  rm  c                 S   s   |d u rt  |jS r{   )r  r[  rC  r   r   r   rE  4  s   z8TestDescriptors.test_no_default_value.<locals>.D.__get__r\  Nc                 S   r\  r{   rZ  r]  r   r   r   rS  :  r9  z8TestDescriptors.test_no_default_value.<locals>.D.__set__r^  r   r   r   r   rL   3  r_  rL   c                       rQ  )z0TestDescriptors.test_no_default_value.<locals>.Cr*   NrR  r   rG  r   r   r   =  rM   r   z&missing 1 required positional argumentr  r   r   rG  r   test_no_default_value2  s   
"z%TestDescriptors.test_no_default_valueN)r   r   r   rL  rM  rO  rP  rU  rV  rW  rX  r`  ra  r   r   r   r   r<    s    r<  c                   @   r  )TestStringAnnotationsc              	      sd   dD ]- | j  d tG  fddd}|  | d|j W d    n1 s*w   Y  qd S )N)zClassVar[int]zClassVar [int]z ClassVar [int]r   z
 ClassVar ztyping.ClassVar[int]ztyping.ClassVar[str]z typing.ClassVar[str]ztyping .ClassVar[str]ztyping. ClassVar[str]ztyping.ClassVar [str]ztyping.ClassVar [ str]ztyping.ClassVar.[int]ztyping.ClassVar+Ztypestrc                       r=  )z.TestStringAnnotations.test_classvar.<locals>.Cr.   Nr>  r   rc  r   r   r   ^  r2   r   r.   )r   r!   r   r   r   r   rc  r   test_classvarE  s   z#TestStringAnnotations.test_classvarc              	      b   dD ], | j  d tG  fddd}| |djd W d    n1 s)w   Y  qd S )N)
CVz
t.ClassVarzt.ClassVar[int]ztyping..ClassVar[int]ZClassvarzClassvar[int]ztyping.ClassVarx[int]ztypong.ClassVar[int]zdataclasses.ClassVar[int]ztypingxClassVar[str]rc  c                       r=  )z3TestStringAnnotations.test_isnt_classvar.<locals>.Cr.   Nr>  r   rc  r   r   r   v  r2   r   r~   r   r!   r"   r.   r   r   rc  r   test_isnt_classvari  s   z(TestStringAnnotations.test_isnt_classvarc              
      s   dD ]> | j  d. tG  fddd}| td |dj W d    n1 s,w   Y  W d    n1 s;w   Y  qd S )N)zInitVar[int]zInitVar [int] InitVar [int]r  z	 InitVar r  zdataclasses.InitVar[str]z dataclasses.InitVar[str]zdataclasses .InitVar[str]zdataclasses. InitVar[str]zdataclasses.InitVar [str]zdataclasses.InitVar [ str]zdataclasses.InitVar.[int]zdataclasses.InitVar+rc  c                       r=  )z-TestStringAnnotations.test_initvar.<locals>.Cr.   Nr>  r   rc  r   r   r     r2   r   zobject has no attribute 'x'r6   )r   r!   r<   r  r.   r   r   rc  r   test_initvar}  s   z"TestStringAnnotations.test_initvarc              	      re  )N)IVz
dc.InitVarzxdataclasses.xInitVarztyping.xInitVar[int]rc  c                       r=  )z2TestStringAnnotations.test_isnt_initvar.<locals>.Cr.   Nr>  r   rc  r   r   r     r2   r   r~   rg  r   r   rc  r   test_isnt_initvar  s   z'TestStringAnnotations.test_isnt_initvarc                 C   sR  ddl m} ddl m} ddl m} ddl m} ||||fD ]}| j|dx |jr0|d}n| }| |j	d |
dd	d
dd}dD ]7}| j|d' | td| d t|| W d    n1 siw   Y  W d    n1 sxw   Y  qF|jr| d|j | |jd n| d|j W d    n1 sw   Y  qd S )Nr   )dataclass_module_1)dataclass_module_1_str)dataclass_module_2)dataclass_module_2_str)mr~   r   r6   r   rY   r   )Ziv0Ziv1Ziv2Ziv3)
field_namezobject has no attribute 'r   not_iv4)rf  rl  rm  rn  ro  r   ZUSING_STRINGSrf  r"   Zcv0rj  r<   r  r   rI   r   rr  r   )r&   rl  rm  rn  ro  rp  r   rq  r   r   r   !test_classvar_module_level_import  s:   z7TestStringAnnotations.test_classvar_module_level_importc                 C   sH   ddl m} | t|jd|ji | t|jj|jtd d d S )Nr   )dataclass_textannor   )r   rm  )rf  rt  r"   r   r  r  r   rH   )r&   rt  r   r   r   test_text_annotations  s   
z+TestStringAnnotations.test_text_annotationsN)	r   r   r   rd  rh  ri  rk  rs  ru  r   r   r   r   rb  D  s    $)rb  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S )TestMakeDataclassc                 C   sZ   t ddtfdttddfgddd id	}|d
}| |j|jfd | | d d S )Nr   r.   rV   r   r   add_onec                 S   s
   | j d S rB  rR   rk   r   r   r   r     s   
 z/TestMakeDataclass.test_simple.<locals>.<lambda>r  r~   )r~   r   r  )r   r0   r:   r"   r.   rV   rw  r   r   r   r   r$    s   
zTestMakeDataclass.test_simplec                 C   s6   i }t ddtfdttddfg|d}| |i  d S )Nr   r.   rV   r   r   rx  )r   r0   r:   r"   )r&   nsr   r   r   r   test_no_mutate_namespace  s   z*TestMakeDataclass.test_no_mutate_namespacec                 C   sd   G dd d}G dd d}t ddtfg||fd}|d}| || | || | || d S )	Nc                   @   r   )z*TestMakeDataclass.test_base.<locals>.Base1Nr   r   r   r   r   Base1  rK   r{  c                   @   r   )z*TestMakeDataclass.test_base.<locals>.Base2Nr   r   r   r   r   Base2  rK   r|  r   r.   r  r   )r   r0   r  r&   r{  r|  r   r   r   r   r   	test_base  s   zTestMakeDataclass.test_basec                 C   s   t G dd d}G dd d}tddtfg||fd}| td |d	}W d    n1 s1w   Y  |d
d	}| || | || | || | |j|jfd d S )Nc                   @   r-   )z4TestMakeDataclass.test_base_dataclass.<locals>.Base1r.   Nr/   r   r   r   r   r{    r2   r{  c                   @   r   )z4TestMakeDataclass.test_base_dataclass.<locals>.Base2Nr   r   r   r   r   r|    rK   r|  r   rV   r}  zrequired positionalr   r6   rD  )	r!   r   r0   r<   rb   r  r"   r.   rV   r~  r   r   r   test_base_dataclass   s   

z%TestMakeDataclass.test_base_dataclassc                 C   s`   dd }t ddtfdtt fgd|id}|dd	}| t|dd
i | tt|d d S )Nc                 S      |  j |9  _ d S r{   rR   r&   rV   r   r   r   	post_init  r  z2TestMakeDataclass.test_init_var.<locals>.post_initr   r.   rV   rw  rx  r   rY   rM  r6   )r   r0   r  r"   r
  r#   r$   )r&   r  r   r   r   r   r   r    s   

zTestMakeDataclass.test_init_varc              	   C   s~   t ddtfdtt dfdtt tddfg}|d}| t|ddi | tt|d | |jd | |j	d d S )	Nr   r.   rV   r~   r   r   r   r6   )
r   r0   r   r:   r"   r
  r#   r$   rV   r   r   r   r   r   r     s   z TestMakeDataclass.test_class_varc              	   C   s   t ddtfdtt dfdtt tddfgdd	}| d
t| | dt| | td t dg dd}W d    d S 1 sBw   Y  d S )Nr   r.   rV   r~   r   r   r   Fr  r   r  zunexpected keyword argument)Zxxinit)	r   r0   r   r:   r   r
  rI   r<   rb   r   r   r   r   test_other_params,  s   "z#TestMakeDataclass.test_other_paramsc                 C   s   t dg d}|ddd}| t|dddd | |jdddd t dddtfd	g}|ddd}| t|dddd | |jdtdd d S )
Nr-  r.   rV   r   r6   r   rY   z
typing.Anyr.   rV   r   )r   r"   r
  r1   r0   r   r   r   r   test_no_types=  s   

zTestMakeDataclass.test_no_typesc              
   C   s   dD ]5}| j |d% | td tdd|g W d    n1 s#w   Y  W d    n1 s2w   Y  qtdd fD ]5}| j |d% | td tdd|g W d    n1 s_w   Y  W d    n1 snw   Y  q>d S )	N)r   )r6   r   rY   r   )	bad_fieldzInvalid field: r   r   c                 S   s   | S r{   r   rR   r   r   r   r   V  r  zCTestMakeDataclass.test_invalid_type_specification.<locals>.<lambda>zhas no len\(\))r   r<   rb   r   rT  )r&   r  r   r   r   test_invalid_type_specificationL  s&   z1TestMakeDataclass.test_invalid_type_specificationc              
   C   sv   dD ]6}| j |d& | td td|d|g W d    n1 s$w   Y  W d    n1 s3w   Y  qd S )N)r   abr:   zField name duplicatedr   r   r   r<   rb   r   r&   r:   r   r   r   test_duplicate_field_names\  s   z,TestMakeDataclass.test_duplicate_field_namesc              
   C      dD ]n}| j |d^ | td tdd|g W d    n1 s#w   Y  | td td|g W d    n1 s?w   Y  | td td|dg W d    n1 s\w   Y  W d    n1 skw   Y  qd S )N)forasyncawaitasr  zmust not be keywordsr   r   r  r  r   r   r   test_keyword_field_namesb     z*TestMakeDataclass.test_keyword_field_namesc              
   C   r  )N)()x,yr   2@3r  zlittle johnny tablesr  zmust be valid identifiersr   r   r  r  r   r   r   test_non_identifier_field_namesl  r  z1TestMakeDataclass.test_non_identifier_field_namesc                 C   s   t dg d d S )Nr   )_Z_aZa_aZa_)r   rk   r   r   r   test_underscore_field_namesv  s   z-TestMakeDataclass.test_underscore_field_namesc              	   C   sV   dD ]&}| j |d t|ddg}| |j| W d    n1 s#w   Y  qd S )N)r  r  r   r  r  )	classnamer   r   )r   r   r"   r   )r&   r  r   r   r   r   test_funny_class_names_names{  s   z.TestMakeDataclass.test_funny_class_names_namesN)r   r   r   r$  rz  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   rv    s    
	

rv  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d Zdd Zdd Zdd ZdS )TestReplacec                 C   sN   t ddG dd d}|dd}t|dd}| |jd | |jd d S )	NTrd   c                   @   r`   )zTestReplace.test.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   r6   r   rY   rR   )r!   r  r"   r.   rV   r&   r   r   r  r   r   r   rf    s   
zTestReplace.testc                 C   s\  t ddG dd d}|dd}t|dd}| |j|j|j|jfd	 | |j|j|j|jfd
 | td t|dddd W d    n1 sLw   Y  | td t|dd t|dddd W d    n1 spw   Y  | t	d d|_W d    n1 sw   Y  | t
d t|ddd}W d    d S 1 sw   Y  d S )NTrd   c                   @   sF   e Zd ZU eed< eed< edddZeed< edddZeed< d	S )
z"TestReplace.test_frozen.<locals>.Cr.   rV   Fr~   r  r   ro   r	  N)r   r   r   r0   r1   r:   r   r	  r   r   r   r   r     s
   
 r   r6   r   rY   rR   )r6   r   r~   ro   )rY   r   r~   ro   
init=Falser   r  )r.   r   r	  r  zcannot assign to field 'x'z3__init__\(\) got an unexpected keyword argument 'a'r   )r.   r   )r!   r  r"   r.   rV   r   r	  r<   r=   r  rb   r  r   r   r   r    s&   
"zTestReplace.test_frozenc                 C   s`   t ddG dd d}|dd}| td t|dd	}W d    d S 1 s)w   Y  d S )
NTrd   c                   @   r`   )z.TestReplace.test_invalid_field_name.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   r6   r   z3__init__\(\) got an unexpected keyword argument 'z'rY   r  r!   r<   rb   r  r  r   r   r   test_invalid_field_name  s   
"z#TestReplace.test_invalid_field_namec                 C   s   t ddG dd d}| td t|dd W d    n1 s#w   Y  | td tddd W d    d S 1 s@w   Y  d S )	NTrd   c                   @   r`   )z*TestReplace.test_invalid_object.<locals>.Cr.   rV   Nr/   r   r   r   r   r     ra   r   r  rY   rR   r   r  r   r   r   r   test_invalid_object  s   "zTestReplace.test_invalid_objectc                 C   s   t G dd d}|d}d|_t|dd}| |j|jfd | td t|d	d
d W d    n1 s8w   Y  | td t|d
d W d    d S 1 sUw   Y  d S )Nc                   @   r  )z#TestReplace.test_no_init.<locals>.Cr.   Fr~   r  rV   Nr  r   r   r   r   r     r  r   r6   r   r   rR   )r   r~   r  r      r  r  )r!   rV   r  r"   r.   r<   r=   r  r   r   r   r    s   "zTestReplace.test_no_initc                 C   s   t G dd d}|d}|d}| |j|j | |jd | td t|dd W d    n1 s7w   Y  t|d	d
 d S )Nc                   @   s&   e Zd ZU eed< dZee ed< dS )z$TestReplace.test_classvar.<locals>.Cr.   r  rV   N)r   r   r   r0   r1   rV   r   r   r   r   r   r     r#  r   r6   r   r  z3__init__\(\) got an unexpected keyword argument 'y'r  r  r   rR   )r!   r   rV   r"   r<   rb   r  r9  r   r   r   rd    s   zTestReplace.test_classvarc                 C   s   t G dd d}|dd}| |jd | td t|dd W d    n1 s,w   Y  t|ddd	}| |jd
 d S )Nc                   @   r  )z0TestReplace.test_initvar_is_specified.<locals>.Cr.   rV   c                 S   r  r{   rR   r  r   r   r   rw    r  z>TestReplace.test_initvar_is_specified.<locals>.C.__post_init__Nr  r   r   r   r   r     r  r   r6   r~   z,InitVar 'y' must be specified with replace()rY   rR   r   r  r   )r!   r"   r.   r<   r=   r  r   r   r   r   test_initvar_is_specified  s   
z%TestReplace.test_initvar_is_specifiedc                 C   sx   t G dd d}|dddd}| t||dd | t|dd	|ddd
d | t|ddd|dddd d S )Nc                   @   s>   e Zd ZU eed< dZee ed< dZee ed< dd ZdS )z6TestReplace.test_initvar_with_default_value.<locals>.Cr.   NrV   r3   r   c                 S   s4   |d ur|  j |7  _ |d ur|  j |7  _ d S d S r{   rR   )r&   rV   r   r   r   r   rw    s
   zDTestReplace.test_initvar_with_default_value.<locals>.C.__post_init__)	r   r   r   r0   r1   rV   r  r   rw  r   r   r   r   r     s
   
 r   r6   r~   r  r@  rR   r   r  r3   )rV   r   )r!   r"   r  r   r   r   r   test_initvar_with_default_value  s   $z+TestReplace.test_initvar_with_default_valuec                 C   s4   t G dd d}|d }||_| t|d d S )Nc                   @      e Zd ZU ded< dS )z*TestReplace.test_recursive_repr.<locals>.Cr   r  Nr>  r   r   r   r   r     r2   r   z1TestReplace.test_recursive_repr.<locals>.C(f=...)r!   r  r"   rA   r   r   r   r   test_recursive_repr  s
   zTestReplace.test_recursive_reprc                 C   s<   t G dd d}|d d }||_||_| t|d d S )Nc                   @   s   e Zd ZU ded< ded< dS )z4TestReplace.test_recursive_repr_two_attrs.<locals>.Cr   r  gNr>  r   r   r   r   r     ra   r   zBTestReplace.test_recursive_repr_two_attrs.<locals>.C(f=..., g=...))r!   r  r  r"   rA   r   r   r   r   test_recursive_repr_two_attrs  s   
z)TestReplace.test_recursive_repr_two_attrsc                 C   sT   t G dd d}t G dd d}|d }|d }||_||_| t|d d S )Nc                   @   r  )z6TestReplace.test_recursive_repr_indirection.<locals>.CrL   r  Nr>  r   r   r   r   r   &  r2   r   c                   @   r  )z6TestReplace.test_recursive_repr_indirection.<locals>.Dr   r  Nr>  r   r   r   r   rL   *  r2   rL   zwTestReplace.test_recursive_repr_indirection.<locals>.C(f=TestReplace.test_recursive_repr_indirection.<locals>.D(f=...))r  )r&   r   rL   r   r#  r   r   r   test_recursive_repr_indirection%  s   z+TestReplace.test_recursive_repr_indirectionc                 C   st   t G dd d}t G dd d}t G dd d}|d }|d }|d }||_||_||_| t|d d S )Nc                   @   r  )z:TestReplace.test_recursive_repr_indirection_two.<locals>.CrL   r  Nr>  r   r   r   r   r   7  r2   r   c                   @   r  )z:TestReplace.test_recursive_repr_indirection_two.<locals>.Dr$  r  Nr>  r   r   r   r   rL   ;  r2   rL   c                   @   r  )z:TestReplace.test_recursive_repr_indirection_two.<locals>.Er   r  Nr>  r   r   r   r   r$  ?  r2   r$  zTestReplace.test_recursive_repr_indirection_two.<locals>.C(f=TestReplace.test_recursive_repr_indirection_two.<locals>.D(f=TestReplace.test_recursive_repr_indirection_two.<locals>.E(f=...)))r  )r&   r   rL   r$  r   r#  r  r   r   r   #test_recursive_repr_indirection_two6  s   z/TestReplace.test_recursive_repr_indirection_twoc                 C   s6   t G dd d}|d d}||_| t|d d S )Nc                   @   s   e Zd ZU ded< eed< dS )z5TestReplace.test_recursive_repr_misc_attrs.<locals>.Cr   r  r  Nr  r   r   r   r   r   O  ra   r   r6   zATestReplace.test_recursive_repr_misc_attrs.<locals>.C(f=..., g=1)r  r   r   r   r   test_recursive_repr_misc_attrsN  s
   
z*TestReplace.test_recursive_repr_misc_attrsN)r   r   r   rf  r  r  r  r  rd  r  r  r  r  r  r  r  r   r   r   r   r    s     	r  c                   @   r  )TestAbstractc                 C   s\   G dd dt j}tddG dd d|}| t| | |ddd	|dd
d d S )Nc                   @   s(   e Zd Zejdd Zejdd ZdS )z5TestAbstract.test_abc_implementation.<locals>.Orderedc                 S   rz   r{   r   rq   r   r   r   r   j  rq  z<TestAbstract.test_abc_implementation.<locals>.Ordered.__lt__c                 S   rz   r{   r   rq   r   r   r   r   n  rq  z<TestAbstract.test_abc_implementation.<locals>.Ordered.__le__N)r   r   r   abcabstractmethodr   r   r   r   r   r   Orderedi  s
    
r  Tr   c                   @   &   e Zd ZU eed< ded< ded< dS )z2TestAbstract.test_abc_implementation.<locals>.DaterI  MonthrJ  r0   rK  Nr/   r   r   r   r   rL  r  rH  rL  i  r@     r     )r  ABCr!   r  r   
isabstractr   )r&   r  rL  r   r   r   test_abc_implementationh  s
   	 z$TestAbstract.test_abc_implementationc                 C   sL   G dd dt j}tG dd d|}| t| d}| t|| d S )Nc                   @   s   e Zd Zejdd ZdS )z)TestAbstract.test_maintain_abc.<locals>.Ac                 S   rz   r{   r   rk   r   r   r   r   }  rq  z-TestAbstract.test_maintain_abc.<locals>.A.fooN)r   r   r   r  r  r   r   r   r   r   r  |  s    r  c                   @   r  )z,TestAbstract.test_maintain_abc.<locals>.DaterI  r  rJ  r0   rK  Nr/   r   r   r   r   rL    rH  rL  z#class Date with abstract method foo)r  r  r!   r   r   r  r<   rb   )r&   r  rL  r>   r   r   r   test_maintain_abc{  s   zTestAbstract.test_maintain_abcN)r   r   r   r  r  r   r   r   r   r  g  s    r  c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestMatchArgsc                 C   s(   t G dd d}| |djd d S )Nc                   @   r-   )z(TestMatchArgs.test_match_args.<locals>.Cr   Nr/   r   r   r   r   r     r2   r   r3   rC  r!   r"   __match_args__r   r   r   r   test_match_args  s   zTestMatchArgs.test_match_argsc                    s0   d t G  fddd}| |dj  d S )Nr   c                       s   e Zd ZU eed<  ZdS )z1TestMatchArgs.test_explicit_match_args.<locals>.Cr   Nr   r   r   r0   r1   r  r   Zmar   r   r        
 r   r3   )r!   r   r  r   r   r  r   test_explicit_match_args  s   z&TestMatchArgs.test_explicit_match_argsc                 C   s.   t ddddG dd d}| |jd d S )NF)rA   r   r@   c                   @   rF  )z'TestMatchArgs.test_bpo_43764.<locals>.Xr   r   r   Nr/   r   r   r   r   X  rH  r  r   r   r   r  )r&   r  r   r   r   test_bpo_43764  s   zTestMatchArgs.test_bpo_43764c                 C   s   t ddG dd d}| d|j t ddG dd d}| |jd t ddG d	d
 d
|}| |jd t G dd d}t ddG dd d|}| |jd d S )NFZ
match_argsc                   @   r-   )z1TestMatchArgs.test_match_args_argument.<locals>.Xr   Nr/   r   r   r   r   r    r2   r  r  c                   @   s   e Zd ZU eed< dZdS )z1TestMatchArgs.test_match_args_argument.<locals>.Yr   r   Nr  r   r   r   r   Y  r  r  r  c                   @   r-   )z1TestMatchArgs.test_match_args_argument.<locals>.Zr   Nr/   r   r   r   r   Z  r2   r  c                   @   r`   )z1TestMatchArgs.test_match_args_argument.<locals>.Ar   r   Nr/   r   r   r   r   r    ra   r  c                   @   r-   )z1TestMatchArgs.test_match_args_argument.<locals>.Br   Nr/   r   r   r   r   r^     r2   r^   )r   r   )r!   r   r   r"   r  )r&   r  r  r  r  r^   r   r   r   test_match_args_argument  s   z&TestMatchArgs.test_match_args_argumentc                 C   s   t ddtfdtfg}| |jd t ddtfdtfgdd}| |jd t ddtfdtfgdd}| d|j t ddtfdtfgd	d
id}| |jd
 d S )Nr   r.   rV   r  Tr  FZ__match__args__r  r  rx  )r   r0   r"   r  r   r   r   r   r   r   test_make_dataclasses  s   z#TestMatchArgs.test_make_dataclassesN)r   r   r   r  r  r  r  r  r   r   r   r   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 )TestKeywordArgsc                 C   s   d}|  t| tG dd d}W d    n1 sw   Y  |  t| tG dd d}W d    n1 s;w   Y  |  t| tddG dd d}W d    d S 1 s^w   Y  d S )Nz+field a is a ClassVar but specifies kw_onlyc                   @   r  )1TestKeywordArgs.test_no_classvar_kwarg.<locals>.ATkw_onlyr   Nr   r   r   r:   r   r   r0   r1   r   r   r   r   r    r  r  c                   @   r  r  Fr  r   Nr  r   r   r   r   r    r  Tr  c                   @   r  r  r  r   r   r   r   r    r  r  )r&   r>   r  r   r   r   test_no_classvar_kwarg  s   "z&TestKeywordArgs.test_no_classvar_kwargc                 C   s~  t ddG dd d}| t|d j t ddG dd d}| t|d j t ddG dd d}| t|d j t ddG d	d d}| t|d j t ddG d
d d}| t|d j t ddG dd d}| t|d j t G dd d}| t|d j t G dd d}| t|d j t G dd d}| t|d j d S )NTr  c                   @   r-   6TestKeywordArgs.test_field_marked_as_kwonly.<locals>.Ar   Nr/   r   r   r   r   r    r2   r  r   c                   @   r   r  Tr  r   Nr   r   r   r:   r   r0   r1   r   r   r   r   r    r   c                   @   r   r  Fr  r   Nr  r   r   r   r   r    r   Fc                   @   r-   r  r/   r   r   r   r   r    r2   c                   @   r   r  r  r   r   r   r   r    r   c                   @   r   r  r  r   r   r   r   r    r   c                   @   r-   r  r/   r   r   r   r   r    r2   c                   @   r   r  r  r   r   r   r   r  	  r   c                   @   r   r  r  r   r   r   r   r    r   )r!   r   r$   r  r  )r&   r  r   r   r   test_field_marked_as_kwonly  s6   z+TestKeywordArgs.test_field_marked_as_kwonlyc                 C   sX   t ddG dd d}| |ddjd t G dd d}| |dd	d
jd d S )NTr  c                   @   r-   )*TestKeywordArgs.test_match_args.<locals>.Cr   Nr/   r   r   r   r   r     r2   r   r3   rC  r   c                   @   s(   e Zd ZU eed< eddZeed< dS )r  r   Tr  r   N)r   r   r   r0   r1   r:   r   r   r   r   r   r     r  r~   r  r  r   r   r   r   r    s   zTestKeywordArgs.test_match_argsc                 C   s  t G dd d}|dddd d}| t| |ddd W d    n1 s)w   Y  t dd	G d
d d}|dddd d}| t| |ddd W d    n1 sZw   Y  t G dd d}|dddd}| |jd | |jd | |jd |dddd}| |jd | |jd | |jd |dddd}| |jd | |jd | |jd |dddd}| |jd | |jd | |jd d S )Nc                   @   .   e Zd ZU eed< eed< eed< eed< dS )z'TestKeywordArgs.test_KW_ONLY.<locals>.Ar   r  r   r   Nr   r   r   r0   r1   KW_ONLYr   r   r   r   r  !  
   
 r  rY   r   r   r   r   -takes 2 positional arguments but 4 were givenTr  c                   @   r  )z'TestKeywordArgs.test_KW_ONLY.<locals>.Br   r  r   r   Nr  r   r   r   r   r^   -  r  r^   r  z,takes 1 positional argument but 4 were givenc                   @   8   e Zd ZU eed< eed< eed< eddZeed< dS )z'TestKeywordArgs.test_KW_ONLY.<locals>.Cr   r  r   Fr  r   Nr   r   r   r0   r1   r  r:   r   r   r   r   r   r   9  
   
 r   r6   r   r  )r   r   )r   r   r   )r!   r<   rb   r"   r   r   r   )r&   r  r>   r^   r   r   r   r   r   test_KW_ONLY   s@   zTestKeywordArgs.test_KW_ONLYc                 C   sb   t G dd d}|dddd d}| t| |ddd W d    d S 1 s*w   Y  d S )Nc                   @   s.   e Zd ZU eed< ded< eed< eed< dS )z1TestKeywordArgs.test_KW_ONLY_as_string.<locals>.Ar   zdataclasses.KW_ONLYr  r   r   Nr/   r   r   r   r   r  Q  r  r  rY   r   r   r  r  r  )r&   r  r>   r   r   r   test_KW_ONLY_as_stringP  s   "z&TestKeywordArgs.test_KW_ONLY_as_stringc                 C   sN  d}|  t| tG dd d}W d    n1 sw   Y  |  t| tG dd d}W d    n1 s;w   Y  |  t| tG dd d}W d    n1 sZw   Y  tG dd d}tG dd d}tG dd	 d	|}|  t| tG d
d d}tG dd	 d	|}W d    d S 1 sw   Y  d S )Nz6'Y' is KW_ONLY, but KW_ONLY has already been specifiedc                   @   s6   e Zd ZU eed< eed< eed< eed< eed< dS )-TestKeywordArgs.test_KW_ONLY_twice.<locals>.Ar   r  r  r   r   Nr  r   r   r   r   r  `     
 r  c                   @   s6   e Zd ZU eed< eed< eed< eed< eed< dS )r  r   r  r   r  r   Nr  r   r   r   r   r  i  r  c                   @   s6   e Zd ZU eed< eed< eed< eed< eed< dS )r  r   r  r   r   r  Nr  r   r   r   r   r  r  r  c                   @   r  )r  r   r  r   Tr  r   Nr  r   r   r   r   r  {  r  c                   @   r  r  r   r  r   r   Nr  r   r   r   r   r    r  c                   @   r  )-TestKeywordArgs.test_KW_ONLY_twice.<locals>.Br  r#  Nr   r   r   r  r1   r0   r   r   r   r   r^     ra   r^   c                   @   r  r  r  r   r   r   r   r    r  c                   @   s&   e Zd ZU eed< eed< eed< dS )r  r  r#  r  Nr  r   r   r   r   r^     rH  r  )r&   r>   r  r^   r   r   r   test_KW_ONLY_twice\  s2   		
"z"TestKeywordArgs.test_KW_ONLY_twicec                 C   s   t G dd d}| td |ddddd W d    n1 s"w   Y  t G d	d
 d
}|ddddd}| t|ddd d S )Nc                   @   F   e Zd ZU eed< eed< ee ed< eed< ee ed< dd ZdS )	z)TestKeywordArgs.test_post_init.<locals>.Ar   r  r   r   r#  c                 S   s   t d|d|)Nzb=z d=rv  r&   r   r#  r   r   r   rw    rl  z7TestKeywordArgs.test_post_init.<locals>.A.__post_init__Nr   r   r   r0   r1   r  r  rw  r   r   r   r   r       
 r  zb=3 d=4r6   r   rY   r   )r   r   r#  c                   @   r  )	z)TestKeywordArgs.test_post_init.<locals>.Br   r  r   r   r#  c                 S   s   || _ || _d S r{   r   r   r  r   r   r   rw    s   
z7TestKeywordArgs.test_post_init.<locals>.B.__post_init__Nr  r   r   r   r   r^     r  r^   r  )r!   r<   r   r"   r  )r&   r  r^   r   r   r   r   r    s   	zTestKeywordArgs.test_post_initc                 C   s   t G dd d}|ddd}| |jd | |jd | |jd | |jd d}| t| t G d	d d}W d    d S 1 sHw   Y  d S )
Nc                   @   s>   e Zd ZU dZeed< eed< eed< dZeed< eed< dS )	(TestKeywordArgs.test_defaults.<locals>.Ar   r   r  r   r6   r   r#  Nr   r   r   r   r0   r1   r  r   r   r   r   r   r    s   
 r  r   rY   )r#  r   r   r6   z1non-default argument 'z' follows default argumentc                   @   sF   e Zd ZU dZeed< eed< eed< eed< dZeed< eed< d	S )
r  r   r   r   r  r   r6   r   r#  Nr  r   r   r   r   r    s   
 )r!   r"   r   r   r   r#  r<   rb   )r&   r  r   Z	err_regexr   r   r   test_defaults  s   "zTestKeywordArgs.test_defaultsc                 C   sn   t ddgdd}| t|d j t dddttddfgdd}| t|d j | t|d	 j d S )
Nr  r   Tr  r   r^   r   Fr6   )r   r   r$   r  r0   r:   r  r.  r   r   r   test_make_dataclass  s   z#TestKeywordArgs.test_make_dataclassN)r   r   r   r  r  r  r  r  r  r  r  r  r   r   r   r   r    s    40Ar  __main__)2Zdataclassesr  r  r  r   r   r  r  ZunittestZunittest.mockr   typingr   r   r   r   r   r	   r
   r   r   r   r   collectionsr   r   r   	functoolsr   	Exceptionr   r   r  r  r  r  r  r  r  r
  r!  r<  rb  rv  r  r  r  r  r   mainr   r   r   r   <module>   sz   0               V#YVG/L ] /  6  % e%A  
