o
    GXhj                     @   s   	 d dl Z d dlZd dlZd dlZd dlmZmZmZmZm	Z	m
Z
 d dlZd dlmZ eeeefZe	e
fZee ZG dd dejZdd ZedkrPe  dS dS )	    N)leltgegteqne)supportc                   @   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 ZPdS )TestCopyc                 C   s&   |  tjtj | ttjt d S N)assertIscopyErrorerrorZ
assertTrue
issubclass	Exceptionself r   8/opt/python-3.10.19/usr/lib/python3.10/test/test_copy.pytest_exceptions   s   zTestCopy.test_exceptionsc                 C   s   d}t  |}| || d S N*   )r   assertEqualr   xyr   r   r   test_copy_basic      
zTestCopy.test_copy_basicc                    sJ   G  fdddt   d}t|}| |j|j | |j|j d S )Nc                       s    e Zd Zdd Z fddZdS )z"TestCopy.test_copy_copy.<locals>.Cc                 S   
   || _ d S r
   foor   r    r   r   r   __init__!      
z+TestCopy.test_copy_copy.<locals>.C.__init__c                    
    | j S r
   r   r   Cr   r   __copy__#   r#   z+TestCopy.test_copy_copy.<locals>.C.__copy__N)__name__
__module____qualname__r"   r'   r   r%   r   r   r&       s    r&   r   )objectr   r   	__class__r    r   r   r%   r   test_copy_copy   
   
zTestCopy.test_copy_copyc                    s|   G dd dt   fdd} d}| ttj| t |  t|}| || | t|  | |j	|j	 d S )Nc                   @      e Zd Zdd ZdS )z&TestCopy.test_copy_registry.<locals>.Cc                 S      t | }||_|S r
   r+   __new__r    clsr    objr   r   r   r2   ,      
z.TestCopy.test_copy_registry.<locals>.C.__new__Nr(   r)   r*   r2   r   r   r   r   r&   +       r&   c                        | j ffS r
   r   r5   r%   r   r   pickle_C0      z-TestCopy.test_copy_registry.<locals>.pickle_Cr   )
r+   assertRaises	TypeErrorr   copyregpickleassertIsNotr   typer    r   r;   r   r   r   r%   r   test_copy_registry*      
zTestCopy.test_copy_registryc                    F   G  fdddt }g  | }t|}| || |  dg d S )Nc                           e Zd Z fddZdd ZdS )z'TestCopy.test_copy_reduce_ex.<locals>.Cc                         d dS N    appendr   protocr   r   __reduce_ex__<      
z5TestCopy.test_copy_reduce_ex.<locals>.C.__reduce_ex__c                 S      |  d d S Nzshouldn't call thisZfailr   r   r   r   
__reduce__?      z2TestCopy.test_copy_reduce_ex.<locals>.C.__reduce__Nr(   r)   r*   rR   rW   r   rP   r   r   r&   ;       r&   rJ   r+   r   r   r   r   r&   r   r   r   rP   r   test_copy_reduce_ex:      
zTestCopy.test_copy_reduce_exc                    rF   )Nc                          e Zd Z fddZdS )z$TestCopy.test_copy_reduce.<locals>.Cc                    rH   rI   rL   r   rP   r   r   rW   I   rS   z/TestCopy.test_copy_reduce.<locals>.C.__reduce__Nr(   r)   r*   rW   r   rP   r   r   r&   H       r&   rJ   r[   r\   r   rP   r   test_copy_reduceG      
zTestCopy.test_copy_reducec                 C   s,   G dd dt }| }| tjtj| d S )Nc                   @   r/   )z"TestCopy.test_copy_cant.<locals>.Cc                 S      | dr	t|t| |S NZ__reduce
startswithAttributeErrorr+   __getattribute__r   namer   r   r   ri   T      
z3TestCopy.test_copy_cant.<locals>.C.__getattribute__Nr(   r)   r*   ri   r   r   r   r   r&   S   r8   r&   )r+   r=   r   r   r   r&   r   r   r   r   test_copy_cantR      zTestCopy.test_copy_cantc                 C   s   G dd d}G dd dt }dd }G dd dtjd	}d d
tddd dddddd|jdttdtdtddd||t|t	 g}|D ]}| 
t|| qDd S )Nc                   @      e Zd ZdS )z*TestCopy.test_copy_atomic.<locals>.ClassicNr(   r)   r*   r   r   r   r   Classic^       rs   c                   @   rq   )z+TestCopy.test_copy_atomic.<locals>.NewStyleNrr   r   r   r   r   NewStyle`   rt   ru   c                   S      d S r
   r   r   r   r   r   fb      z$TestCopy.test_copy_atomic.<locals>.fc                   @   rq   )z0TestCopy.test_copy_atomic.<locals>.WithMetaclassNrr   r   r   r   r   WithMetaclassd   rt   ry   	metaclass.r      d   Q	@TF              ?hello   helloሴs   world   
   rJ   )r+   abcABCMetaNotImplemented__code__bytesrangeslicemaxpropertyr   r   )r   rs   ru   rw   ry   testsr   r   r   r   test_copy_atomic]   s   zTestCopy.test_copy_atomicc                 C   sT   g d}t  |}| || | || g }t  |}| || | || d S )NrJ   r|      r   r   rA   r   r   r   r   test_copy_listn   s   

zTestCopy.test_copy_listc                 C   sN   d}|  t|| d}|  t|| dddg f}|  t|| d S )Nr   r   rJ   r|   r   )r   r   r   r   r   r   r   test_copy_tuplex   s   zTestCopy.test_copy_tuplec                 C   sV   ddd}t  |}| || | || i }t  |}| || | || d S )NrJ   r|   r    barr   r   r   r   r   test_copy_dict   s   


zTestCopy.test_copy_dictc                 C   sV   h d}t  |}| || | || t }t  |}| || | || d S N>   rJ   r|   r   )r   r   rA   setr   r   r   r   test_copy_set      

zTestCopy.test_copy_setc                 C   s:   t h d}| t|| t  }| t|| d S r   )	frozensetr   r   r   r   r   r   test_copy_frozenset   s   zTestCopy.test_copy_frozensetc                 C   sV   t d}t|}| || | || t  }t|}| || | || d S )Ns   abc)	bytearrayr   r   rA   r   r   r   r   test_copy_bytearray   r   zTestCopy.test_copy_bytearrayc                 C   ,   G dd d}|d}|  t|| d S )Nc                   @      e Zd Zdd Zdd ZdS )z*TestCopy.test_copy_inst_vanilla.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"      r#   z3TestCopy.test_copy_inst_vanilla.<locals>.C.__init__c                 S      | j |j kS r
   r   r   otherr   r   r   __eq__   r<   z1TestCopy.test_copy_inst_vanilla.<locals>.C.__eq__Nr(   r)   r*   r"   r   r   r   r   r   r&          r&   r   r   r   rn   r   r   r   test_copy_inst_vanilla   s   zTestCopy.test_copy_inst_vanillac                    s0   G  fddd  d}|  t|| d S )Nc                       (   e Zd Zdd Z fddZdd ZdS )z'TestCopy.test_copy_inst_copy.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"      r#   z0TestCopy.test_copy_inst_copy.<locals>.C.__init__c                    r$   r
   r   r   r%   r   r   r'      r#   z0TestCopy.test_copy_inst_copy.<locals>.C.__copy__c                 S   r   r
   r   r   r   r   r   r      r<   z.TestCopy.test_copy_inst_copy.<locals>.C.__eq__N)r(   r)   r*   r"   r'   r   r   r%   r   r   r&          r&   r   r   r   r   r%   r   test_copy_inst_copy   s   zTestCopy.test_copy_inst_copyc                 C   r   )Nc                   @   $   e Zd Zdd Zdd Zdd ZdS )z.TestCopy.test_copy_inst_getinitargs.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"      r#   z7TestCopy.test_copy_inst_getinitargs.<locals>.C.__init__c                 S      | j fS r
   r   r   r   r   r   __getinitargs__      z>TestCopy.test_copy_inst_getinitargs.<locals>.C.__getinitargs__c                 S   r   r
   r   r   r   r   r   r      r<   z5TestCopy.test_copy_inst_getinitargs.<locals>.C.__eq__Nr(   r)   r*   r"   r   r   r   r   r   r   r&          r&   r   r   rn   r   r   r   test_copy_inst_getinitargs      z#TestCopy.test_copy_inst_getinitargsc                 C   sZ   G dd dt }|d}t|}| || | || | || | |j|j d S )Nc                   @   r   )z-TestCopy.test_copy_inst_getnewargs.<locals>.Cc                 S   r0   r
   intr2   r    r4   r    r   r   r   r   r2      r6   z5TestCopy.test_copy_inst_getnewargs.<locals>.C.__new__c                 S   r   r
   r   r   r   r   r   __getnewargs__   r   z<TestCopy.test_copy_inst_getnewargs.<locals>.C.__getnewargs__c                 S   r   r
   r   r   r   r   r   r      r<   z4TestCopy.test_copy_inst_getnewargs.<locals>.C.__eq__Nr(   r)   r*   r2   r   r   r   r   r   r   r&          r&   r   r   r   assertIsInstancer   rA   r    r\   r   r   r   test_copy_inst_getnewargs   s   	
z"TestCopy.test_copy_inst_getnewargsc                 C   s\   G dd dt }|dd}t|}| || | || | || | |j|j d S )Nc                   @   r   )z0TestCopy.test_copy_inst_getnewargs_ex.<locals>.Cc                S   r0   r
   r   r   r   r   r   r2      r6   z8TestCopy.test_copy_inst_getnewargs_ex.<locals>.C.__new__c                 S      dd| j ifS Nr   r    r   r   r   r   r   __getnewargs_ex__   rX   zBTestCopy.test_copy_inst_getnewargs_ex.<locals>.C.__getnewargs_ex__c                 S   r   r
   r   r   r   r   r   r      r<   z7TestCopy.test_copy_inst_getnewargs_ex.<locals>.C.__eq__Nr(   r)   r*   r2   r   r   r   r   r   r   r&      r   r&   r   r   r   r\   r   r   r   test_copy_inst_getnewargs_ex   s   
	
z%TestCopy.test_copy_inst_getnewargs_exc                 C   r   )Nc                   @   r   )z+TestCopy.test_copy_inst_getstate.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"      r#   z4TestCopy.test_copy_inst_getstate.<locals>.C.__init__c                 S   
   d| j iS Nr    r   r   r   r   r   __getstate__   r#   z8TestCopy.test_copy_inst_getstate.<locals>.C.__getstate__c                 S   r   r
   r   r   r   r   r   r      r<   z2TestCopy.test_copy_inst_getstate.<locals>.C.__eq__Nr(   r)   r*   r"   r   r   r   r   r   r   r&      r   r&   r   r   rn   r   r   r   test_copy_inst_getstate   r   z TestCopy.test_copy_inst_getstatec                 C   r   )Nc                   @   r   )z+TestCopy.test_copy_inst_setstate.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"      r#   z4TestCopy.test_copy_inst_setstate.<locals>.C.__init__c                 S      |d | _ d S r   r   r   stater   r   r   __setstate__   rX   z8TestCopy.test_copy_inst_setstate.<locals>.C.__setstate__c                 S   r   r
   r   r   r   r   r   r      r<   z2TestCopy.test_copy_inst_setstate.<locals>.C.__eq__Nr(   r)   r*   r"   r   r   r   r   r   r   r&      r   r&   r   r   rn   r   r   r   test_copy_inst_setstate   r   z TestCopy.test_copy_inst_setstatec                 C   sF   G dd d}|d}|  t|| |d}|  t|| d S )Nc                   @   ,   e Zd Zdd Zdd Zdd Zdd Zd	S )
z4TestCopy.test_copy_inst_getstate_setstate.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"      r#   z=TestCopy.test_copy_inst_getstate_setstate.<locals>.C.__init__c                 S      | j S r
   r   r   r   r   r   r         zATestCopy.test_copy_inst_getstate_setstate.<locals>.C.__getstate__c                 S   r   r
   r   r   r   r   r   r     r#   zATestCopy.test_copy_inst_getstate_setstate.<locals>.C.__setstate__c                 S   r   r
   r   r   r   r   r   r     r<   z;TestCopy.test_copy_inst_getstate_setstate.<locals>.C.__eq__Nr(   r)   r*   r"   r   r   r   r   r   r   r   r&      
    r&   r   g        r   rn   r   r   r    test_copy_inst_getstate_setstate   s
   	z)TestCopy.test_copy_inst_getstate_setstatec                 C   s   d}t |}| || d S r   )r   deepcopyr   r   r   r   r   test_deepcopy_basic  r   zTestCopy.test_deepcopy_basicc                 C   sZ   g }||g}t |}| || | || | |d |d  | |d |d  d S Nr   rJ   )r   r   r   rA   r   r   r   r   r   test_deepcopy_memo  s   
zTestCopy.test_deepcopy_memoc                 C   s8   G dd dt }G dd d|d}| t|| d S )Nc                   @   rq   )z/TestCopy.test_deepcopy_issubclass.<locals>.MetaNrr   r   r   r   r   Meta"  rt   r   c                   @   rq   )z,TestCopy.test_deepcopy_issubclass.<locals>.CNrr   r   r   r   r   r&   $  rt   r&   rz   )rB   r   r   r   )r   r   r&   r   r   r   test_deepcopy_issubclass  s   z!TestCopy.test_deepcopy_issubclassc                    sJ   G  fdddt   d}t|}| |j|j | |j|j d S )Nc                       s"   e Zd Zdd Zd fdd	ZdS )z*TestCopy.test_deepcopy_deepcopy.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"   *  r#   z3TestCopy.test_deepcopy_deepcopy.<locals>.C.__init__Nc                    r$   r
   r   r   memor%   r   r   __deepcopy__,  r#   z7TestCopy.test_deepcopy_deepcopy.<locals>.C.__deepcopy__r
   )r(   r)   r*   r"   r   r   r%   r   r   r&   )  s    r&   r   )r+   r   r   r   r,   r    r   r   r%   r   test_deepcopy_deepcopy(  r.   zTestCopy.test_deepcopy_deepcopyc                    s|   G dd dt   fdd} d}| ttj| t |  t|}| || | t	|  | |j
|j
 d S )Nc                   @   r/   )z*TestCopy.test_deepcopy_registry.<locals>.Cc                 S   r0   r
   r1   r3   r   r   r   r2   5  r6   z2TestCopy.test_deepcopy_registry.<locals>.C.__new__Nr7   r   r   r   r   r&   4  r8   r&   c                    r9   r
   r   r:   r%   r   r   r;   9  r<   z1TestCopy.test_deepcopy_registry.<locals>.pickle_Cr   )r+   r=   r>   r   r   r?   r@   rA   r   rB   r    rC   r   r%   r   test_deepcopy_registry3  rE   zTestCopy.test_deepcopy_registryc                    F   G  fdddt }g  | }t|}| || |  dg d S )Nc                       rG   )z+TestCopy.test_deepcopy_reduce_ex.<locals>.Cc                    rH   rI   rL   rN   rP   r   r   rR   E  rS   z9TestCopy.test_deepcopy_reduce_ex.<locals>.C.__reduce_ex__c                 S   rT   rU   rV   r   r   r   r   rW   H  rX   z6TestCopy.test_deepcopy_reduce_ex.<locals>.C.__reduce__NrY   r   rP   r   r   r&   D  rZ   r&   rJ   r+   r   r   r   r   r\   r   rP   r   test_deepcopy_reduce_exC  r^   z TestCopy.test_deepcopy_reduce_exc                    r   )Nc                       r_   )z(TestCopy.test_deepcopy_reduce.<locals>.Cc                    rH   rI   rL   r   rP   r   r   rW   R  rS   z3TestCopy.test_deepcopy_reduce.<locals>.C.__reduce__Nr`   r   rP   r   r   r&   Q  ra   r&   rJ   r   r\   r   rP   r   test_deepcopy_reduceP  rc   zTestCopy.test_deepcopy_reducec                 C   s,   G dd dt }| }| tjtj| d S )Nc                   @   r/   )z&TestCopy.test_deepcopy_cant.<locals>.Cc                 S   rd   re   rf   rj   r   r   r   ri   ]  rl   z7TestCopy.test_deepcopy_cant.<locals>.C.__getattribute__Nrm   r   r   r   r   r&   \  r8   r&   )r+   r=   r   r   r   rn   r   r   r   test_deepcopy_cant[  rp   zTestCopy.test_deepcopy_cantc                 C   sz   G dd d}G dd dt }dd }d dtdd	d
 ddddddd|j|td|tt g}|D ]}| t|| q/d S )Nc                   @   rq   )z.TestCopy.test_deepcopy_atomic.<locals>.ClassicNrr   r   r   r   r   rs   g  rt   rs   c                   @   rq   )z/TestCopy.test_deepcopy_atomic.<locals>.NewStyleNrr   r   r   r   r   ru   i  rt   ru   c                   S   rv   r
   r   r   r   r   r   rw   k  rx   z(TestCopy.test_deepcopy_atomic.<locals>.f.r   r|   r}   r~   TFr   s   bytesr   r   r   )	r+   r   r   r   r   r   r   r   r   )r   rs   ru   rw   r   r   r   r   r   test_deepcopy_atomicf  s   
zTestCopy.test_deepcopy_atomicc                 C   sF   ddgdg}t |}| || | || | |d |d  d S NrJ   r|   r   r   r   r   r   rA   r   r   r   r   test_deepcopy_lists  
   
zTestCopy.test_deepcopy_listc                 C   sb   g }| | t|}tD ]
}| t||| q| || | |d | | t	|d d S r   )
rM   r   r   comparisonsr=   RecursionErrorrA   r   r   lenr   r   r   opr   r   r   test_deepcopy_reflexive_listz  s   

z%TestCopy.test_deepcopy_reflexive_listc                 C      d}t |}| || d S Nr   r   r   r   r   r   r   r   test_deepcopy_empty_tuple  r   z"TestCopy.test_deepcopy_empty_tuplec                 C   sF   ddgdf}t |}| || | || | |d |d  d S r   r   r   r   r   r   test_deepcopy_tuple  r   zTestCopy.test_deepcopy_tuplec                 C   r   )N)rJ   r|   r   r   r   r   r   r   !test_deepcopy_tuple_of_immutables  r   z*TestCopy.test_deepcopy_tuple_of_immutablesc                 C   sp   g f}|d  | t|}tD ]
}| t||| q| || | |d |d  | |d d | d S Nr   )rM   r   r   r   r=   r   rA   r   r   r   r   r   test_deepcopy_reflexive_tuple  s   
z&TestCopy.test_deepcopy_reflexive_tuplec                 C   sH   ddgdd}t |}| || | || | |d |d  d S )NrJ   r|   r   r   r    r   r   r   r   r   test_deepcopy_dict  s
   
zTestCopy.test_deepcopy_dictc                 C   sz   i }||d< t |}tD ]
}| t||| qtD ]
}| t||| q| || | |d | | 	t
|d d S )Nr    rJ   )r   r   order_comparisonsr=   r>   equality_comparisonsr   rA   r   r   r   r   r   r   r   test_deepcopy_reflexive_dict  s   
z%TestCopy.test_deepcopy_reflexive_dictc                 C   s0   i }g }t ||}| |t| d | d S r   )r   r   r   idr   r   r   r   r   r   r   test_deepcopy_keepalive  s   z TestCopy.test_deepcopy_keepalivec                 C   sj   i }g d}t ||}| || | t|d i }dg}t ||}| || | t|d d S )N)rJ   r|   r      r|   r   )r   r   r   r   r   r   r   r   !test_deepcopy_dont_memo_immutable  s   z*TestCopy.test_deepcopy_dont_memo_immutablec                 C   sB   G dd d}|dg}t |}| || | |j|j d S )Nc                   @   r   )z.TestCopy.test_deepcopy_inst_vanilla.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"     r#   z7TestCopy.test_deepcopy_inst_vanilla.<locals>.C.__init__c                 S   r   r
   r   r   r   r   r   r     r<   z5TestCopy.test_deepcopy_inst_vanilla.<locals>.C.__eq__Nr   r   r   r   r   r&     r   r&   r   r   r   r   rA   r    r\   r   r   r   test_deepcopy_inst_vanilla  s
   

z#TestCopy.test_deepcopy_inst_vanillac                    sR   G  fddd  dg}t |}| || | || | |j|j d S )Nc                       r   )z/TestCopy.test_deepcopy_inst_deepcopy.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"     r#   z8TestCopy.test_deepcopy_inst_deepcopy.<locals>.C.__init__c                    s    t | j|S r
   )r   r   r    r   r%   r   r   r        z<TestCopy.test_deepcopy_inst_deepcopy.<locals>.C.__deepcopy__c                 S   r   r
   r   r   r   r   r   r     r<   z6TestCopy.test_deepcopy_inst_deepcopy.<locals>.C.__eq__N)r(   r)   r*   r"   r   r   r   r%   r   r   r&     r   r&   r   r  r   r   r%   r   test_deepcopy_inst_deepcopy  s   

z$TestCopy.test_deepcopy_inst_deepcopyc                 C   N   G dd d}|dg}t |}| || | || | |j|j d S )Nc                   @   r   )z2TestCopy.test_deepcopy_inst_getinitargs.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"     r#   z;TestCopy.test_deepcopy_inst_getinitargs.<locals>.C.__init__c                 S   r   r
   r   r   r   r   r   r     r   zBTestCopy.test_deepcopy_inst_getinitargs.<locals>.C.__getinitargs__c                 S   r   r
   r   r   r   r   r   r     r<   z9TestCopy.test_deepcopy_inst_getinitargs.<locals>.C.__eq__Nr   r   r   r   r   r&     r   r&   r   r  r\   r   r   r   test_deepcopy_inst_getinitargs     

z'TestCopy.test_deepcopy_inst_getinitargsc                 C   sl   G dd dt }|dg}t|}| || | || | || | |j|j | |j|j d S )Nc                   @   r   )z1TestCopy.test_deepcopy_inst_getnewargs.<locals>.Cc                 S   r0   r
   r   r   r   r   r   r2     r6   z9TestCopy.test_deepcopy_inst_getnewargs.<locals>.C.__new__c                 S   r   r
   r   r   r   r   r   r     r   z@TestCopy.test_deepcopy_inst_getnewargs.<locals>.C.__getnewargs__c                 S   r   r
   r   r   r   r   r   r     r<   z8TestCopy.test_deepcopy_inst_getnewargs.<locals>.C.__eq__Nr   r   r   r   r   r&     r   r&   r   r   r   r   r   r   rA   r    r\   r   r   r   test_deepcopy_inst_getnewargs  s   
	
z&TestCopy.test_deepcopy_inst_getnewargsc                 C   sn   G dd dt }|dgd}t|}| || | || | || | |j|j | |j|j d S )Nc                   @   r   )z4TestCopy.test_deepcopy_inst_getnewargs_ex.<locals>.Cc                S   r0   r
   r   r   r   r   r   r2     r6   z<TestCopy.test_deepcopy_inst_getnewargs_ex.<locals>.C.__new__c                 S   r   r   r   r   r   r   r   r     rX   zFTestCopy.test_deepcopy_inst_getnewargs_ex.<locals>.C.__getnewargs_ex__c                 S   r   r
   r   r   r   r   r   r     r<   z;TestCopy.test_deepcopy_inst_getnewargs_ex.<locals>.C.__eq__Nr   r   r   r   r   r&     r   r&   r   r   r  r\   r   r   r    test_deepcopy_inst_getnewargs_ex   s   	
z)TestCopy.test_deepcopy_inst_getnewargs_exc                 C   r  )Nc                   @   r   )z/TestCopy.test_deepcopy_inst_getstate.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"     r#   z8TestCopy.test_deepcopy_inst_getstate.<locals>.C.__init__c                 S   r   r   r   r   r   r   r   r     r#   z<TestCopy.test_deepcopy_inst_getstate.<locals>.C.__getstate__c                 S   r   r
   r   r   r   r   r   r     r<   z6TestCopy.test_deepcopy_inst_getstate.<locals>.C.__eq__Nr   r   r   r   r   r&     r   r&   r   r  r\   r   r   r   test_deepcopy_inst_getstate  r  z$TestCopy.test_deepcopy_inst_getstatec                 C   r  )Nc                   @   r   )z/TestCopy.test_deepcopy_inst_setstate.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"   "  r#   z8TestCopy.test_deepcopy_inst_setstate.<locals>.C.__init__c                 S   r   r   r   r   r   r   r   r   $  rX   z<TestCopy.test_deepcopy_inst_setstate.<locals>.C.__setstate__c                 S   r   r
   r   r   r   r   r   r   &  r<   z6TestCopy.test_deepcopy_inst_setstate.<locals>.C.__eq__Nr   r   r   r   r   r&   !  r   r&   r   r  r\   r   r   r   test_deepcopy_inst_setstate   r  z$TestCopy.test_deepcopy_inst_setstatec                 C   s   G dd d}|dg}t |}| || | || | |j|j |g }t |}| || | || | |j|j d S )Nc                   @   r   )
z8TestCopy.test_deepcopy_inst_getstate_setstate.<locals>.Cc                 S   r   r
   r   r!   r   r   r   r"   0  r#   zATestCopy.test_deepcopy_inst_getstate_setstate.<locals>.C.__init__c                 S   r   r
   r   r   r   r   r   r   2  r   zETestCopy.test_deepcopy_inst_getstate_setstate.<locals>.C.__getstate__c                 S   r   r
   r   r   r   r   r   r   4  r#   zETestCopy.test_deepcopy_inst_getstate_setstate.<locals>.C.__setstate__c                 S   r   r
   r   r   r   r   r   r   6  r<   z?TestCopy.test_deepcopy_inst_getstate_setstate.<locals>.C.__eq__Nr   r   r   r   r   r&   /  r   r&   r   r  r\   r   r   r   $test_deepcopy_inst_getstate_setstate.  s   
	

z-TestCopy.test_deepcopy_inst_getstate_setstatec                 C   sB   G dd d}| }||_ t|}| || | |j | d S )Nc                   @   rq   )z0TestCopy.test_deepcopy_reflexive_inst.<locals>.CNrr   r   r   r   r   r&   E  rt   r&   )r    r   r   rA   r   r\   r   r   r   test_deepcopy_reflexive_instD  s   
z%TestCopy.test_deepcopy_reflexive_instc                 C   sF   G dd dt }| }t|}| || t|}| || d S )Nc                   @   r/   )z+TestCopy.test_reconstruct_string.<locals>.Cc                 S   s   dS )NrK   r   r   r   r   r   rW   Q  rx   z6TestCopy.test_reconstruct_string.<locals>.C.__reduce__Nr`   r   r   r   r   r&   P  r8   r&   )r+   r   r   r   r\   r   r   r   test_reconstruct_stringO  s   

z TestCopy.test_reconstruct_stringc                    sX   G  fdddt    }d|_t|}| |j|j t|}| |j|j d S )Nc                       r_   )z,TestCopy.test_reconstruct_nostate.<locals>.Cc                    s    dfS r   r   r   r%   r   r   rW   [  r   z7TestCopy.test_reconstruct_nostate.<locals>.C.__reduce__Nr`   r   r%   r   r   r&   Z  ra   r&   r   )r+   r    r   r   r,   r   r   r   r%   r   test_reconstruct_nostateY  s   

z!TestCopy.test_reconstruct_nostatec                    b   G  fdddt    }dg|_t|}| || t|}| || | |j|j d S )Nc                       rG   )z*TestCopy.test_reconstruct_state.<locals>.Cc                        d| j fS r   __dict__r   r%   r   r   rW   f  r<   z5TestCopy.test_reconstruct_state.<locals>.C.__reduce__c                 S   r   r
   r  r   r   r   r   r   h  r<   z1TestCopy.test_reconstruct_state.<locals>.C.__eq__Nr(   r)   r*   rW   r   r   r%   r   r   r&   e      r&   r   r+   r    r   r   r   rA   r   r   r%   r   test_reconstruct_stated  s   

zTestCopy.test_reconstruct_statec                    r  )Nc                       s(   e Zd Z fddZdd Zdd ZdS )z3TestCopy.test_reconstruct_state_setstate.<locals>.Cc                    r  r   r  r   r%   r   r   rW   t  r<   z>TestCopy.test_reconstruct_state_setstate.<locals>.C.__reduce__c                 S   s   | j | d S r
   )r  updater   r   r   r   r   v     z@TestCopy.test_reconstruct_state_setstate.<locals>.C.__setstate__c                 S   r   r
   r  r   r   r   r   r   x  r<   z:TestCopy.test_reconstruct_state_setstate.<locals>.C.__eq__N)r(   r)   r*   rW   r   r   r   r%   r   r   r&   s  s    r&   r   r  r   r   r%   r   test_reconstruct_state_setstater  s   

z(TestCopy.test_reconstruct_state_setstatec                 C   sD   G dd dt }| }||_t|}| || | |j| d S )Nc                   @   rq   )z.TestCopy.test_reconstruct_reflexive.<locals>.CNrr   r   r   r   r   r&     rt   r&   )r+   r    r   r   rA   r   r\   r   r   r   test_reconstruct_reflexive  s   
z#TestCopy.test_reconstruct_reflexivec                    s   G  fdddt   ddgdg}t|}| || | || | |d |d  t|}| || | || | |d |d  d S )Nc                       rG   )z&TestCopy.test_reduce_4tuple.<locals>.Cc                    s    d| j t| fS r   )r  iterr   r%   r   r   rW     r  z1TestCopy.test_reduce_4tuple.<locals>.C.__reduce__c                 S      t | t |ko| j|jkS r
   )listr  r   r   r   r   r        
z-TestCopy.test_reduce_4tuple.<locals>.C.__eq__Nr  r   r%   r   r   r&     r  r&   rJ   r|   r   r   )r  r   r   rA   r   r   r   r   r%   r   test_reduce_4tuple  s   

zTestCopy.test_reduce_4tuplec                    s   G  fdddt   dddgfdg}t|}| || | || | |d |d  t|}| || | || | |d |d  d S )Nc                       rG   )z&TestCopy.test_reduce_5tuple.<locals>.Cc                    s    d| j d |  fS r   )r  itemsr   r%   r   r   rW     s   z1TestCopy.test_reduce_5tuple.<locals>.C.__reduce__c                 S   r  r
   )dictr  r   r   r   r   r     r   z-TestCopy.test_reduce_5tuple.<locals>.C.__eq__Nr  r   r%   r   r   r&     r  r&   r    rJ   r|   )r   r   )r#  r   r   rA   r   r   r   r   r%   r   test_reduce_5tuple  s   

zTestCopy.test_reduce_5tuplec                    s   fddG  fddd   } t t| W d    n1 s(w   Y   t t| W d    d S 1 sCw   Y  d S )Nc                     s     d d S rU   rV   )argskwargsr   r   r   state_setter  rX   z1TestCopy.test_reduce_6tuple.<locals>.state_setterc                       s   e Zd Z fddZdS )z&TestCopy.test_reduce_6tuple.<locals>.Cc                    s    d| j d d fS r   r  r   r&   r'  r   r   rW     r  z1TestCopy.test_reduce_6tuple.<locals>.C.__reduce__Nr`   r   r(  r   r   r&     s    r&   r=   r>   r   r   r   r   )r&   r   r'  r   test_reduce_6tuple  s   "zTestCopy.test_reduce_6tuplec                    s   G  fddd   }|  t t| W d    n1 s!w   Y  |  t t| W d    d S 1 s<w   Y  d S )Nc                       r_   )z+TestCopy.test_reduce_6tuple_none.<locals>.Cc                    s    d| j d d d fS r   r  r   r%   r   r   rW     r  z6TestCopy.test_reduce_6tuple_none.<locals>.C.__reduce__Nr`   r   r%   r   r   r&     ra   r&   r)  r   r   r%   r   test_reduce_6tuple_none  s   "z TestCopy.test_reduce_6tuple_nonec                 C   s<   G dd dt }| }dg|_t|}| |j|j d S )Nc                   @      e Zd ZdgZdS )z#TestCopy.test_copy_slots.<locals>.Cr    Nr(   r)   r*   	__slots__r   r   r   r   r&         
r&   r   )r+   r    r   r   r\   r   r   r   test_copy_slots  s
   
zTestCopy.test_copy_slotsc                 C   sL   G dd dt }| }dg|_t|}| |j|j | |j|j d S )Nc                   @   r,  )z'TestCopy.test_deepcopy_slots.<locals>.Cr    Nr-  r   r   r   r   r&     r/  r&   r   )r+   r    r   r   r   rA   r\   r   r   r   test_deepcopy_slots  s   
zTestCopy.test_deepcopy_slotsc                 C   sx   G dd dt }|ddid}t|}| || | |j|j | || d|d< | || | |j|j d S )Nc                       s*   e Zd Zd fdd	Z fddZ  ZS )z/TestCopy.test_deepcopy_dict_subclass.<locals>.CNc                    s&   |si }t | | _t | d S r
   )r  keys_keyssuperr"   )r   dr,   r   r   r"     s   z8TestCopy.test_deepcopy_dict_subclass.<locals>.C.__init__c                    s,   t  || || jvr| j| d S d S r
   )r4  __setitem__r3  rM   )r   keyitemr6  r   r   r7    s   
z;TestCopy.test_deepcopy_dict_subclass.<locals>.C.__setitem__r
   )r(   r)   r*   r"   r7  __classcell__r   r   r6  r   r&     s    r&   r    r   )r5  rJ   r   )r#  r   r   r   r3  rA   assertNotEqualr\   r   r   r   test_deepcopy_dict_subclass  s   

z$TestCopy.test_deepcopy_dict_subclassc                 C   s   G dd dt }|ddgdg}ddg|_t|}| t |t | | |j|j | |d |d  | |j|j d S )	Nc                   @   rq   )z+TestCopy.test_copy_list_subclass.<locals>.CNrr   r   r   r   r   r&     rt   r&   rJ   r|   r   r      r   )r  r    r   r   r   r\   r   r   r   test_copy_list_subclass     

z TestCopy.test_copy_list_subclassc                 C   s   G dd dt }|ddgdg}ddg|_t|}| t |t | | |j|j | |d |d  | |j|j d S )	Nc                   @   rq   )z/TestCopy.test_deepcopy_list_subclass.<locals>.CNrr   r   r   r   r   r&     rt   r&   rJ   r|   r   r   r=  r   )r  r    r   r   r   rA   r\   r   r   r   test_deepcopy_list_subclass  r?  z$TestCopy.test_deepcopy_list_subclassc                 C   sJ   G dd dt }|g d}| t |d t|}| t |d d S )Nc                   @   rq   )z,TestCopy.test_copy_tuple_subclass.<locals>.CNrr   r   r   r   r   r&     rt   r&   r   )tupler   r   r\   r   r   r   test_copy_tuple_subclass   s
   
z!TestCopy.test_copy_tuple_subclassc                 C   s~   G dd dt }|ddgdg}| t |ddgdf t|}| t |ddgdf | || | |d |d  d S )Nc                   @   rq   )z0TestCopy.test_deepcopy_tuple_subclass.<locals>.CNrr   r   r   r   r   r&   	  rt   r&   rJ   r|   r   r   )rA  r   r   r   rA   r\   r   r   r   test_deepcopy_tuple_subclass  s   
z%TestCopy.test_deepcopy_tuple_subclassc                 C   s&   G dd dt }| ttj|  d S )Nc                   @   r/   )z-TestCopy.test_getstate_exc.<locals>.EvilStatec                 S   s   t d)Nzain't got no stickin' state)
ValueErrorr   r   r   r   r     r   z:TestCopy.test_getstate_exc.<locals>.EvilState.__getstate__N)r(   r)   r*   r   r   r   r   r   	EvilState  r8   rE  )r+   r=   rD  r   )r   rE  r   r   r   test_getstate_exc  s   zTestCopy.test_getstate_excc                 C   sJ   |  ttt dd }|  t|| dd }|  t|| d S )Nc                 S      | | S r
   r   r   r   r   r   r   r          z(TestCopy.test_copy_function.<locals>.fooc                   S   rv   r
   r   r   r   r   r   <lambda>      z-TestCopy.test_copy_function.<locals>.<lambda>)r   r   
global_foor   r    r   r   r   r   test_copy_function  
   zTestCopy.test_copy_functionc                 C   sJ   |  ttt dd }|  t|| dd }|  t|| d S )Nc                 S   rG  r
   r   rH  r   r   r   r    !  rI  z,TestCopy.test_deepcopy_function.<locals>.fooc                   S   rv   r
   r   r   r   r   r   rJ  #  rK  z1TestCopy.test_deepcopy_function.<locals>.<lambda>)r   r   r   rL  rM  r   r   r   test_deepcopy_function  rO  zTestCopy.test_deepcopy_functionc                 C   sN   G dd dt }| }t|}||}| || ~||}| || d S )Nc                   @   rq   )z"TestCopy._check_weakref.<locals>.CNrr   r   r   r   r   r&   '  rt   r&   )r+   weakrefrefr   )r   Z_copyr&   r5   r   r   r   r   r   _check_weakref&  s   
zTestCopy._check_weakrefc                 C   s   |  tj d S r
   )rS  r   r   r   r   r   test_copy_weakref1  r  zTestCopy.test_copy_weakrefc                 C      |  tj d S r
   )rS  r   r   r   r   r   r   test_deepcopy_weakref4  r  zTestCopy.test_deepcopy_weakrefc           
         s   G dd dt   fddtdD \}}}}| }|||< |||< t|}| || | || | || | | || | | t|d ~~t  | t|d     }}	|	||< | || d S )Nc                   @   rq   )z(TestCopy._check_copy_weakdict.<locals>.CNrr   r   r   r   r   r&   8  rt   r&   c                    s   g | ]}  qS r   r   .0ir%   r   r   
<listcomp>:  s    z1TestCopy._check_copy_weakdict.<locals>.<listcomp>r   r|   rJ   )	r+   r   r   rA   r   r   r   
gc_collectZassertNotIn)
r   Z	_dicttypeabrQ   r5  uvr   r   r   r%   r   _check_copy_weakdict7  s"   
zTestCopy._check_copy_weakdictc                 C   rU  r
   )r`  rQ  WeakKeyDictionaryr   r   r   r   test_copy_weakkeydictL  r  zTestCopy.test_copy_weakkeydictc                 C   rU  r
   )r`  rQ  WeakValueDictionaryr   r   r   r   test_copy_weakvaluedictO  r  z TestCopy.test_copy_weakvaluedictc                    s   G dd dt   fddtdD \}}}}t }|||< |||< t|}| || | t|d | 	|| | | 	|| | | || j
|j
 | || j
|j
 ~t  | t|d d S )Nc                   @   r/   )z-TestCopy.test_deepcopy_weakkeydict.<locals>.Cc                 S   r   r
   rY  r   rY  r   r   r   r"   T  r#   z6TestCopy.test_deepcopy_weakkeydict.<locals>.C.__init__Nr(   r)   r*   r"   r   r   r   r   r&   S  r8   r&   c                       g | ]} |qS r   r   rW  r%   r   r   rZ  V      z6TestCopy.test_deepcopy_weakkeydict.<locals>.<listcomp>r   r|   rJ   )r+   r   rQ  ra  r   r   r;  r   r   rA   rY  r   r[  )r   r\  r]  rQ   r5  r^  r_  r   r%   r   test_deepcopy_weakkeydictR  s   
z"TestCopy.test_deepcopy_weakkeydictc                    s  G dd dt   fddtdD \}}}}t }|||< |||< t|}| || | t|d t	|
 dd d	\\}}\}	}
| || | |j|j | || | |	| | |	j|j | |
| ~~~	~
~t  | t|d
 d S )Nc                   @   r/   )z/TestCopy.test_deepcopy_weakvaluedict.<locals>.Cc                 S   r   r
   re  rf  r   r   r   r"   h  r#   z8TestCopy.test_deepcopy_weakvaluedict.<locals>.C.__init__Nrg  r   r   r   r   r&   g  r8   r&   c                    rh  r   r   rW  r%   r   r   rZ  j  ri  z8TestCopy.test_deepcopy_weakvaluedict.<locals>.<listcomp>r   r|   c                 S   s
   | d j S r   re  )Zpairr   r   r   rJ  r  s   
 z6TestCopy.test_deepcopy_weakvaluedict.<locals>.<lambda>)r8  rJ   )r+   r   rQ  rc  r   r   r;  r   r   sortedr"  rA   rY  r   r   r[  )r   r\  r]  rQ   r5  r^  r_  r   r   ztr   r%   r   test_deepcopy_weakvaluedictf  s&   
 z$TestCopy.test_deepcopy_weakvaluedictc                 C   sT   G dd dt }| }|j|_t|}| |j|j | |jj| |  d S )Nc                   @   r/   )z0TestCopy.test_deepcopy_bound_method.<locals>.Fooc                 S   rv   r
   r   r   r   r   r   m  rx   z2TestCopy.test_deepcopy_bound_method.<locals>.Foo.mN)r(   r)   r*   ro  r   r   r   r   Foo  r8   rp  )r+   ro  r]  r   r   r   r   __self__)r   rp  rw   gr   r   r   test_deepcopy_bound_method~  s   
z#TestCopy.test_deepcopy_bound_methodN)Qr(   r)   r*   r   r   r-   rD   r]   rb   ro   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r	  r
  r  r  r  r  r  r  r  r  r  r!  r$  r*  r+  r0  r1  r<  r>  r@  rB  rC  rF  rN  rP  rS  rT  rV  r`  rb  rd  rj  rn  rs  r   r   r   r   r	      s    



	



	
r	   c                 C   rG  r
   r   rH  r   r   r   rL    rI  rL  __main__)r   r?   rQ  r   operatorr   r   r   r   r   r   Zunittesttestr   r   r   r   ZTestCaser	   rL  r(   mainr   r   r   r   <module>   s.            