B
    u9a.                @   s,  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Zd dl	Z	d dl
Z
d dlmZ d dlm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ZG dd dejZdd Zedkr(e  dS )    N)deepcopy)supportc               @   s   e Zd Zdd Zd0ddZd1d	d
Zd2ddZd3ddZd4ddZd5ddZ	dd Z
dd Zg fddZd d! Zd"d# Zd$d% Zd&d' Zed(d)d* Zed(d+d, Zd-d. Zd/S )6OperatorsTestc             O   s   t jj| f|| ddddddddd	d
ddddddddddd| _x>t| j D ],\}}| rn|d }nd| }|| j|< qTW ddddddd| _x>t| j D ],\}}| r|d }nd| }|| j|< qW d S )N+-*@/z//divmodz**z<<z>>&^|cmp<z<=z==z!=>z>=)addsubmulmatmultruedivfloordivr
   powlshiftrshiftandxororr   ltleeqnegtgez(a, b)za %s babs~intfloat)posnegr#   invertr%   r&   z(a)z%s a)unittestTestCase__init__binopslistitemsislowerunops)selfargskwargsnameexpr r7    /usr/lib/python3.7/test_descr.pyr,      sJ    



zOperatorsTest.__init__len(a)__len__c       	      C   s   d|i}|  t||| t|}t||}x||jkrD|jd }q.W |  t|d||j|  |  ||| t||}|  | | d S )Nar   im_func)assertEqualevaltypegetattr__dict__	__bases__)	r2   r;   resr6   methdtmbmr7   r7   r8   	unop_testC   s    

zOperatorsTest.unop_testa+b__add__c       
      C   s   ||d}|  t||| t|}t||}x||jkrF|jd }q0W |  t|d||j|  |  |||| t||}	|  |	|| d S )N)r;   br   r<   )r=   r>   r?   r@   rA   rB   )
r2   r;   rL   rC   r6   rD   rE   rF   rG   rH   r7   r7   r8   
binop_testS   s    


zOperatorsTest.binop_testa[b:c]__getitem__c             C   s   |||d}|  t||| t|}t||}	x||jkrH|jd }q2W |  t|	d|	|j|  |  |	|t||| t||}
|  |
t||| d S )N)r;   rL   cr   r<   )r=   r>   r?   r@   rA   rB   slice)r2   r;   rL   rP   rC   r6   rD   rE   rF   rG   rH   r7   r7   r8   sliceop_testb   s    

zOperatorsTest.sliceop_testa+=b__iadd__c       
      C   s   t ||d}t|| | |d | t|}t||}x||jkrR|jd }q<W | t|d||j|  t ||d< ||d | | |d | t ||d< t|d |}	|	| | |d | d S )N)r;   rL   r;   r   r<   )r   execr=   r?   r@   rA   rB   )
r2   r;   rL   rC   stmtrD   rE   rF   rG   rH   r7   r7   r8   
setop_testp   s    

zOperatorsTest.setop_testa[b]=c__setitem__c             C   s   t |||d}t|| | |d | t|}t||}	x||jkrT|jd }q>W | t|	d|	|j|  t ||d< |	|d || | |d | t ||d< t|d |}
|
|| | |d | d S )N)r;   rL   rP   r;   r   r<   )r   rU   r=   r?   r@   rA   rB   )r2   r;   rL   rP   rC   rV   rD   rE   rF   rG   rH   r7   r7   r8   set2op_test   s    


zOperatorsTest.set2op_testa[b:c]=dc             C   s   t ||||d}t|| | |d | t|}	x||	jkrL|	jd }	q6W t|	|}
| t|
d|
|	j|  t ||d< |
|d t||| | |d | t ||d< t|d |}|t||| | |d | d S )N)r;   rL   rP   rE   r;   r   r<   )r   rU   r=   r?   rA   rB   r@   rQ   )r2   r;   rL   rP   rE   rC   rV   rD   Z
dictionaryrF   rG   rH   r7   r7   r8   setsliceop_test   s    

zOperatorsTest.setsliceop_testc          
   C   s`  |  dgdgddgdd |  dddgdddd |  dddgdd	dd |  dddgddd
d | dddgd	dddgdd | dgdgddgdd | ddgdddddddgdd | dddgddd |  ddgdddddddgdd |  ddgdddddddgdd | ddgddddgdd | ddddgddddgddddgdd d S )N      za+brK      zb in a__contains__   r   za[b]rO   za[b:c]za+=brT   za*=b__imul__zlen(a)r:   za*b__mul__zb*a__rmul__za[b]=crY         za[b:c]=d)rM   rR   rW   rI   rZ   r\   )r2   r7   r7   r8   
test_lists   s    """$zOperatorsTest.test_listsc          	   C   sh  |  ddddddd |  ddddddd |  ddddddd	 ddd}g }xt| D ]}|| qdW g }xt|D ]}|| qW | || g }x| D ]}|| qW | || g }xt|D ]}|| qW | || ddd}| |dd
d | t	t
|i | | t	| i | | ddddddddddd d S )Nr^   ra   )r]   r_   r]   zb in ar`   r   za[b]rO   zlen(a)r:   r_   )r]   r^   r_   za[b]=crY   )rM   r.   keysappenditerr=   __iter__dictrI   r>   repr__repr__rZ   )r2   rE   l1ilr7   r7   r8   
test_dicts   s2    

zOperatorsTest.test_dictsc             C   s   ||d}xL| j  D ]>\}}||krd| }t||rt||}| ||||| qW xNt| j D ]<\}}||krhd| }t||rht||}| |||| qhW d S )N)r;   rL   z__%s__)r-   r/   hasattrr>   rM   r.   r1   rI   )r2   r;   rL   skiprl   r5   r6   rC   r7   r7   r8   number_operators   s    




zOperatorsTest.number_operatorsc             C   s~   |  dd | d d | d d G dd dt}| |dd y| d  W n tk
rn   Y nX | d	 d S )
Nd   r_   r]   r   c               @   s   e Zd Zdd ZdS )z"OperatorsTest.test_ints.<locals>.Cc             S   s   t S )N)NotImplemented)r2   otherr7   r7   r8   rK      s    z*OperatorsTest.test_ints.<locals>.C.__add__N)__name__
__module____qualname__rK   r7   r7   r7   r8   C   s   r|   re    z+NotImplemented should have caused TypeError)ru   r=   __bool__r%   	TypeErrorfail)r2   r|   r7   r7   r8   	test_ints   s    zOperatorsTest.test_intsc             C   s   |  dd d S )Ng      Y@g      @)ru   )r2   r7   r7   r8   test_floats   s    zOperatorsTest.test_floatsc             C   s   | j ddddddddd	d
dg	d G dd dt}|ddd}| t|d | |jd ||dd}| t|d | |jd |d}| t|d | |jd d S )Ny              Y@y              @r   r   r!   r"   r%   r&   r   r
   mod)rt   c               @   s&   e Zd ZdgZdd Zdd ZeZdS )z,OperatorsTest.test_complexes.<locals>.Numberprecc             _   s"   t j| f| }|dd|_|S )Nr      )complex__new__getr   )clsr3   kwdsresultr7   r7   r8   r     s    z4OperatorsTest.test_complexes.<locals>.Number.__new__c             S   sJ   | j }| jdkrd|| jf S | jdkr6d|| jf S d|| j|| jf S )Ng        z%.*gz%.*gjz(%.*g+%.*gj))r   imagreal)r2   r   r7   r7   r8   rn     s    

z5OperatorsTest.test_complexes.<locals>.Number.__repr__N)ry   rz   r{   	__slots__r   rn   __str__r7   r7   r7   r8   Number  s   r   gQ	@rf   )r   z3.14r^   z3.1g     Pm@z234.5r   )ru   r   r=   rm   r   )r2   r   r;   r7   r7   r8   test_complexes   s    zOperatorsTest.test_complexesc             C   s2   |  tddtdd |  tddd d S )Ny              @g      @g      @r]   g       )r=   r   __radd__r&   __rsub__)r2   r7   r7   r8   test_explicit_reverse_methods   s    z+OperatorsTest.test_explicit_reverse_methodsz"the module 'xxsubtype' is internalc             C   sX  dd l }dd l}d"dd}||j|j< | |dg|dg|ddgdd | |dddgddd	d
 | |dddgddd	d
 | |dddgdddd | |dddgdd|ddgdd | |dg|dg|ddgdd | |ddgd|ddddddgdd | |dddgddd | |ddgd|ddddddgdd | |ddgd|ddddddgdd | |ddgdd|ddgdd | 	|ddddgdd|ddg|ddddgdd G dd d|j}| }| 
|g  | 
| d |d  | 
|d g | 
| d |d! | 
| d! d S )#Nr   c             S   s   dd l }|| S )Nr   )	xxsubtypespamlist)rq   memospamr7   r7   r8   r   *  s    z/OperatorsTest.test_spam_lists.<locals>.spamlistr]   r^   za+brK   r_   zb in ar`   ra   za[b]rO   za[b:c]za+=brT   za*=brb   zlen(a)r:   za*brc   zb*ard   za[b]=crY   re   rf   za[b:c]=dc               @   s   e Zd Zdd ZdS )z(OperatorsTest.test_spam_lists.<locals>.Cc             S   s   dS )Nr]   r7   )r2   r7   r7   r8   fooG      z,OperatorsTest.test_spam_lists.<locals>.C.fooN)ry   rz   r{   r   r7   r7   r7   r8   r|   F  s   r|   rv   *   )N)copyr   _deepcopy_dispatchr   rM   rR   rW   rI   rZ   r\   r=   r   ri   getstatesetstate)r2   r   r   r   r|   r;   r7   r7   r8   test_spam_lists%  s@    
   $$$ 

zOperatorsTest.test_spam_listsc          
   C   s$  dd l }dd l}ddd}||j|j< | |ddddddd	 | |ddddddd	 | |dddddd
d |ddd}g }xt| D ]}|| qW g }xt|D ]}|| qW | 	|| g }x|
 D ]}|| qW | 	|| g }x&t|i 
|D ]}|| qW | 	|| ddd}||}	| |	ddd | |	t|dd | |ddddd|dddddd G dd d|j}
|
 }| 	t| g  | 	| d d|d< | 	t| dg | 	| d |d | 	| d d S )Nr   c             S   s6   dd l }| }x t|  D ]\}}|||< qW |S )Nr   )r   spamdictr.   r/   )rE   r   r   sdkvr7   r7   r8   r   U  s
    z/OperatorsTest.test_spam_dicts.<locals>.spamdictr^   ra   )r]   r_   r]   zb in ar`   za[b]rO   zlen(a)r:   zrepr(a)rn   r_   )r]   r^   r_   za[b]=crY   c               @   s   e Zd Zdd ZdS )z(OperatorsTest.test_spam_dicts.<locals>.Cc             S   s   dS )Nr]   r7   )r2   r7   r7   r8   r   y  r   z,OperatorsTest.test_spam_dicts.<locals>.C.fooN)ry   rz   r{   r   r7   r7   r7   r8   r|   x  s   r|   barr   )r   r   rv   )N)r   r   r   r   rM   r.   rh   ri   rj   r=   rk   r?   rI   rm   rZ   r/   r   r   r   )r2   r   r   r   rE   ro   rp   rq   Z	straightdZspamdr|   r;   r7   r7   r8   test_spam_dictsQ  sJ    

"
zOperatorsTest.test_spam_dictsc             C   s   |  ttj tj d S )N)r=   rangesysmaxsizer:   )r2   r7   r7   r8   test_wrap_lenfunc_bad_cast  s    z(OperatorsTest.test_wrap_lenfunc_bad_castN)r9   r:   )rJ   rK   )rN   rO   )rS   rT   )rX   rY   )r[   rY   )ry   rz   r{   r,   rI   rM   rR   rW   rZ   r\   rg   rr   ru   r   r   r   r   r   impl_detailr   r   r   r7   r7   r7   r8   r      s"   0





!,2r   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 fd)d*Zejd+d, Zed-d.d/ Zd0d1 Zejd2d3 Zed-d4d5 Zd6d7 Z d8d9 Z!d:d; Z"e#j$d<d= Z%d>d? Z&e#j$d@dA Z'dBdC Z(dDdE Z)dFdG Z*dHdI Z+dJdK Z,dLdM Z-dNdO Z.e#/e0j1j2dPkdQdRdS Z3ej4dTdU Z5dVdW Z6dXdY Z7dZd[ Z8 fd\d]Z9d^d_ Z:d`da Z;dbdc Z<ddde Z=dfdg Z>dhdi Z?djdk Z@dldm ZAdndo ZBdpdq ZCdrds ZDdtdu ZEdvdw ZFdxdy ZGdzd{ ZHd|d} ZId~d ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^eddd Z_dd Z`dd Zadd Zbdd Zcdd Zddd Zedd Zfdd Zgdd Zhdd Zidd Zjdd ZkddĄ ZlddƄ ZmddȄ Znddʄ Zodd̄ Zpdd΄ ZqddЄ Zrdd҄ ZsddԄ Ztddք Zudd؄ Zvddڄ Zwdd܄ Zx fddބZy  ZzS )ClassPropertiesAndMethodsc             C   s   |  t||d||f  d S )Nz%r has no attribute %r)
assertTruers   )r2   objr5   r7   r7   r8   assertHasAttr  s    z'ClassPropertiesAndMethods.assertHasAttrc             C   s   |  t||d||f  d S )Nz%r has unexpected attribute %r)assertFalsers   )r2   r   r5   r7   r7   r8   assertNotHasAttr  s    z*ClassPropertiesAndMethods.assertNotHasAttrc       	         s    ttt  i t t } |i   |jt  |t G  fdddt}  t|t |d} |jd |ddd} |d dko|d d | } |jd	  | d	 |	d
  |jd
  | d
 |	d  |jd  | d  |d d
 d|d<  |d d d}x@t
|D ]4}| ||< x"t
|D ]}|| || |< qlW qTW x>t
|D ]2}x*t
|D ]} || | ||  qW qW d S )Nc                   s@   e Zd ZdZ fddZdd Z fddZdd	 Zd
d ZdS )z6ClassPropertiesAndMethods.test_python_dicts.<locals>.Cc                sH   |r  t|d |d | _|rDx t| D ]\}}|| |< q0W d S )Nr]   r   )r=   lenstater.   r/   )
self_localr;   kwr   r   )r2   r7   r8   r,     s    
z?ClassPropertiesAndMethods.test_python_dicts.<locals>.C.__init__c             S   s   |  |dS )Nr   )r   )r2   keyr7   r7   r8   rO     s    zBClassPropertiesAndMethods.test_python_dicts.<locals>.C.__getitem__c                s"     |td t| || d S )Nr   )assertIsInstancer?   rl   rY   )r   r   value)r2   r7   r8   rY     s    zBClassPropertiesAndMethods.test_python_dicts.<locals>.C.__setitem__c             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r     s    z?ClassPropertiesAndMethods.test_python_dicts.<locals>.C.setstatec             S   s   | j S )N)r   )r2   r7   r7   r8   r     s    z?ClassPropertiesAndMethods.test_python_dicts.<locals>.C.getstateN)	ry   rz   r{   r   r,   rO   rY   r   r   r7   )r2   r7   r8   r|     s   r|   r   r]   r^   )r   r   r   r   r   r   
   r      2   )r   
issubclassrl   r   r=   assertIs	__class__r   r   r   r   )	r2   rE   r|   a1a2r;   Nrp   jr7   )r2   r8   test_python_dicts  s@    


z+ClassPropertiesAndMethods.test_python_dictsc             C   sn   G dd dt }| }|dddg | |d d | |d d | |d d | |dd	 d
 d S )Nc               @   s   e Zd Zdd ZdS )z6ClassPropertiesAndMethods.test_python_lists.<locals>.Cc             S   s&   t |tr|j|jfS t| |d S )Nrv   )
isinstancerQ   startstopr.   rO   )r2   rp   r7   r7   r8   rO     s    
zBClassPropertiesAndMethods.test_python_lists.<locals>.C.__getitem__N)ry   rz   r{   rO   r7   r7   r7   r8   r|     s   r|   r   r]   r^   rv   e   f      )rv   r   )r.   extendr=   )r2   r|   r;   r7   r7   r8   test_python_lists  s    z+ClassPropertiesAndMethods.test_python_listsc          	      sB  G dd dt d}| }| | d |d | | d G dd dt }G dd	 d	|d}| | | | }| |j| G d
d dt }G dd d|d}| |jd | }| |jd G dd dtG fdddt}G dd d|d}| |jd | |j	d | 
d|j | }| | d G fdddt G dd dd}	G dd d|	}
G dd d|	}G dd	 d	||
}| |  d G dd  d |
|}| |  d! G fd"d#d#t G d$d dd}	|	 }| |d% d&|_| |jd& | |jd' G d(d) d)}G d*d d|d}	G d+d d|	}
G d,d d|	}G d-d	 d	||
}| | jd G  fd.d/d/t  G d0d d d}|  jd | }| t || |  jd G d1d dt}| }y
|  W n tk
r   Y nX | d2 G d3d dt }	G d4d dt}
G d5d dt|	d}G d6d	 d	|
|}| |	t | g G fd7d8d8t }G fd9d:d:|}G d;d d|d}	| d8g   G d<d d|d}
| d:d8g   G d=d d|	|
}| d:d8g   | 
d>|j G d?d@ d@|
|	}| d:d8g   | 
d>|j G dAd	 d	|t d}| d:d8g   | 
d>|j G dBd  d ||d}| d:d8g   | 
d>|j t fdCdD}G dEdF dF|d}G dGdH dHt|d}G dIdJ dJ||d}| | | | | | g G fdKdLdL}G fdMdNdN|}G dOd d|d}	| |t |	 | dLg   | dLg   G dPd d|d}
| |t |
 | dNdLg   | dNdLg   G dQd d|	|
}| |t | | dNdLg   | dNdLg   G dRd@ d@|
|	}| |t | | dNdLg   | dNdLg   | t G dSd	 d	|t d}W d Q R X G dTd  d ||d}| |t | | dNdLg   | dNdLg   G dUdV dVt |}| |t | | dNdLg   | dNdLg   G dWdX dX|t }| |t | | dNdLg   | dNdLg   | t G dYdF dF|t }W d Q R X | t G dZdF dFt |}W d Q R X d S )[Nc               @   s$   e Zd Zdd Zdd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Cc             S   s
   d| _ d S )Nr   )	_C__state)r2   r7   r7   r8   r,     s    z<ClassPropertiesAndMethods.test_metaclass.<locals>.C.__init__c             S   s   | j S )N)r   )r2   r7   r7   r8   r     s    z<ClassPropertiesAndMethods.test_metaclass.<locals>.C.getstatec             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r     s    z<ClassPropertiesAndMethods.test_metaclass.<locals>.C.setstateN)ry   rz   r{   r,   r   r   r7   r7   r7   r8   r|     s   r|   )	metaclassr   r   c               @   s   e Zd Zdd ZdS )z<ClassPropertiesAndMethods.test_metaclass.<locals>._metaclassc             S   s   | S )Nr7   )r   r7   r7   r8   myself  r   zCClassPropertiesAndMethods.test_metaclass.<locals>._metaclass.myselfN)ry   rz   r{   r   r7   r7   r7   r8   
_metaclass  s   r   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   D  s   r   c               @   s   e Zd Zdd ZdS )z4ClassPropertiesAndMethods.test_metaclass.<locals>.M1c             S   s   d|d< t | |||S )Nr]   __spam__)r?   r   )r   r5   basesrl   r7   r7   r8   r     s    z<ClassPropertiesAndMethods.test_metaclass.<locals>.M1.__new__N)ry   rz   r{   r   r7   r7   r7   r8   M1  s   r   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r]   c               @   s   e Zd ZdS )z;ClassPropertiesAndMethods.test_metaclass.<locals>._instanceN)ry   rz   r{   r7   r7   r7   r8   	_instance  s   r   c                   s$   e Zd Zedd Z fddZdS )z4ClassPropertiesAndMethods.test_metaclass.<locals>.M2c             S   s    t | }||_||_||_|S )N)objectr   r5   r   rl   )r   r5   r   rl   r2   r7   r7   r8   r     s
    
z<ClassPropertiesAndMethods.test_metaclass.<locals>.M2.__new__c                s@     }x4| j D ]*}|drqt||| j | ||  qW |S )N__)rl   
startswithsetattr__get__)r2   itr   )r   r7   r8   __call__  s    
z=ClassPropertiesAndMethods.test_metaclass.<locals>.M2.__call__N)ry   rz   r{   staticmethodr   r   r7   )r   r7   r8   M2  s   r   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Cc             S   s   dS )Nr   r7   )r2   r7   r7   r8   r     s    z8ClassPropertiesAndMethods.test_metaclass.<locals>.C.spamN)ry   rz   r{   r   r7   r7   r7   r8   r|     s   r7   r   r   c                   s   e Zd Z fddZ  ZS )z;ClassPropertiesAndMethods.test_metaclass.<locals>.autosuperc                s^   t | | |||}x |d d dkr6|dd  }qW |rFd| }nd}t||t | |S )Nr]   _z
_%s__superZ__super)superr   r   )r   r5   r   rl   r   )r   	autosuperr7   r8   r     s    

zCClassPropertiesAndMethods.test_metaclass.<locals>.autosuper.__new__)ry   rz   r{   r   __classcell__r7   )r   )r   r8   r     s   r   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Ac             S   s   dS )NAr7   )r2   r7   r7   r8   rD     s    z8ClassPropertiesAndMethods.test_metaclass.<locals>.A.methN)ry   rz   r{   rD   r7   r7   r7   r8   r     s   r   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Bc             S   s   d| j   S )NB)	_B__superrD   )r2   r7   r7   r8   rD   !  s    z8ClassPropertiesAndMethods.test_metaclass.<locals>.B.methN)ry   rz   r{   rD   r7   r7   r7   r8   r      s   r   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Cc             S   s   d| j   S )Nr|   )	_C__superrD   )r2   r7   r7   r8   rD   $  s    z8ClassPropertiesAndMethods.test_metaclass.<locals>.C.methN)ry   rz   r{   rD   r7   r7   r7   r8   r|   #  s   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Dc             S   s   d| j   S )Nr   )	_D__superrD   )r2   r7   r7   r8   rD   '  s    z8ClassPropertiesAndMethods.test_metaclass.<locals>.D.methN)ry   rz   r{   rD   r7   r7   r7   r8   r   &  s   ZDCBAc               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Ec             S   s   d| j   S )NE)Z	_E__superrD   )r2   r7   r7   r8   rD   +  s    z8ClassPropertiesAndMethods.test_metaclass.<locals>.E.methN)ry   rz   r{   rD   r7   r7   r7   r8   r   *  s   r   ZEBCAc                   s   e Zd Z fddZ  ZS )z>ClassPropertiesAndMethods.test_metaclass.<locals>.autopropertyc       	         s   i }x|  D ]v\}}|drN|dd  }||d\}}|}||f||< q|dr|dd  }||d\}}|}||f||< qW x&|  D ]\}\}}t||||< qW t| | |||S )NZ_get_re   )NNZ_set_)r/   r   r   propertyr   r   )	r   r5   r   rl   hitsr   valr   set)r   autopropertyr7   r8   r   2  s     

zFClassPropertiesAndMethods.test_metaclass.<locals>.autoproperty.__new__)ry   rz   r{   r   r   r7   )r   )r   r8   r   /  s   r   c               @   s   e Zd Zdd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Ac             S   s   | j  S )N)_A__x)r2   r7   r7   r8   _get_xD  s    z:ClassPropertiesAndMethods.test_metaclass.<locals>.A._get_xc             S   s   | | _ d S )N)r   )r2   xr7   r7   r8   _set_xF  s    z:ClassPropertiesAndMethods.test_metaclass.<locals>.A._set_xN)ry   rz   r{   r   r   r7   r7   r7   r8   r   C  s   r   r   ic               @   s   e Zd ZdS )z@ClassPropertiesAndMethods.test_metaclass.<locals>.multimetaclassN)ry   rz   r{   r7   r7   r7   r8   multimetaclassN  s   r   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Ac             S   s   dS )Nr   r7   )r2   r7   r7   r8   r   R  s    z:ClassPropertiesAndMethods.test_metaclass.<locals>.A._get_xN)ry   rz   r{   r   r7   r7   r7   r8   r   Q  s   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Bc             S   s   d| j   S )Nr   )r   r   )r2   r7   r7   r8   r   U  s    z:ClassPropertiesAndMethods.test_metaclass.<locals>.B._get_xN)ry   rz   r{   r   r7   r7   r7   r8   r   T  s   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Cc             S   s   d| j   S )Nr|   )r   r   )r2   r7   r7   r8   r   X  s    z:ClassPropertiesAndMethods.test_metaclass.<locals>.C._get_xN)ry   rz   r{   r   r7   r7   r7   r8   r|   W  s   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Dc             S   s   d| j   S )Nr   )r   r   )r2   r7   r7   r8   r   [  s    z:ClassPropertiesAndMethods.test_metaclass.<locals>.D._get_xN)ry   rz   r{   r   r7   r7   r7   r8   r   Z  s   c                   s   e Zd ZdZ fddZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Tr   c                s     j d7  _ d S )Nr]   )counter)r2   r3   )Tr7   r8   r,   b  s    z<ClassPropertiesAndMethods.test_metaclass.<locals>.T.__init__N)ry   rz   r{   r   r,   r7   )r   r7   r8   r   `  s   r   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   d  s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   k  s    z5calling object w/o call method should raise TypeErrorc               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.Ac              _   s   t j| |S )N)r?   r   )r3   r4   r7   r7   r8   r   t  s    z;ClassPropertiesAndMethods.test_metaclass.<locals>.A.__new__N)ry   rz   r{   r   r7   r7   r7   r8   r   s  s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r   w  s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   z  s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r   ~  s   c                   s.   e Zd Ze fddZedd Z  ZS )z7ClassPropertiesAndMethods.test_metaclass.<locals>.AMetac                s    d t | |||S )NAMeta)ri   r   r   )mclsr5   r   ns)r   	new_callsr7   r8   r     s    
z?ClassPropertiesAndMethods.test_metaclass.<locals>.AMeta.__new__c             S   s   i S )Nr7   )r   r5   r   r7   r7   r8   __prepare__  s    zCClassPropertiesAndMethods.test_metaclass.<locals>.AMeta.__prepare__)ry   rz   r{   r   r   classmethodr   r   r7   )r   )r   r8   r     s   r   c                   s2   e Zd Ze fddZe fddZ  ZS )z7ClassPropertiesAndMethods.test_metaclass.<locals>.BMetac                s    d t | |||S )NBMeta)ri   r   r   )r   r5   r   r   )r   r   r7   r8   r     s    
z?ClassPropertiesAndMethods.test_metaclass.<locals>.BMeta.__new__c                s   t  ||}d|d< |S )NTBMeta_was_here)r   r   )r   r5   r   r   )r   r7   r8   r     s    zCClassPropertiesAndMethods.test_metaclass.<locals>.BMeta.__prepare__)ry   rz   r{   r   r   r   r   r   r7   )r   )r   r8   r     s   r   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r   c               @   s   e Zd ZdS )z4ClassPropertiesAndMethods.test_metaclass.<locals>.C2N)ry   rz   r{   r7   r7   r7   r8   C2  s   r   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r     s   c                 s    S )Nr7   )r3   r4   )markerr7   r8   func  s    z6ClassPropertiesAndMethods.test_metaclass.<locals>.funcc               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   X  s   r   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.YN)ry   rz   r{   r7   r7   r7   r8   Y  s   r  c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.ZN)ry   rz   r{   r7   r7   r7   r8   Z  s   r  c                   s.   e Zd Z fddZefddZ  ZS )z:ClassPropertiesAndMethods.test_metaclass.<locals>.ANotMetac                s    d t | S )NANotMeta)ri   r   r   )r   r3   r4   )r   r   r7   r8   r     s    
zBClassPropertiesAndMethods.test_metaclass.<locals>.ANotMeta.__new__c                s     d i S )Nr  )ri   )r   r5   r   )prepare_callsr7   r8   r     s    
zFClassPropertiesAndMethods.test_metaclass.<locals>.ANotMeta.__prepare__)ry   rz   r{   r   r   r   r   r7   )r   r  )r   r8   r    s   r  c                   s0   e Zd Z fddZe fddZ  ZS )z:ClassPropertiesAndMethods.test_metaclass.<locals>.BNotMetac                s    d t | S )NBNotMeta)ri   r   r   )r   r3   r4   )r   r   r7   r8   r     s    
zBClassPropertiesAndMethods.test_metaclass.<locals>.BNotMeta.__new__c                s    d t ||S )Nr  )ri   r   r   )r   r5   r   )r   r  r7   r8   r     s    
zFClassPropertiesAndMethods.test_metaclass.<locals>.BNotMeta.__prepare__)ry   rz   r{   r   r   r   r   r7   )r   r  )r   r8   r    s   r  c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   c               @   s   e Zd ZdS )z4ClassPropertiesAndMethods.test_metaclass.<locals>.C2N)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.FN)ry   rz   r{   r7   r7   r7   r8   F  s   r  c               @   s   e Zd ZdS )z4ClassPropertiesAndMethods.test_metaclass.<locals>.F2N)ry   rz   r{   r7   r7   r7   r8   F2  s   r  c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r   #  s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_metaclass.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r   &  s   )r?   r=   r   r   r   r   r   r   r5   r   assertInrl   r   rD   r   r   r   r   r   r   r   clearrA   assertRaisesr%   )r2   r|   r;   r   r   rE   r   rP   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r7   )r   r   r   r   r   r   r  r8   test_metaclass  s$   
 
 
		z(ClassPropertiesAndMethods.test_metaclassc                s   g t t G  fddd }|d}d|_|j}|`| dddg yG dd	 d	tjt}W n tk
rx   Y nX | d
 d S )Nc                   sB   e Zd Z fddZ fddZ fddZ fddZd	S )
z<ClassPropertiesAndMethods.test_module_subclasses.<locals>.MMc                s     | | d S )N)r,   )r2   r5   )MTr7   r8   r,   .  s    zEClassPropertiesAndMethods.test_module_subclasses.<locals>.MM.__init__c                s    d|f  | |S )Nr@   )ri   __getattribute__)r2   r5   )r  logr7   r8   r  0  s    zMClassPropertiesAndMethods.test_module_subclasses.<locals>.MM.__getattribute__c                s"    d||f  | || d S )Nr   )ri   __setattr__)r2   r5   r   )r  r  r7   r8   r  3  s    zHClassPropertiesAndMethods.test_module_subclasses.<locals>.MM.__setattr__c                s    d|f  | | d S )Ndelattr)ri   __delattr__)r2   r5   )r  r  r7   r8   r  6  s    zHClassPropertiesAndMethods.test_module_subclasses.<locals>.MM.__delattr__N)ry   rz   r{   r,   r  r  r  r7   )r  r  r7   r8   MM-  s   r  r;   r   )r   r   r   )r@   r   )r  r   c               @   s   e Zd ZdS )z@ClassPropertiesAndMethods.test_module_subclasses.<locals>.ModuleN)ry   rz   r{   r7   r7   r7   r8   ModuleC  s   r  z?inheriting from ModuleType and str at the same time should fail)	r?   r   r   r=   types
ModuleTypestrr   r   )r2   r  r;   r   r  r7   )r  r  r8   test_module_subclasses)  s    z0ClassPropertiesAndMethods.test_module_subclassesc                sL  G dd dt    }| | d |d | | d G  fdddt }| }| t| g  d|d< | t| d	g | |d d | | d |d | | d | |j|t t f G d
d dt }G dd d|t}| | 	 d | t
| d | | 	 d | t
| d d S )Nc               @   s$   e Zd Zdd Zdd Zdd ZdS )z>ClassPropertiesAndMethods.test_multiple_inheritance.<locals>.Cc             S   s
   d| _ d S )Nr   )r   )r2   r7   r7   r8   r,   N  s    zGClassPropertiesAndMethods.test_multiple_inheritance.<locals>.C.__init__c             S   s   | j S )N)r   )r2   r7   r7   r8   r   P  s    zGClassPropertiesAndMethods.test_multiple_inheritance.<locals>.C.getstatec             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r   R  s    zGClassPropertiesAndMethods.test_multiple_inheritance.<locals>.C.setstateN)ry   rz   r{   r,   r   r   r7   r7   r7   r8   r|   M  s   r|   r   r   c                   s   e Zd Z fddZdS )z>ClassPropertiesAndMethods.test_multiple_inheritance.<locals>.Dc                s   t i |   |  d S )N)r?   r,   )r2   )r|   r7   r8   r,   Y  s    zGClassPropertiesAndMethods.test_multiple_inheritance.<locals>.D.__init__N)ry   rz   r{   r,   r7   )r|   r7   r8   r   X  s   r   worldhello)r  r  c               @   s   e Zd Zdd Zdd ZdS )zAClassPropertiesAndMethods.test_multiple_inheritance.<locals>.Nodec             S   s   t |  S )N)r%   r   )r2   r7   r7   r8   __int__h  s    zIClassPropertiesAndMethods.test_multiple_inheritance.<locals>.Node.__int__c             S   s   dS )NZ23r7   )r2   r7   r7   r8   r   j  s    zEClassPropertiesAndMethods.test_multiple_inheritance.<locals>.Node.fooN)ry   rz   r{   r  r   r7   r7   r7   r8   Nodeg  s   r  c               @   s   e Zd Zdd ZdS )zAClassPropertiesAndMethods.test_multiple_inheritance.<locals>.Fragc             S   s   dS )NZ42r7   )r2   r7   r7   r8   r   m  s    zEClassPropertiesAndMethods.test_multiple_inheritance.<locals>.Frag.fooN)ry   rz   r{   r   r7   r7   r7   r8   Fragl  s   r     r   )r   r=   r   r   rl   r.   rh   r/   __mro__r  r%   )r2   r;   r   rE   r  r  r7   )r|   r8   test_multiple_inheritanceK  s*    

z3ClassPropertiesAndMethods.test_multiple_inheritancec             C   s  G dd dt }| |  d G dd d|}| |  d | |  d G dd d|}| |  d | |  d G dd d||}| |  d | |  d | |j||||t f G d	d
 d
||}| |  d | |  d | |j||||t f yG dd d||}W n tk
rR   Y nX | d yG dd d||}W n tk
r   Y nX | d d S )Nc               @   s   e Zd Zdd ZdS )z=ClassPropertiesAndMethods.test_diamond_inheritance.<locals>.Ac             S   s   dS )Nr   r7   )r2   r7   r7   r8   r   w  r   zBClassPropertiesAndMethods.test_diamond_inheritance.<locals>.A.spamN)ry   rz   r{   r   r7   r7   r7   r8   r   v  s   r   c               @   s   e Zd Zdd Zdd ZdS )z=ClassPropertiesAndMethods.test_diamond_inheritance.<locals>.Bc             S   s   dS )Nr   r7   )r2   r7   r7   r8   booz  r   zAClassPropertiesAndMethods.test_diamond_inheritance.<locals>.B.booc             S   s   dS )Nr   r7   )r2   r7   r7   r8   r   {  r   zBClassPropertiesAndMethods.test_diamond_inheritance.<locals>.B.spamN)ry   rz   r{   r   r   r7   r7   r7   r8   r   y  s   r   c               @   s   e Zd Zdd ZdS )z=ClassPropertiesAndMethods.test_diamond_inheritance.<locals>.Cc             S   s   dS )Nr|   r7   )r2   r7   r7   r8   r     r   zAClassPropertiesAndMethods.test_diamond_inheritance.<locals>.C.booN)ry   rz   r{   r   r7   r7   r7   r8   r|   ~  s   r|   c               @   s   e Zd ZdS )z=ClassPropertiesAndMethods.test_diamond_inheritance.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z=ClassPropertiesAndMethods.test_diamond_inheritance.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z=ClassPropertiesAndMethods.test_diamond_inheritance.<locals>.FN)ry   rz   r{   r7   r7   r7   r8   r    s    r  z#expected MRO order disagreement (F)c               @   s   e Zd ZdS )z=ClassPropertiesAndMethods.test_diamond_inheritance.<locals>.GN)ry   rz   r{   r7   r7   r7   r8   G  s    r!  z#expected MRO order disagreement (G))r   r=   r   r   r  r   r   )r2   r   r   r|   r   r   r  r!  r7   r7   r8   test_diamond_inheritancet  s4    
z2ClassPropertiesAndMethods.test_diamond_inheritancec          
   C   s   G dd dt }G dd dt }G dd dt }G dd d|}G d	d
 d
|}G dd d||||}| |j||||||t f d S )Nc               @   s   e Zd ZdS )z<ClassPropertiesAndMethods.test_ex5_from_c3_switch.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z<ClassPropertiesAndMethods.test_ex5_from_c3_switch.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z<ClassPropertiesAndMethods.test_ex5_from_c3_switch.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s    r|   c               @   s   e Zd ZdS )z<ClassPropertiesAndMethods.test_ex5_from_c3_switch.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z<ClassPropertiesAndMethods.test_ex5_from_c3_switch.<locals>.YN)ry   rz   r{   r7   r7   r7   r8   r    s    r  c               @   s   e Zd ZdS )z<ClassPropertiesAndMethods.test_ex5_from_c3_switch.<locals>.ZN)ry   rz   r{   r7   r7   r7   r8   r    s    r  )r   r=   r  )r2   r   r   r|   r   r  r  r7   r7   r8   test_ex5_from_c3_switch  s    z1ClassPropertiesAndMethods.test_ex5_from_c3_switchc       	      C   s   G dd dt }G dd d|}G dd d|}G dd d|}G d	d
 d
|}G dd d||}G dd d|}G dd d||}| |j|||||t f | |j||||t f | |j||||||||t f	 d S )Nc               @   s   e Zd ZdS )z9ClassPropertiesAndMethods.test_monotonicity.<locals>.BoatN)ry   rz   r{   r7   r7   r7   r8   Boat  s    r$  c               @   s   e Zd ZdS )z<ClassPropertiesAndMethods.test_monotonicity.<locals>.DayBoatN)ry   rz   r{   r7   r7   r7   r8   DayBoat  s    r%  c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_monotonicity.<locals>.WheelBoatN)ry   rz   r{   r7   r7   r7   r8   	WheelBoat  s    r&  c               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_monotonicity.<locals>.EngineLessN)ry   rz   r{   r7   r7   r7   r8   
EngineLess  s    r'  c               @   s   e Zd ZdS )zCClassPropertiesAndMethods.test_monotonicity.<locals>.SmallMultihullN)ry   rz   r{   r7   r7   r7   r8   SmallMultihull  s    r(  c               @   s   e Zd ZdS )zCClassPropertiesAndMethods.test_monotonicity.<locals>.PedalWheelBoatN)ry   rz   r{   r7   r7   r7   r8   PedalWheelBoat  s    r)  c               @   s   e Zd ZdS )zCClassPropertiesAndMethods.test_monotonicity.<locals>.SmallCatamaranN)ry   rz   r{   r7   r7   r7   r8   SmallCatamaran  s    r*  c               @   s   e Zd ZdS )z;ClassPropertiesAndMethods.test_monotonicity.<locals>.PedaloN)ry   rz   r{   r7   r7   r7   r8   Pedalo  s    r+  )r   r=   r  )	r2   r$  r%  r&  r'  r(  r)  r*  r+  r7   r7   r8   test_monotonicity  s    z+ClassPropertiesAndMethods.test_monotonicityc          
   C   s   G dd dt }G dd dt }G dd dt }G dd d||}G d	d
 d
||}G dd d||}| |j||||||t f d S )Nc               @   s   e Zd ZdS )zAClassPropertiesAndMethods.test_consistency_with_epg.<locals>.PaneN)ry   rz   r{   r7   r7   r7   r8   Pane  s    r-  c               @   s   e Zd ZdS )zKClassPropertiesAndMethods.test_consistency_with_epg.<locals>.ScrollingMixinN)ry   rz   r{   r7   r7   r7   r8   ScrollingMixin  s    r.  c               @   s   e Zd ZdS )zIClassPropertiesAndMethods.test_consistency_with_epg.<locals>.EditingMixinN)ry   rz   r{   r7   r7   r7   r8   EditingMixin  s    r/  c               @   s   e Zd ZdS )zKClassPropertiesAndMethods.test_consistency_with_epg.<locals>.ScrollablePaneN)ry   rz   r{   r7   r7   r7   r8   ScrollablePane  s    r0  c               @   s   e Zd ZdS )zIClassPropertiesAndMethods.test_consistency_with_epg.<locals>.EditablePaneN)ry   rz   r{   r7   r7   r7   r8   EditablePane  s    r1  c               @   s   e Zd ZdS )zSClassPropertiesAndMethods.test_consistency_with_epg.<locals>.EditableScrollablePaneN)ry   rz   r{   r7   r7   r7   r8   EditableScrollablePane  s    r2  )r   r=   r  )r2   r-  r.  r/  r0  r1  r2  r7   r7   r8   test_consistency_with_epg  s    z3ClassPropertiesAndMethods.test_consistency_with_epgc                s   d} fdd}G dd dt }G dd d|}G dd	 d	t }|td
td||fi  |t|td||fi  |t|td|||fi  G dd dt }G dd d|}G dd d|}G dd d||}	G dd d||}
|t|td|	|
fi  d S )NzCCannot create a consistent method resolution
order (MRO) for bases c          
      sn   y||  W nN | k
rZ } z0t  rJt||sJ dt||f  W d d }~X Y nX  d|   d S )NzMessage %r, expected %rzExpected %s)r   check_impl_detailr  r   r   )excexpectedcallabler3   msg)r2   r7   r8   raises  s    "z?ClassPropertiesAndMethods.test_mro_disagreement.<locals>.raisesc               @   s   e Zd ZdS )z:ClassPropertiesAndMethods.test_mro_disagreement.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z:ClassPropertiesAndMethods.test_mro_disagreement.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z:ClassPropertiesAndMethods.test_mro_disagreement.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s    r|   zduplicate base class Ar   c               @   s   e Zd ZdS )zCClassPropertiesAndMethods.test_mro_disagreement.<locals>.GridLayoutN)ry   rz   r{   r7   r7   r7   r8   
GridLayout  s    r:  c               @   s   e Zd ZdS )zGClassPropertiesAndMethods.test_mro_disagreement.<locals>.HorizontalGridN)ry   rz   r{   r7   r7   r7   r8   HorizontalGrid  s    r;  c               @   s   e Zd ZdS )zEClassPropertiesAndMethods.test_mro_disagreement.<locals>.VerticalGridN)ry   rz   r{   r7   r7   r7   r8   VerticalGrid  s    r<  c               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_mro_disagreement.<locals>.HVGridN)ry   rz   r{   r7   r7   r7   r8   HVGrid  s    r=  c               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_mro_disagreement.<locals>.VHGridN)ry   rz   r{   r7   r7   r7   r8   VHGrid  s    r>  ZConfusedGrid)r   r   r?   )r2   Zmro_err_msgr9  r   r   r|   r:  r;  r<  r=  r>  r7   )r2   r8   test_mro_disagreement  s$    z/ClassPropertiesAndMethods.test_mro_disagreementc          	   C   s   t  }| |jt  | t|t  t  }| || | |d y
d|_W n ttfk
rd   Y nX | 	d | t  d G dd dt }| }| |j
i  d|_| |jd | |j
ddi d S )Nr   r   z1object() should not allow setting a foo attributerA   c               @   s   e Zd ZdS )z:ClassPropertiesAndMethods.test_object_class.<locals>.CdictN)ry   rz   r{   r7   r7   r7   r8   Cdict  s   r@  r]   )r   r=   r   r?   assertNotEqualr   r   AttributeErrorr   r   rA   )r2   r;   rL   r@  r   r7   r7   r8   test_object_class  s$    

z+ClassPropertiesAndMethods.test_object_classc       
   	   C   s  G dd dt j}t d}| |jt jk | t|d ||_| |j|k | t|d t j|_| |jt jk | t|d G dd dt}| t |d_W d Q R X G dd	 d	t	}| t |d
_W d Q R X G dd dt
}| t |d_W d Q R X G dd dt}| t |d_W d Q R X G dd dt}| t |d_W d Q R X G dd dt}| t |d_W d Q R X G dd dt}	| t |	t _W d Q R X d S )Nc               @   s   e Zd ZdZdS )zjClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes.<locals>.SubTyper]   N)ry   rz   r{   r;   r7   r7   r7   r8   SubType  s   rD  rG   r;   c               @   s   e Zd ZdZdS )zhClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes.<locals>.MyIntr7   N)ry   rz   r{   r   r7   r7   r7   r8   MyInt  s   rE  r]   c               @   s   e Zd ZdZdS )zjClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes.<locals>.MyFloatr7   N)ry   rz   r{   r   r7   r7   r7   r8   MyFloat#  s   rF  g      ?c               @   s   e Zd ZdZdS )zlClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes.<locals>.MyComplexr7   N)ry   rz   r{   r   r7   r7   r7   r8   	MyComplex(  s   rG  y      ?       @c               @   s   e Zd ZdZdS )zhClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes.<locals>.MyStrr7   N)ry   rz   r{   r   r7   r7   r7   r8   MyStr-  s   rH  c               @   s   e Zd ZdZdS )zjClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes.<locals>.MyBytesr7   N)ry   rz   r{   r   r7   r7   r7   r8   MyBytes2  s   rI     ac               @   s   e Zd ZdZdS )zjClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes.<locals>.MyTupler7   N)ry   rz   r{   r   r7   r7   r7   r8   MyTuple7  s   rK  r7   c               @   s   e Zd ZdZdS )znClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes.<locals>.MyFrozenSetr7   N)ry   rz   r{   r   r7   r7   r7   r8   MyFrozenSet<  s   rL  )r  r  r   r   r   rs   r%   r
  r   r&   r   r  bytestuple	frozenset)
r2   rD  rG   rE  rF  rG  rH  rI  rK  rL  r7   r7   r8   ?test_object_class_assignment_between_heaptypes_and_nonheaptypes  s>    
zYClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypesc          	      s  G dd dt }| }|d |d G dd dt }| }|d |d d|_|jd d |_|jd  |`|d G d	d
 d
t }| }|d |d |d |d d|_d|_d|_|jd |jd |jd G dd dt }|d}|d |d | d y
d|_W n tk
rv   Y nX 	d yG dd dt }W n t
k
r   Y nX 	d yG dd dt }W n t
k
r   Y nX 	d yG dd dt }W n t
k
r   Y nX 	d yG dd dt }W n t
k
rN   Y nX 	d yG dd dt }W n t
k
r   Y nX 	d G d d dt }G d!d dt }| }d|_|jd G d"d dt }| }d|_|jd d#G fd$ddt }| }d|_|jd td% t yG d&d dt }W n t
tfk
rh   Y nX 	d' G  fd(d)d)t  G d*d dt }| }  |_  |_  |_ jd ~t   jd% G d+d, d,|}| }  |_  |_ jd ~t   jd% G d-d. d.|}	|	 }  |_  |_  |_ jd ~t   jd% G d/d0 d0t }
|
 }  |g|_ jd d }t   jd% ttd1r(G d2d3 d3t }| }tt }xtd4D ]}||k qW tt }|| G fd5d6d6t }td7}| }~W d Q R X | d8 G d9d: d:t }t | `W d Q R X d S );Nc               @   s   e Zd Zg ZdS )z0ClassPropertiesAndMethods.test_slots.<locals>.C0N)ry   rz   r{   r   r7   r7   r7   r8   C0C  s   rQ  rA   r   c               @   s   e Zd ZdgZdS )z0ClassPropertiesAndMethods.test_slots.<locals>.C1r;   N)ry   rz   r{   r   r7   r7   r7   r8   C1I  s   rR  r;   r]   c               @   s   e Zd ZdddgZdS )z0ClassPropertiesAndMethods.test_slots.<locals>.C3r;   rL   rP   N)ry   rz   r{   r   r7   r7   r7   r8   C3U  s   rS  rL   rP   r^   r_   c               @   s&   e Zd ZdZdgZdd Zdd ZdS )z0ClassPropertiesAndMethods.test_slots.<locals>.C4zValidate name mangling__ac             S   s
   || _ d S )N)_C4__a)r2   r   r7   r7   r8   r,   f  s    z9ClassPropertiesAndMethods.test_slots.<locals>.C4.__init__c             S   s   | j S )N)rU  )r2   r7   r7   r8   r   h  s    z4ClassPropertiesAndMethods.test_slots.<locals>.C4.getN)ry   rz   r{   __doc__r   r,   r   r7   r7   r7   r8   C4c  s   rW  re   rT  rf   z$Double underscored names not mangledc               @   s   e Zd ZdgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.CN)ry   rz   r{   r   r7   r7   r7   r8   r|   w  s   r|   z[None] slots not caughtc               @   s   e Zd ZdgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Czfoo barN)ry   rz   r{   r   r7   r7   r7   r8   r|   ~  s   z['foo bar'] slots not caughtc               @   s   e Zd ZdgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Czfoo barN)ry   rz   r{   r   r7   r7   r7   r8   r|     s   z['foo\0bar'] slots not caughtc               @   s   e Zd ZdgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.C1N)ry   rz   r{   r   r7   r7   r7   r8   r|     s   z['1'] slots not caughtc               @   s   e Zd ZdgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Cr}   N)ry   rz   r{   r   r7   r7   r7   r8   r|     s   z[''] slots not caughtc               @   s   e Zd ZddddgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Cr;   Za_bZ_aZA0123456789ZN)ry   rz   r{   r   r7   r7   r7   r8   r|     s   c               @   s   e Zd ZdZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.CabcN)ry   rz   r{   r   r7   r7   r7   r8   r|     s   c               @   s   e Zd ZdZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.CrY  N)ry   rz   r{   r   r7   r7   r7   r8   r|     s   )r   r   c                   s   e Zd Z ZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.CN)ry   rz   r{   r   r7   )slotsr7   r8   r|     s   r   c               @   s   e Zd ZedgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.C   N)ry   rz   r{   chrr   r7   r7   r7   r8   r|     s   z[chr(128)] slots not caughtc                   s(   e Zd ZdZ fddZ fddZdS )z5ClassPropertiesAndMethods.test_slots.<locals>.Countedr   c                s     j d7  _ d S )Nr]   )r   )r2   )Countedr7   r8   r,     s    z>ClassPropertiesAndMethods.test_slots.<locals>.Counted.__init__c                s     j d8  _ d S )Nr]   )r   )r2   )r]  r7   r8   __del__  s    z=ClassPropertiesAndMethods.test_slots.<locals>.Counted.__del__N)ry   rz   r{   r   r,   r^  r7   )r]  r7   r8   r]    s   r]  c               @   s   e Zd ZdddgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Cr;   rL   rP   N)ry   rz   r{   r   r7   r7   r7   r8   r|     s   c               @   s   e Zd ZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.EeN)ry   rz   r{   r   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZddgZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Fr;   rL   N)ry   rz   r{   r   r7   r7   r7   r8   r    s   r  get_objectsc               @   s   e Zd Zdd ZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Gc             S   s   dS )NFr7   )r2   rx   r7   r7   r8   __eq__  s    z6ClassPropertiesAndMethods.test_slots.<locals>.G.__eq__N)ry   rz   r{   ra  r7   r7   r7   r8   r!    s   r!  r   c                   s(   e Zd ZddgZdd Z fddZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Hr;   rL   c             S   s   d| _ d| _d S )Nr]   r^   )r;   rL   )r2   r7   r7   r8   r,     s    z8ClassPropertiesAndMethods.test_slots.<locals>.H.__init__c                s      | jd   | jd d S )Nr]   r^   )r=   r;   rL   )self_)r2   r7   r8   r^    s    z7ClassPropertiesAndMethods.test_slots.<locals>.H.__del__N)ry   rz   r{   r   r,   r^  r7   )r2   r7   r8   H  s   rc  stderrr}   c               @   s   e Zd ZdZdS )z/ClassPropertiesAndMethods.test_slots.<locals>.Xr;   N)ry   rz   r{   r   r7   r7   r7   r8   r     s   r   )r   r   r;   r=   rL   rP   r   Z_ClassPropertiesAndMethods__arB  r   r   rY  r   r   r?   r  UnicodeEncodeErrorr   r   
gc_collectzr_  rs   gcr   r`  r   Zcaptured_outputgetvaluer
  )r2   rQ  r   rR  rS  rW  r|   rP   r   r   r  sr!  gZorig_objectsrp   Znew_objectsrc  hr   r7   )r]  r2   rZ  r8   
test_slotsA  s   







z$ClassPropertiesAndMethods.test_slotsc             C   s2  G dd dt }| }| |d | |d d|_| |jddi G dd dt }| }| |d | |d y
d|_W n tk
r   Y nX | d	 G d
d d||}| }| |d | |d d|_| |jddi G dd d||}| }| |d | |d d|_| |jddi d S )Nc               @   s   e Zd ZdgZdS )z7ClassPropertiesAndMethods.test_slots_special.<locals>.DrA   N)ry   rz   r{   r   r7   r7   r7   r8   r     s   r   rA   __weakref__r   r   c               @   s   e Zd ZdgZdS )z7ClassPropertiesAndMethods.test_slots_special.<locals>.Wrn  N)ry   rz   r{   r   r7   r7   r7   r8   W  s   ro  z!shouldn't be allowed to set a.fooc               @   s   e Zd Zg ZdS )z8ClassPropertiesAndMethods.test_slots_special.<locals>.C1N)ry   rz   r{   r   r7   r7   r7   r8   rR  !  s   rR  c               @   s   e Zd Zg ZdS )z8ClassPropertiesAndMethods.test_slots_special.<locals>.C2N)ry   rz   r{   r   r7   r7   r7   r8   r   )  s   r   )r   r   r   r   r=   rA   rB  r   )r2   r   r;   ro  rR  r   r7   r7   r8   test_slots_special  s6    

z,ClassPropertiesAndMethods.test_slots_specialc       	   	      s6  G  fdddt }G dd d}G dd d||dd} |jd tj | } |jd	  |d d	|_ |jd	  	t
 G d
d d}W d Q R X G dd d|dd} |j|jd d d   |jd tj | } |d d|_ |jd  	t
 G dd d}W d Q R X d S )Nc                   s   e Zd Z fddZ  ZS )z;ClassPropertiesAndMethods.test_slots_special2.<locals>.Metac                s    || t | |||S )N)r  r   r   )r   r5   r   	namespaceattr)r   r2   r7   r8   r   4  s    zCClassPropertiesAndMethods.test_slots_special2.<locals>.Meta.__new__)ry   rz   r{   r   r   r7   )r2   )r   r8   Meta3  s   rs  c               @   s   e Zd Zdd ZdS )z9ClassPropertiesAndMethods.test_slots_special2.<locals>.C1c             S   s
   d| _ d S )Nr   )rL   )r2   r7   r7   r8   r,   9  s    zBClassPropertiesAndMethods.test_slots_special2.<locals>.C1.__init__N)ry   rz   r{   r,   r7   r7   r7   r8   rR  8  s   rR  c                   s"   e Zd ZdgZ fddZ  ZS )z9ClassPropertiesAndMethods.test_slots_special2.<locals>.C2r   c                s   t    d S )N)r   r,   )r2   )r   r7   r8   r,   =  s    zBClassPropertiesAndMethods.test_slots_special2.<locals>.C2.__init__)ry   rz   r{   r   r,   r   r7   r7   )r   r8   r   ;  s   r   r   )r   rr  r   c               @   s   e Zd ZdZdgZdS )z9ClassPropertiesAndMethods.test_slots_special2.<locals>.C3r   r   N)ry   rz   r{   r   r   r7   r7   r7   r8   rS  G  s   rS  c               @   s   e Zd ZdgZdS )z9ClassPropertiesAndMethods.test_slots_special2.<locals>.Q1r{   N)ry   rz   r{   r   r7   r7   r7   r8   Q1K  s   rt  r{   qc               @   s   e Zd Ze ZdgZdS )z9ClassPropertiesAndMethods.test_slots_special2.<locals>.Q2r{   N)ry   rz   r{   r   r   r7   r7   r7   r8   Q2U  s   rw  )r?   r   rA   r  MemberDescriptorTyper=   rL   r   r   r
  r   r{   )	r2   rs  rR  r   rP   rS  rt  rv  rw  r7   )r2   r8   test_slots_special21  s,    z-ClassPropertiesAndMethods.test_slots_special2c             C   s`   dd l }G dd d|jd}G dd dt}|| | }| || | t|jj|d d S )Nr   c               @   s   e Zd ZdZdS )z>ClassPropertiesAndMethods.test_slots_descriptor.<locals>.MyABCr;   N)ry   rz   r{   r   r7   r7   r7   r8   MyABC]  s   rz  )r   c               @   s   e Zd ZdS )zBClassPropertiesAndMethods.test_slots_descriptor.<locals>.UnrelatedN)ry   rz   r{   r7   r7   r7   r8   	Unrelated`  s   r{  r_   )	rY  ABCMetar   registerr   r
  r   r;   __set__)r2   rY  rz  r{  ur7   r7   r8   test_slots_descriptorY  s    
z/ClassPropertiesAndMethods.test_slots_descriptorc             C   sJ  G dd dt }G dd d|}G dd d|}d|_| |jd | |jd | |jd G dd	 d	t }| }| |d
 d|_| |jd dd |_| | d dd |_| t|d dd |_| t	|d | |jd | |d dd }||_
| |jd d|_| |jd dd }||_y
d|_W n tk
r\   Y nX | d | |jd G dd d|}| }d|_| |jd G dd dt	}	| d|	d d | |	dd d | d|	d  d! | |	d d d! | |	d |	d d! G d"d# d#t}
G d$d% d%|
d&}| |t  d S )'Nc               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_dynamics.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r   l  s   r   c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_dynamics.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r   n  s   r   c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_dynamics.<locals>.FN)ry   rz   r{   r7   r7   r7   r8   r  p  s   r  r]   c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_dynamics.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   x  s   r|   foobarr^   c             S   s   dS )Nr   r7   )r2   r7   r7   r8   <lambda>~  r   z9ClassPropertiesAndMethods.test_dynamics.<locals>.<lambda>r   c             S   s   dS )NzC()r7   )r2   r7   r7   r8   r    r   zC()c             S   s   dS )Nrv   r7   )r2   r7   r7   r8   r    r   rv   r   c             S   s   |dkrdS t d S )Nr   )rB  )r2   r5   r7   r7   r8   	mygetattr  s    z:ClassPropertiesAndMethods.test_dynamics.<locals>.mygetattrr   c             S   s   |dkrt t| ||S )Nr   )rB  r   r  )r2   r5   r   r7   r7   r8   	mysetattr  s    z:ClassPropertiesAndMethods.test_dynamics.<locals>.mysetattrznot spamzexpected AttributeErrorc               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_dynamics.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_dynamics.<locals>.IN)ry   rz   r{   r7   r7   r7   r8   I  s   r  r;   Zaar_   rf   c               @   s   e Zd ZdS )zAClassPropertiesAndMethods.test_dynamics.<locals>.dynamicmetaclassN)ry   rz   r{   r7   r7   r7   r8   dynamicmetaclass  s   r  c               @   s   e Zd ZdS )z:ClassPropertiesAndMethods.test_dynamics.<locals>.someclassN)ry   rz   r{   r7   r7   r7   r8   	someclass  s   r  )r   )r   r   r=   r   r  methodrn   rm   r  r%   __getattr__r   newr  rB  r   r?   rA  )r2   r   r   r  r|   r;   r  r  rE   r  r  r  r7   r7   r8   test_dynamicsj  s\    




z'ClassPropertiesAndMethods.test_dynamicsc             C   s  yG dd dt t}W n tk
r*   Y nX | d yG dd dtd }W n tk
r`   Y nX | d G dd d}yG dd dtt}W n tk
r   Y nX | d	 yG d
d dt}W n tk
r   Y nX | d yG dd dt}W n tk
r   Y nX | d G dd dt}G dd dt}G dd dt|d}G dd dt|d}yG dd d||}W n tk
r   Y nX | d d S )Nc               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_errors.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r|   z5inheritance from both list and dict should be illegalc               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_errors.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   z+inheritance from non-type should be illegalc               @   s   e Zd ZdS )z6ClassPropertiesAndMethods.test_errors.<locals>.ClassicN)ry   rz   r{   r7   r7   r7   r8   Classic  s   r  c               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_errors.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   z,inheritance from CFunction should be illegalc               @   s   e Zd ZdZdS )z0ClassPropertiesAndMethods.test_errors.<locals>.Cr]   N)ry   rz   r{   r   r7   r7   r7   r8   r|     s   z__slots__ = 1 should be illegalc               @   s   e Zd ZdgZdS )z0ClassPropertiesAndMethods.test_errors.<locals>.Cr]   N)ry   rz   r{   r   r7   r7   r7   r8   r|     s   z!__slots__ = [1] should be illegalc               @   s   e Zd ZdS )z1ClassPropertiesAndMethods.test_errors.<locals>.M1N)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z1ClassPropertiesAndMethods.test_errors.<locals>.M2N)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z1ClassPropertiesAndMethods.test_errors.<locals>.A1N)ry   rz   r{   r7   r7   r7   r8   A1  s   r  )r   c               @   s   e Zd ZdS )z1ClassPropertiesAndMethods.test_errors.<locals>.A2N)ry   rz   r{   r7   r7   r7   r8   A2  s   r  c               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_errors.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   r   z5finding the most derived metaclass should have failed)r.   rl   r   r   r   r?   r   )r2   r|   r  r   r   r  r  r   r7   r7   r8   test_errors  sF    




z%ClassPropertiesAndMethods.test_errorsc       	         s&  G dd dt }| }| |d|df | |d|df | |d|df G dd d|}| }| |d|df | |d|df | |d|df | ||d|df dd }t|}| |dtd	td	f | |dd	td	f | |jj| | |jj| | t||jj| | t||jj| | t|| |f | t|| |f tdd}| 	t
| yt|dd
 W n t
k
r   Y nX | d t|}| |ji  d	|_| |jd	 | |jdd	i |`| |d d S )Nc               @   s   e Zd Zdd ZeeZdS )z6ClassPropertiesAndMethods.test_classmethods.<locals>.Cc              W   s   | S )Nr7   )r;   r7   r7   r8   r     r   z:ClassPropertiesAndMethods.test_classmethods.<locals>.C.fooN)ry   rz   r{   r   r   goor7   r7   r7   r8   r|     s   r|   r]   c               @   s   e Zd ZdS )z6ClassPropertiesAndMethods.test_classmethods.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c             S   s   | |fS )Nr7   )r   argr7   r7   r8   f  r   z6ClassPropertiesAndMethods.test_classmethods.<locals>.fr   r   )r   z)classmethod shouldn't accept keyword argsr   )r   r=   r  r   r   r   r%   __self__r   r
  r   r   rA   r   r   )	r2   r|   rP   r   rE   r  ZffrD   cm)r   r7   r8   test_classmethods  sF    
z+ClassPropertiesAndMethods.test_classmethodsc             C   sP   t td}td }| }xtdD ]}|d  q$W | j| | ddd d S )Ngettotalrefcountrv   r   r   )delta)r   get_attributer   r   r   r,   assertAlmostEqual)r2   r  r  refs_beforerp   r7   r7   r8   %test_refleaks_in_classmethod___init__  s    z?ClassPropertiesAndMethods.test_refleaks_in_classmethod___init__z"the module 'xxsubtype' is internalc          	   C   s  dd l }d}ddi}|jj||\}}}| ||j | || | || | j||\}}}| ||j | || | || |jjd }||jf||\}}	}
| ||j | |	| | |
| G dd d|j}||f||\}}	}
| || | |	| | |
| | t}|  W d Q R X | t|jd | t}||  W d Q R X | t|jd	 | t}|t	 W d Q R X | t|jd
 d S )Nr   )r]   r^   r_   rY  {   	classmethc               @   s   e Zd ZdS )zAClassPropertiesAndMethods.test_classmethods_in_c.<locals>.SubSpamN)ry   rz   r{   r7   r7   r7   r8   SubSpam:  s    r  zGdescriptor 'classmeth' of 'xxsubtype.spamlist' object needs an argumentzSdescriptor 'classmeth' requires a type but received a 'xxsubtype.spamlist' instancezUdescriptor 'classmeth' requires a subtype of 'xxsubtype.spamlist' but received 'list')
r   r   r  r=   rA   r
  r   r  	exceptionr.   )r2   r   r;   rE   r   r   d1Zspam_cmZx2r   d2r  r  r7   r7   r8   test_classmethods_in_c'  sH    z0ClassPropertiesAndMethods.test_classmethods_in_cc             C   s  G dd dt }| }| |dd | |dd | |d|df G dd d|}| }| |dd | |dd | |d|df | ||d|df td }| |ji  d|_| |jd | |jddi |`| |d d S )	Nc               @   s   e Zd Zdd ZeeZdS )z7ClassPropertiesAndMethods.test_staticmethods.<locals>.Cc              W   s   | S )Nr7   )r;   r7   r7   r8   r   X  r   z;ClassPropertiesAndMethods.test_staticmethods.<locals>.C.fooN)ry   rz   r{   r   r   r  r7   r7   r7   r8   r|   W  s   r|   r]   )r]   c               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_staticmethods.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r   ^  s   r   r   r   )r   r=   r  r   r   rA   r   r   )r2   r|   rP   r   rE   smr7   r7   r8   test_staticmethodsU  s$    z,ClassPropertiesAndMethods.test_staticmethodsc             C   sP   t td}td }| }xtdD ]}|d  q$W | j| | ddd d S )Nr  rv   r   r   )r  )r   r  r   r   r   r,   r  )r2   r  r  r  rp   r7   r7   r8   &test_refleaks_in_staticmethod___init__m  s    z@ClassPropertiesAndMethods.test_refleaks_in_staticmethod___init__c             C   s   dd l }d}ddi}|jj||\}}}| |d  | || | || | j||\}}}| |d  | || | || d S )Nr   )r]   r^   r_   rY  r  )r   r   Z
staticmethr=   )r2   r   r;   rE   r   r   r  r  r7   r7   r8   test_staticmethods_in_cv  s    z1ClassPropertiesAndMethods.test_staticmethods_in_cc                s  G dd d   }|   d df |  |d df |  |d|df G dd d }| }|  |d|df |  |d|df |  |d|df |  ||d|df G  fddd}|  | jj j | t j  d d S )	Nc               @   s   e Zd Zdd ZeeZdS )z1ClassPropertiesAndMethods.test_classic.<locals>.Cc              W   s   | S )Nr7   )r;   r7   r7   r8   r     r   z5ClassPropertiesAndMethods.test_classic.<locals>.C.fooN)ry   rz   r{   r   r   r  r7   r7   r7   r8   r|     s   r|   r]   c               @   s   e Zd ZdS )z1ClassPropertiesAndMethods.test_classic.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c                   s   e Zd Z jZdS )z1ClassPropertiesAndMethods.test_classic.<locals>.EN)ry   rz   r{   r   r7   )r|   r7   r8   r     s   r   z<bound method )r=   r  r   __func__r   rm   r   r   )r2   rP   r   rE   r   r7   )r|   r8   test_classic  s    z&ClassPropertiesAndMethods.test_classicc             C   sh   G dd dt }| }| |jd | |jd d|_| |jd | |jd |`| |d d S )Nc               @   sH   e Zd ZG dd deZdd Zdd Zdd Zd	d
 ZeeeeZ	dS )z2ClassPropertiesAndMethods.test_compattr.<locals>.Cc               @   s0   e Zd Zd
ddZdddZdd Zdd	 ZdS )zEClassPropertiesAndMethods.test_compattr.<locals>.C.computed_attributeNc             S   s   || _ || _|| _d S )N)_computed_attribute__get_computed_attribute__set_computed_attribute__delete)r2   r   r   deleter7   r7   r8   r,     s    zNClassPropertiesAndMethods.test_compattr.<locals>.C.computed_attribute.__init__c             S   s
   |  |S )N)r  )r2   r   r?   r7   r7   r8   r     s    zMClassPropertiesAndMethods.test_compattr.<locals>.C.computed_attribute.__get__c             S   s   |  ||S )N)r  )r2   r   r   r7   r7   r8   r~    s    zMClassPropertiesAndMethods.test_compattr.<locals>.C.computed_attribute.__set__c             S   s
   |  |S )N)r  )r2   r   r7   r7   r8   
__delete__  s    zPClassPropertiesAndMethods.test_compattr.<locals>.C.computed_attribute.__delete__)NN)N)ry   rz   r{   r,   r   r~  r  r7   r7   r7   r8   computed_attribute  s   

r  c             S   s
   d| _ d S )Nr   )_C__x)r2   r7   r7   r8   r,     s    z;ClassPropertiesAndMethods.test_compattr.<locals>.C.__init__c             S   s   | j }|d | _ |S )Nr]   )r  )r2   r   r7   r7   r8   Z__get_x  s    
z:ClassPropertiesAndMethods.test_compattr.<locals>.C.__get_xc             S   s
   || _ d S )N)r  )r2   r   r7   r7   r8   Z__set_x  s    z:ClassPropertiesAndMethods.test_compattr.<locals>.C.__set_xc             S   s   | ` d S )N)r  )r2   r7   r7   r8   Z
__delete_x  s    z=ClassPropertiesAndMethods.test_compattr.<locals>.C.__delete_xN)
ry   rz   r{   r   r  r,   Z	_C__get_xZ	_C__set_xZ_C__delete_xr   r7   r7   r7   r8   r|     s   r|   r   r]   r      r   )r   r=   r   r   )r2   r|   r;   r7   r7   r8   test_compattr  s    z'ClassPropertiesAndMethods.test_compattrc             C   sh   G dd dt }| }| |jd | |j| G dd d|}| }| |jd | |j| d S )Nc               @   s   e Zd Zdd Zdd ZdS )z2ClassPropertiesAndMethods.test_newslots.<locals>.Cc             S   s   t | }d|_|S )Nr]   )r.   r   r   )r   r2   r7   r7   r8   r     s    
z:ClassPropertiesAndMethods.test_newslots.<locals>.C.__new__c             S   s   | j d | _ d S )Nr^   )r   )r2   r7   r7   r8   r,     s    z;ClassPropertiesAndMethods.test_newslots.<locals>.C.__init__N)ry   rz   r{   r   r,   r7   r7   r7   r8   r|     s   r|   r_   c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_newslots.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   )r.   r=   r   r   )r2   r|   r;   r   rL   r7   r7   r8   test_newslots  s    z'ClassPropertiesAndMethods.test_newslotsc             C   sz   |  ttj |  ttjd |  ttjt |  ttjt G dd dt}|  t| G dd dt}|  t| d S )Nr}   c               @   s   e Zd ZejZdS )z1ClassPropertiesAndMethods.test_bad_new.<locals>.CN)ry   rz   r{   r.   r   r7   r7   r7   r8   r|     s   r|   c               @   s   e Zd ZejZdS )z1ClassPropertiesAndMethods.test_bad_new.<locals>.CN)ry   rz   r{   r   r   r7   r7   r7   r8   r|     s   )r
  r   r   r   r.   )r2   r|   r7   r7   r8   test_bad_new  s    z&ClassPropertiesAndMethods.test_bad_newc             C   s4  G dd dt }t | | tt j|d t |  | tt j| d G dd dt }t | t |d t |d | tt j|dd G dd dt }t | | tt j|d t |d t |dd G dd dt }t | | tt j|d t |d | tt j|dd d S )Nc               @   s   e Zd ZdS )z4ClassPropertiesAndMethods.test_object_new.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   re   c               @   s   e Zd Zdd ZdS )z4ClassPropertiesAndMethods.test_object_new.<locals>.Ac             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r,     s    z=ClassPropertiesAndMethods.test_object_new.<locals>.A.__init__N)ry   rz   r{   r,   r7   r7   r7   r8   r     s   r_   c               @   s   e Zd Zdd ZdS )z4ClassPropertiesAndMethods.test_object_new.<locals>.Ac             S   s
   t | S )N)r   r   )r   r   r7   r7   r8   r     s    z<ClassPropertiesAndMethods.test_object_new.<locals>.A.__new__N)ry   rz   r{   r   r7   r7   r7   r8   r     s   c               @   s   e Zd Zdd Zdd ZdS )z4ClassPropertiesAndMethods.test_object_new.<locals>.Ac             S   s
   t | S )N)r   r   )r   r   r7   r7   r8   r     s    z<ClassPropertiesAndMethods.test_object_new.<locals>.A.__new__c             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r,     s    z=ClassPropertiesAndMethods.test_object_new.<locals>.A.__init__N)ry   rz   r{   r   r,   r7   r7   r7   r8   r     s   )r   r   r
  r   r,   )r2   r   r7   r7   r8   test_object_new  s(    



z)ClassPropertiesAndMethods.test_object_newc          	   C   s   G dd dt }| t| G dd d|}t  tdt |d}W d Q R X | |jd | |j	| |`
| t| |`
t  tdt |d}W d Q R X | |jd | |j	| d S )Nc               @   s   e Zd Zdd ZdS )z=ClassPropertiesAndMethods.test_restored_object_new.<locals>.Ac             _   s   t d S )N)AssertionError)r   r3   r4   r7   r7   r8   r      s    zEClassPropertiesAndMethods.test_restored_object_new.<locals>.A.__new__N)ry   rz   r{   r   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZejZdd ZdS )z=ClassPropertiesAndMethods.test_restored_object_new.<locals>.Bc             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r,     s    zFClassPropertiesAndMethods.test_restored_object_new.<locals>.B.__init__N)ry   rz   r{   r   r   r,   r7   r7   r7   r8   r     s   r   errorr_   )r   r
  r  warningscatch_warningssimplefilterDeprecationWarningr=   r   r   r   )r2   r   r   rL   r7   r7   r8   test_restored_object_new  s     

z2ClassPropertiesAndMethods.test_restored_object_newc       	   	   C   sJ  G dd dt }G dd d|}G dd d|}G dd d||}| | |t g | |j|t f | | ||t g | |j||t f | | ||t g | |j||t f | | ||||t g | |j||||t f | |  d G d	d
 d
t}G dd d|||||d}| |jt |||||f | |  d y:G dd dt}G dd dt |d}t |}d|d< W n tk
r   Y nX | d y(G dd dt}G dd dt |d}W n tk
r   Y nX | d y(G dd dt}G dd dt |d}W n tk
r:   Y nX | d d S )Nc               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_altmro.<locals>.Ac             S   s   dS )Nr   r7   )r2   r7   r7   r8   r    r   z2ClassPropertiesAndMethods.test_altmro.<locals>.A.fN)ry   rz   r{   r  r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_altmro.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_altmro.<locals>.Cc             S   s   dS )Nr|   r7   )r2   r7   r7   r8   r    r   z2ClassPropertiesAndMethods.test_altmro.<locals>.C.fN)ry   rz   r{   r  r7   r7   r7   r8   r|     s   r|   c               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_altmro.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd Zdd ZdS )z?ClassPropertiesAndMethods.test_altmro.<locals>.PerverseMetaTypec             S   s   t | }|  |S )N)r?   mroreverse)r   Lr7   r7   r8   r  *  s    
zCClassPropertiesAndMethods.test_altmro.<locals>.PerverseMetaType.mroN)ry   rz   r{   r  r7   r7   r7   r8   PerverseMetaType)  s   r  c               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_altmro.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r   .  s   r   )r   c               @   s   e Zd Zdd ZdS )z9ClassPropertiesAndMethods.test_altmro.<locals>._metaclassc             S   s
   | t tgS )N)rl   r   )r2   r7   r7   r8   r  5  s    z=ClassPropertiesAndMethods.test_altmro.<locals>._metaclass.mroN)ry   rz   r{   r  r7   r7   r7   r8   r   4  s   r   c               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_altmro.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r   7  s   rf   re   zdevious mro() return not caughtc               @   s   e Zd Zdd ZdS )z9ClassPropertiesAndMethods.test_altmro.<locals>._metaclassc             S   s   dgS )Nr]   r7   )r2   r7   r7   r8   r  H  s    z=ClassPropertiesAndMethods.test_altmro.<locals>._metaclass.mroN)ry   rz   r{   r  r7   r7   r7   r8   r   G  s   c               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_altmro.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r   J  s   z!non-class mro() return not caughtc               @   s   e Zd Zdd ZdS )z9ClassPropertiesAndMethods.test_altmro.<locals>._metaclassc             S   s   dS )Nr]   r7   )r2   r7   r7   r8   r  S  s    z=ClassPropertiesAndMethods.test_altmro.<locals>._metaclass.mroN)ry   rz   r{   r  r7   r7   r7   r8   r   R  s   c               @   s   e Zd ZdS )z0ClassPropertiesAndMethods.test_altmro.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r   U  s   z$non-sequence mro() return not caught)	r   r=   r  r  r  r?   r   r   r   )	r2   r   r   r|   r   r  r   r   r   r7   r7   r8   test_altmro  sJ    


z%ClassPropertiesAndMethods.test_altmroc                s   G dd dt  G  fddd }| }| |jd d|_| |jd |`| |jd | |d d	 d
|d< | |jd |d= | |jd | |dd dtddf d|dd< | |jtdddf |dd= | |jtdd d S )Nc               @   s   e Zd ZdZdS )z5ClassPropertiesAndMethods.test_overloading.<locals>.Bz<Intermediate class because object doesn't have a __setattr__N)ry   rz   r{   rV  r7   r7   r7   r8   r   _  s   r   c                   sD   e Zd Zdd Z fddZ fddZdd Zd	d
 Zdd ZdS )z5ClassPropertiesAndMethods.test_overloading.<locals>.Cc             S   s   |dkrd|fS t d S )Nr   r@   )rB  )r2   r5   r7   r7   r8   r  c  s    zAClassPropertiesAndMethods.test_overloading.<locals>.C.__getattr__c                s&   |dkr||f| _ n | ||S d S )Nr   )r   r  )r2   r5   r   )r   r7   r8   r  h  s    zAClassPropertiesAndMethods.test_overloading.<locals>.C.__setattr__c                s    |dkr|| _ n | |S d S )Nr   )r  r  )r2   r5   )r   r7   r8   r  m  s    zAClassPropertiesAndMethods.test_overloading.<locals>.C.__delattr__c             S   s   d|fS )Ngetitemr7   )r2   r   r7   r7   r8   rO   s  s    zAClassPropertiesAndMethods.test_overloading.<locals>.C.__getitem__c             S   s   ||f| _ d S )N)setitem)r2   r   r   r7   r7   r8   rY   u  s    zAClassPropertiesAndMethods.test_overloading.<locals>.C.__setitem__c             S   s
   || _ d S )N)delitem)r2   r   r7   r7   r8   __delitem__w  s    zAClassPropertiesAndMethods.test_overloading.<locals>.C.__delitem__N)	ry   rz   r{   r  r  r  rO   rY   r  r7   )r   r7   r8   r|   b  s   r|   )r@   r   r   )r   r   r   )r  r      )r   r  r   r   r  )r   r=   r   r   r  r  r  rQ   )r2   r|   r;   r7   )r   r8   test_overloading\  s$    
z*ClassPropertiesAndMethods.test_overloadingc                s   G dd dt   d|  d G  fddd }|d}| | d | | d | | d G  fdddt }| | jj j | t j d	d	 d S )
Nc               @   s   e Zd Zdd Zdd ZdS )z1ClassPropertiesAndMethods.test_methods.<locals>.Cc             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r,     s    z:ClassPropertiesAndMethods.test_methods.<locals>.C.__init__c             S   s   | j S )N)r   )r2   r7   r7   r8   r     s    z5ClassPropertiesAndMethods.test_methods.<locals>.C.fooN)ry   rz   r{   r,   r   r7   r7   r7   r8   r|     s   r|   r]   c                   s   e Zd Z jZjZdS )z1ClassPropertiesAndMethods.test_methods.<locals>.DN)ry   rz   r{   r   r   r  r7   )r|   c1r7   r8   r     s   r   r^   c                   s   e Zd Z jZdS )z1ClassPropertiesAndMethods.test_methods.<locals>.EN)ry   rz   r{   r   r7   )r|   r7   r8   r     s   r   z<bound method )
r   r=   r   r   r  r  r   rm   r   r   )r2   r   r  r   r7   )r|   r  r8   test_methods  s    z&ClassPropertiesAndMethods.test_methodsc                s  dd }dd }dd }dd }d	d
 }dd }dd }d=dd}dd }	dd }
fdd}fdd}dd }dd }dt |t i fdt|t i fdt|t ||d fd!tj|t i fd"|	|t i fd#||td$i fd%|
|td&i fd'||t d(|ifd(||t d'|ifd)t|t i fd*t|t i fd+tj	|t i fd,tj
|t i fd,t|t i fd-tj|t i fd.t|t i fd/t|t i fg}G fd0d1d1t}G fd2d3d3t}G d4d5 d5t G  fd6d7d7t}x|D ]\}}}}G d8d9 d9|}x"| D ]\}}t||| qW t||| ||  g G d:d9 d9|}x"| D ]\}}t||| qTW t|||| ||  d;g| G d<d9 d9|}x"| D ]\}}t||| qW t|||   ||  qW d S )>Nc          	   S   s   |  W d Q R X d S )Nr7   )Zmanagerr7   r7   r8   run_context  s    zIClassPropertiesAndMethods.test_special_method_lookup.<locals>.run_contextc             S   s   | S )Nr7   )r2   r7   r7   r8   iden  s    zBClassPropertiesAndMethods.test_special_method_lookup.<locals>.idenc             S   s   dS )Ns   hellor7   )r2   r7   r7   r8   r    s    zCClassPropertiesAndMethods.test_special_method_lookup.<locals>.helloc             S   s   g S )Nr7   )r2   r7   r7   r8   	empty_seq  s    zGClassPropertiesAndMethods.test_special_method_lookup.<locals>.empty_seqc             S   s   dS )Nr   r7   )r2   r7   r7   r8   zero  s    zBClassPropertiesAndMethods.test_special_method_lookup.<locals>.zeroc             S   s   dS )Ny              ?r7   )r2   r7   r7   r8   complex_num  s    zIClassPropertiesAndMethods.test_special_method_lookup.<locals>.complex_numc             S   s   t d S )N)StopIteration)r2   r7   r7   r8   r     s    zBClassPropertiesAndMethods.test_special_method_lookup.<locals>.stopc             S   s   dS )NTr7   )r2   thingr7   r7   r8   return_true  s    zIClassPropertiesAndMethods.test_special_method_lookup.<locals>.return_truec             S   s
   t t| S )N)r   r%   )r   r7   r7   r8   do_isinstance  s    zKClassPropertiesAndMethods.test_special_method_lookup.<locals>.do_isinstancec             S   s
   t t| S )N)r   r%   )r   r7   r7   r8   do_issubclass  s    zKClassPropertiesAndMethods.test_special_method_lookup.<locals>.do_issubclassc                s*   G dd d| j t} | d d d S )Nc               @   s   e Zd ZdS )z^ClassPropertiesAndMethods.test_special_method_lookup.<locals>.do_dict_missing.<locals>.DictSubN)ry   rz   r{   r7   r7   r7   r8   DictSub  s   r  hira   )r   rl   r=   )Zcheckerr  )r2   r7   r8   do_dict_missing  s    zMClassPropertiesAndMethods.test_special_method_lookup.<locals>.do_dict_missingc                s     |d dS )Nr  ra   )r=   )rb  r   )r2   r7   r8   some_number  s    zIClassPropertiesAndMethods.test_special_method_lookup.<locals>.some_numberc              W   s   d S )Nr7   )r3   r7   r7   r8   swallow  r   zEClassPropertiesAndMethods.test_special_method_lookup.<locals>.swallowc             S   s   dS )Nr  r7   )r2   specr7   r7   r8   format_impl  s    zIClassPropertiesAndMethods.test_special_method_lookup.<locals>.format_impl	__bytes____reversed____length_hint__)rk   __next__
__sizeof____instancecheck____missing__)r   __subclasscheck__)rB   	__enter____exit____complex__
__format__	__floor__	__trunc____ceil____dir__	__round__c                   s(   e Zd ZfddZf fdd	ZdS )zEClassPropertiesAndMethods.test_special_method_lookup.<locals>.Checkerc             S   s   | d| d S )Nz__getattr__ called with {0})r   format)r2   rr  testr7   r7   r8   r    s    zQClassPropertiesAndMethods.test_special_method_lookup.<locals>.Checker.__getattr__c                s$   | kr| d| t| |S )Nz __getattribute__ called with {0})r   r  r   r  )r2   rr  r  )okr7   r8   r    s    zVClassPropertiesAndMethods.test_special_method_lookup.<locals>.Checker.__getattribute__N)ry   rz   r{   r  r  r7   )r  r2   r7   r8   Checker  s   r  c                   s    e Zd Zdd Z fddZdS )zJClassPropertiesAndMethods.test_special_method_lookup.<locals>.SpecialDescrc             S   s
   || _ d S )N)impl)r2   r  r7   r7   r8   r,     s    zSClassPropertiesAndMethods.test_special_method_lookup.<locals>.SpecialDescr.__init__c                s     d | j||S )Nr]   )ri   r  r   )r2   r   owner)recordr7   r8   r     s    
zRClassPropertiesAndMethods.test_special_method_lookup.<locals>.SpecialDescr.__get__N)ry   rz   r{   r,   r   r7   )r  r7   r8   SpecialDescr  s   r  c               @   s   e Zd ZdS )zIClassPropertiesAndMethods.test_special_method_lookup.<locals>.MyExceptionN)ry   rz   r{   r7   r7   r7   r8   MyException  s   r  c                   s   e Zd Z fddZdS )zFClassPropertiesAndMethods.test_special_method_lookup.<locals>.ErrDescrc                s    d S )Nr7   )r2   r   r  )r  r7   r8   r     s    zNClassPropertiesAndMethods.test_special_method_lookup.<locals>.ErrDescr.__get__N)ry   rz   r{   r   r7   )r  r7   r8   ErrDescr  s   r  c               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_special_method_lookup.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_special_method_lookup.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   r]   c               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_special_method_lookup.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   )N)rM  r   reversedr.   r   	getsizeofr   r  mathZfloorZtruncr%   Zceildirroundr   	Exceptionr/   r   r=   r
  )r2   r  r  r  r  r  r  r   r  r  r  r  r  r  r  Zspecialsr  r  r  r5   ZrunnerZ	meth_implenvr   rr  r   r7   )r  r  r  r2   r8   test_special_method_lookup  sp    






z4ClassPropertiesAndMethods.test_special_method_lookupc             C   s  G dd dt }| }| }| |  | t|t| t| t| | || | ||k | ||k | ||k | t|	dd | t|t
| | d| xtdD ]}| || qW | d| G dd dt }| }| }| |  | t|t| t| t| | || | || | ||k | ||k | t|	d	d | t|t
| | d| xtdD ]}| || qW | d| G d
d dt }|d}	|d}
|d}| |	 | |
  | t|	td | |	|	 | |	|
 | |	|	k | |	 |
 | |	|
k  | |	|
k | |
|	k | |
|	k | t|	d | t
|	d |td}| d| xtdD ]}| || qW | d| d S )Nc               @   s   e Zd Zdd ZdS )z2ClassPropertiesAndMethods.test_specials.<locals>.Cc             S   s$   d|  krdk rn n|S t d S )Nr   r   )
IndexError)r2   rp   r7   r7   r8   rO     s     z>ClassPropertiesAndMethods.test_specials.<locals>.C.__getitem__N)ry   rz   r{   rO   r7   r7   r7   r8   r|     s   r|   zC object at r   r   r   c               @   s   e Zd Zdd ZdS )z2ClassPropertiesAndMethods.test_specials.<locals>.Dc             S   s$   d|  krdk rn n|S t d S )Nr   r   )r  )r2   rp   r7   r7   r8   rO   (  s     z>ClassPropertiesAndMethods.test_specials.<locals>.D.__getitem__N)ry   rz   r{   rO   r7   r7   r7   r8   r   '  s   r   zD object at 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 )z6ClassPropertiesAndMethods.test_specials.<locals>.Proxyc             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r,   ?  s    z?ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__init__c             S   s
   | j   S )N)r   )r2   r7   r7   r8   r~   A  s    z?ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__bool__c             S   s
   t | jS )N)hashr   )r2   r7   r7   r8   __hash__C  s    z?ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__hash__c             S   s
   | j |kS )N)r   )r2   rx   r7   r7   r8   ra  E  s    z=ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__eq__c             S   s
   | j |kS )N)r   )r2   rx   r7   r7   r8   __ne__G  s    z=ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__ne__c             S   s
   | j |kS )N)r   )r2   rx   r7   r7   r8   __ge__I  s    z=ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__ge__c             S   s
   | j |kS )N)r   )r2   rx   r7   r7   r8   __gt__K  s    z=ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__gt__c             S   s
   | j |kS )N)r   )r2   rx   r7   r7   r8   __le__M  s    z=ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__le__c             S   s
   | j |k S )N)r   )r2   rx   r7   r7   r8   __lt__O  s    z=ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__lt__c             S   s
   d| j  S )NzProxy:%s)r   )r2   r7   r7   r8   r   Q  s    z>ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__str__c             S   s
   d| j  S )Nz	Proxy(%r))r   )r2   r7   r7   r8   rn   S  s    z?ClassPropertiesAndMethods.test_specials.<locals>.Proxy.__repr__c             S   s
   || j kS )N)r   )r2   r   r7   r7   r8   r`   U  s    zCClassPropertiesAndMethods.test_specials.<locals>.Proxy.__contains__N)ry   rz   r{   r,   r~   r  ra  r   r  r  r  r  r   rn   r`   r7   r7   r7   r8   Proxy>  s   r  r]   zProxy:0zProxy(0))r   r   rA  idr  r=   r   ZassertGreaterEqualr  findrm   assertNotInr   r  )r2   r|   r  c2rp   r   r  r  r  Zp0Zp1Zp_1Zp10r7   r7   r8   test_specials  sp    
z'ClassPropertiesAndMethods.test_specialsc       
   
   C   s   dd l }G dd dt}| }||}| | | ~t  | | d  ~G dd dt}| }y|| W n2 tk
r } z| dt| W d d }~X Y nX | 	d G dd	 d	t}| }	||	}| | |	 ~	t  | | d  ~d S )
Nr   c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_weakrefs.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   p  s   r|   c               @   s   e Zd ZdgZdS )z7ClassPropertiesAndMethods.test_weakrefs.<locals>.NoWeakr   N)ry   rz   r{   r   r7   r7   r7   r8   NoWeaky  s   r  zweak referencez!weakref.ref(no) should be illegalc               @   s   e Zd ZddgZdS )z5ClassPropertiesAndMethods.test_weakrefs.<locals>.Weakr   rn  N)ry   rz   r{   r   r7   r7   r7   r8   Weak  s   r  )
weakrefr   refr=   r   rf  r   r  r  r   )
r2   r  r|   rP   rr  nor8  r  Zyesr7   r7   r8   test_weakrefsm  s0    
"

z'ClassPropertiesAndMethods.test_weakrefsc       
      C   s  G dd dt }| }| |d d|_| |jd | |jd |`| |d | |d |j|d | |j|d |j| | |d |jd }| 	|t
 t|}| d| | d| | d	| | d
| | |jd | |j|jd  | |j|jd  | |j|jd  x|dD ]t}yt||d W nN tk
r } z.t|ddk r| d|t|f  W d d }~X Y nX | d|  q8W d|_| |jd G dd dt }| }yx|D ]}	t|	 qW W n tk
r   Y nX | d d S )Nc               @   s4   e Zd Zdd Zdd Zdd ZeeeeddZd	S )
z4ClassPropertiesAndMethods.test_properties.<locals>.Cc             S   s   | j S )N)r  )r2   r7   r7   r8   getx  s    z9ClassPropertiesAndMethods.test_properties.<locals>.C.getxc             S   s
   || _ d S )N)r  )r2   r   r7   r7   r8   setx  s    z9ClassPropertiesAndMethods.test_properties.<locals>.C.setxc             S   s   | ` d S )N)r  )r2   r7   r7   r8   delx  s    z9ClassPropertiesAndMethods.test_properties.<locals>.C.delxzI'm the x property.)docN)ry   rz   r{   r  r  r  r   r   r7   r7   r7   r8   r|     s   r|   r   r   r  rv   rV  fgetfsetfdelzI'm the x property.r  r  r  )r  r  r  readonlyr   zQwhen setting readonly attr %r on a property, got unexpected AttributeError msg %rzIexpected AttributeError from trying to set readonly %r attr on a propertyc               @   s   e Zd Zedd ZdS )z4ClassPropertiesAndMethods.test_properties.<locals>.Dc             S   s   dd S )Nr]   r   r7   )rj  r7   r7   r8   r    r   z=ClassPropertiesAndMethods.test_properties.<locals>.D.<lambda>N)ry   rz   r{   r   rO   r7   r7   r7   r8   r     s   r   z,expected ZeroDivisionError from bad property)r   r   r   r=   r  r~  r   r  rA   r   r   r  r  rV  r   r  r  r  r   rB  r  r  r   ZeroDivisionError)
r2   r|   r;   rawattrsrr  r8  r   rE   rp   r7   r7   r8   test_properties  sV    

"
z)ClassPropertiesAndMethods.test_propertiesr^   z)Docstrings are omitted with -O2 and abovec                s   G  fdddt }d S )Nc                   sJ   e Zd Zdd Zdd ZeeZ ejd eedZ	 e	jd dS )z?ClassPropertiesAndMethods.test_properties_doc_attrib.<locals>.Ec             S   s   dS )zgetter methodr   r7   )r2   r7   r7   r8   getter  s    zFClassPropertiesAndMethods.test_properties_doc_attrib.<locals>.E.getterc             S   s   dS )zsetter methodNr7   )rb  r   r7   r7   r8   setter  s    zFClassPropertiesAndMethods.test_properties_doc_attrib.<locals>.E.setterzgetter method)r  N)
ry   rz   r{   r  r  r   Zpropr=   rV  Zprop2r7   )r2   r7   r8   r     s   
r   )r   )r2   r   r7   )r2   r8   test_properties_doc_attrib  s    z4ClassPropertiesAndMethods.test_properties_doc_attribc                s:   ydd l  W n tk
r    Y nX G  fdddt}d S )Nr   c                   s   e Zd Ze jZdS )z>ClassPropertiesAndMethods.test_testcapi_no_segfault.<locals>.XN)ry   rz   r{   r   Ztest_with_docstringpr7   )	_testcapir7   r8   r     s   r   )r"  ImportErrorr   )r2   r   r7   )r"  r8   test_testcapi_no_segfault  s
    z3ClassPropertiesAndMethods.test_testcapi_no_segfaultc                s  G dd dt    }|  jjd | |d d|_| |d | |jd | |jd |`| |d | |d G  fdd	d	 }| }d
|_| |jd
 |`|`G dd dt  }d|_| |jd |`G fddd}| }d|_| |jd |`d S )Nc               @   s@   e Zd ZeddZejdd Zejdd Zejdd ZdS )z9ClassPropertiesAndMethods.test_properties_plus.<locals>.Cr  )r  c             S   s   | j S )N)_foo)r2   r7   r7   r8   r     s    z=ClassPropertiesAndMethods.test_properties_plus.<locals>.C.fooc             S   s   t || _d S )N)r#   r%  )r2   r   r7   r7   r8   r     s    c             S   s   | ` d S )N)r%  )r2   r7   r7   r8   r     s    N)ry   rz   r{   r   r   r  r  deleterr7   r7   r7   r8   r|     s   
r|   r  r   ir%  r   c                   s   e Zd Z jjdd ZdS )z9ClassPropertiesAndMethods.test_properties_plus.<locals>.Dc             S   s"   y| ` W n tk
r   Y nX d S )N)r%  rB  )r2   r7   r7   r8   r     s    z=ClassPropertiesAndMethods.test_properties_plus.<locals>.D.fooN)ry   rz   r{   r   r&  r7   )r|   r7   r8   r     s   r   r   c               @   sD   e Zd Zedd Zejdd Zejdd ZejdddZdS )z9ClassPropertiesAndMethods.test_properties_plus.<locals>.Ec             S   s   | j S )N)r%  )r2   r7   r7   r8   r   
	  s    z=ClassPropertiesAndMethods.test_properties_plus.<locals>.E.fooc             S   s   t d S )N)RuntimeError)r2   r   r7   r7   r8   r   	  s    c             S   s   t || _d S )N)r#   r%  )r2   r   r7   r7   r8   r   	  s    Nc             S   s   | ` d S )N)r%  )r2   r   r7   r7   r8   r   	  s    )N)ry   rz   r{   r   r   r  r&  r7   r7   r7   r8   r   		  s
   r   c                   s*   e Zd Z jjdd Zejdd ZdS )z9ClassPropertiesAndMethods.test_properties_plus.<locals>.Fc             S   s   | ` d S )N)r%  )r2   r7   r7   r8   r   	  s    z=ClassPropertiesAndMethods.test_properties_plus.<locals>.F.fooc             S   s   t d|| _d S )Nr   )maxr%  )r2   r   r7   r7   r8   r    	  s    N)ry   rz   r{   r   r&  r  r7   )r   r7   r8   r  	  s   r  ir   )r   r=   r   rV  r   r   r%  )r2   rP   r   rE   r_  r  r  r7   )r|   r   r8   test_properties_plus  s6    z.ClassPropertiesAndMethods.test_properties_plusc          	   C   s  t  }| |i  t i }| |i  t ddd}| |ddd | |t t|  | |t t|  t ddd}| |t ddd | |t f | | |t ddidd | |t dgdd	 | |t d
dgf| | |t f | x|dddddgdfD ]f}yt | W nD tk
r<   Y n> tk
rj   |dkrXn| d|  Y nX | d|  qW yt i i  W n tk
r   Y nX | d G dd d}yt |  W n tk
r   Y nX | d dd |_dd |_	t | }| ||j  G dd d}t |dd|dd|dd|ddg}| |ddd t t
tdtdd }| |t d!d" tdD  xHd#gd$gfD ]8}yt | W n tk
r   Y nX | d%|  qW d S )&Nr^   rL   )r]   r;   r]   )onetwor*  )r+  )r+  r^   )r*  )r*  rv   )r+  r   r   y                0)r   zno TypeError from dict(%r)zno TypeError from dict({}, {})c               @   s   e Zd ZddddZdS )zAClassPropertiesAndMethods.test_dict_constructors.<locals>.Mappingr^   ra   y              ?)r]   r_   r;   N)ry   rz   r{   rl   r7   r7   r7   r8   MappingQ	  s   r-  z*no TypeError from dict(incomplete mapping)c             S   s   t | j S )N)r.   rl   rh   )r2   r7   r7   r8   r  \	  r   zBClassPropertiesAndMethods.test_dict_constructors.<locals>.<lambda>c             S   s
   | j | S )N)rl   )r2   rp   r7   r7   r8   r  ]	  r   c               @   s   e Zd Zdd Zdd ZdS )zJClassPropertiesAndMethods.test_dict_constructors.<locals>.AddressBookEntryc             S   s   || _ || _d S )N)firstlast)r2   r.  r/  r7   r7   r8   r,   c	  s    zSClassPropertiesAndMethods.test_dict_constructors.<locals>.AddressBookEntry.__init__c             S   s   t | j| jgS )N)rj   r.  r/  )r2   r7   r7   r8   rk   f	  s    zSClassPropertiesAndMethods.test_dict_constructors.<locals>.AddressBookEntry.__iter__N)ry   rz   r{   r,   rk   r7   r7   r7   r8   AddressBookEntryb	  s   r0  TimZWarsawBarryZPeters)r2  r1  ra   re   c             S   s   g | ]}||d  fqS )r]   r7   ).0rp   r7   r7   r8   
<listcomp>p	  s    zDClassPropertiesAndMethods.test_dict_constructors.<locals>.<listcomp>)Ztooshort)ZtooZlongzby 1zno ValueError from dict(%r))rl   r=   r.   r/   rj   r   
ValueErrorr   rh   rO   zipr   )r2   rE   Zbadargr-  r0  Zbadr7   r7   r8   test_dict_constructors(	  sl    






z0ClassPropertiesAndMethods.test_dict_constructorsc                s8  d}|  t ddg ~x2dddddgddd	ddit| jfD ]}t| q<W d
d }G dd dt}ddg}|  |t|| | }|  |t|| d|_dd |_|  |t||ddg  G dd d|}ddg| }|  |t|| | }	|  |t|	| d|	_dd |	_|  |t|	|ddg  G dd dtt	}
|
d}d|_
d|_d d!d"d#d$gfd%d&t|D }|  |d'd(g G d)d* d*|
}|d+}d|_
d|_|  |jd, yt| W n tk
r   Y nX |  tttt G  fd-d.d.t G  fd/ddt}t|  d S )0Nr   junkr2   r^   y               @g       @2   2)r^   c             S   s   dd | D S )Nc             S   s   g | ]}| d s|qS )r   )r   )r3  rj  r7   r7   r8   r4  	  s    zKClassPropertiesAndMethods.test_dir.<locals>.interesting.<locals>.<listcomp>r7   )stringsr7   r7   r8   interesting	  s    z7ClassPropertiesAndMethods.test_dir.<locals>.interestingc               @   s   e Zd ZdZdd ZdS )z-ClassPropertiesAndMethods.test_dir.<locals>.Cr]   c             S   s   d S )Nr7   )r2   r7   r7   r8   Cmethod	  r   z5ClassPropertiesAndMethods.test_dir.<locals>.C.CmethodN)ry   rz   r{   Cdatar=  r7   r7   r7   r8   r|   	  s   r|   r>  r=  c             S   s   dS )Nr   r7   )r2   r7   r7   r8   r  	  r   z4ClassPropertiesAndMethods.test_dir.<locals>.<lambda>cdatacmethodc               @   s   e Zd ZdZdd ZdS )z-ClassPropertiesAndMethods.test_dir.<locals>.Ar]   c             S   s   d S )Nr7   )r2   r7   r7   r8   Amethod	  r   z5ClassPropertiesAndMethods.test_dir.<locals>.A.AmethodN)ry   rz   r{   AdatarA  r7   r7   r7   r8   r   	  s   r   rB  rA  r   c             S   s   dS )Nr_   r7   )r2   r7   r7   r8   r  	  r   adataamethodc               @   s   e Zd ZdS )z-ClassPropertiesAndMethods.test_dir.<locals>.MN)ry   rz   r{   r7   r7   r7   r8   M	  s   rE  rG   r]   ry   rV  __package__
__loader____spec__c                s   g | ]}| kr|qS r7   r7   )r3  r   )default_attributesr7   r8   r4  	  s    z6ClassPropertiesAndMethods.test_dir.<locals>.<listcomp>r;   rL   c               @   s   e Zd Zdd ZeeZdS )z.ClassPropertiesAndMethods.test_dir.<locals>.M2c             S   s   dS )NzNot a dict!r7   )r2   r7   r7   r8   getdict	  s    z6ClassPropertiesAndMethods.test_dir.<locals>.M2.getdictN)ry   rz   r{   rJ  r   rA   r7   r7   r7   r8   r   	  s   r   Zm2zNot a dict!c                   s<   e Zd Zdd Zdd Z fddZdd Z fd	d
ZdS )z3ClassPropertiesAndMethods.test_dir.<locals>.Wrapperc             S   s
   || _ d S )N)_Wrapper__obj)r2   r   r7   r7   r8   r,   	  s    z<ClassPropertiesAndMethods.test_dir.<locals>.Wrapper.__init__c             S   s   dt | j S )NzWrapper(%s))rm   rK  )r2   r7   r7   r8   rn   	  s    z<ClassPropertiesAndMethods.test_dir.<locals>.Wrapper.__repr__c                s    | j | S )N)rK  )r2   r   )Wrapperr7   r8   rO   	  s    z?ClassPropertiesAndMethods.test_dir.<locals>.Wrapper.__getitem__c             S   s
   t | jS )N)r   rK  )r2   r7   r7   r8   r:   	  s    z;ClassPropertiesAndMethods.test_dir.<locals>.Wrapper.__len__c                s    t | j|S )N)r@   rK  )r2   r5   )rL  r7   r8   r  	  s    z?ClassPropertiesAndMethods.test_dir.<locals>.Wrapper.__getattr__N)ry   rz   r{   r,   rn   rO   r:   r  r7   )rL  r7   r8   rL  	  s
   rL  c                   s    e Zd Z fddZeeZdS )z-ClassPropertiesAndMethods.test_dir.<locals>.Cc                s    t | S )N)r?   )r2   )rL  r7   r8   Z
__getclass	  s    z8ClassPropertiesAndMethods.test_dir.<locals>.C.__getclassN)ry   rz   r{   Z_C__getclassr   r   r7   )rL  r7   r8   r|   	  s   )r=   r  r?   test_dirr   r?  r@  rC  rD  r   rL   r;   rA   r   rw   Ellipsis)r2   r8  r  r<  r|   ZcstuffrP   r   Zastuffr;   rE  Z	minstancenamesr   Z
m2instancer7   )rL  rI  r8   rM  {	  sV    (

z"ClassPropertiesAndMethods.test_dirc                s  G dd dt }| | dd G  fddd| |   dd G d	d
 d
|}t||_| | dd G fddd| |  dd G fdddtG fddd|  dd G dd d}||_| | dd ytd W n tk
r4   Y nX | d yt|  W n tk
rf   Y nX | d ytd W n tk
r   Y nX | d yt|  W n tk
r   Y nX | d  G d!d" d"t }G d#d$ d$|}| }| |j	d% | t||j	d G d&d' d't }G fd(d)d)|| 
 |j yt|dd* W n tk
r   Y nX | d+ d S ),Nc               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_supers.<locals>.Ac             S   s   d| S )NzA(%r)r7   )r2   r;   r7   r7   r8   rD   	  s    z5ClassPropertiesAndMethods.test_supers.<locals>.A.methN)ry   rz   r{   rD   r7   r7   r7   r8   r   	  s   r   r]   zA(1)c                   s&   e Zd Z fddZdd Z  ZS )z0ClassPropertiesAndMethods.test_supers.<locals>.Bc                s   t  | | _d S )N)r   r   )r2   )r   r   r7   r8   r,   	  s    z9ClassPropertiesAndMethods.test_supers.<locals>.B.__init__c             S   s   d| | j | S )NzB(%r))r   rD   )r2   r;   r7   r7   r8   rD   	  s    z5ClassPropertiesAndMethods.test_supers.<locals>.B.meth)ry   rz   r{   r,   rD   r   r7   )r   )r   r8   r   	  s   r   r^   zB(2)A(2)c               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_supers.<locals>.Cc             S   s   d| | j | S )NzC(%r))r   rD   )r2   r;   r7   r7   r8   rD   	  s    z5ClassPropertiesAndMethods.test_supers.<locals>.C.methN)ry   rz   r{   rD   r7   r7   r7   r8   r|   	  s   r|   r_   zC(3)A(3)c                   s   e Zd Z fddZ  ZS )z0ClassPropertiesAndMethods.test_supers.<locals>.Dc                s   d| t  | | S )NzD(%r))r   rD   )r2   r;   )r   r   r7   r8   rD   	  s    z5ClassPropertiesAndMethods.test_supers.<locals>.D.meth)ry   rz   r{   rD   r   r7   )r   )r   r8   r   	  s   r   ra   zD(4)C(4)B(4)A(4)c                   s   e Zd Z fddZ  ZS )z6ClassPropertiesAndMethods.test_supers.<locals>.mysuperc                s   t | j| S )N)r   r,   )r2   r3   )r   mysuperr7   r8   r,   	  s    z?ClassPropertiesAndMethods.test_supers.<locals>.mysuper.__init__)ry   rz   r{   r,   r   r7   )rP  )r   r8   rP  	  s   rP  c                   s   e Zd Z fddZdS )z0ClassPropertiesAndMethods.test_supers.<locals>.Ec                s   d|  |  | S )NzE(%r))rD   )r2   r;   )r   rP  r7   r8   rD   	  s    z5ClassPropertiesAndMethods.test_supers.<locals>.E.methN)ry   rz   r{   rD   r7   )r   rP  r7   r8   r   	  s   r   re   zE(5)D(5)C(5)B(5)A(5)c               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_supers.<locals>.Fc             S   s    | j }d||jjf || S )Nz	F(%r)[%s])	_F__superr   ry   rD   )r2   r;   rj  r7   r7   r8   rD   
  s    z5ClassPropertiesAndMethods.test_supers.<locals>.F.methN)ry   rz   r{   rD   r7   r7   r7   r8   r  
  s   r  rf   z!F(6)[mysuper]E(6)D(6)C(6)B(6)A(6)r   zshouldn't allow super(D, 42)zshouldn't allow super(D, C())r   z$shouldn't allow super(D).__get__(12)z%shouldn't allow super(D).__get__(C())c               @   s   e Zd Zdd ZeeZdS )z5ClassPropertiesAndMethods.test_supers.<locals>.DDbasec             S   s   dS )Nr   r7   )r2   r7   r7   r8   r  -
  r   z:ClassPropertiesAndMethods.test_supers.<locals>.DDbase.getxN)ry   rz   r{   r  r   r   r7   r7   r7   r8   DDbase,
  s   rR  c               @   s   e Zd Zdd ZeeZdS )z4ClassPropertiesAndMethods.test_supers.<locals>.DDsubc             S   s   dS )Nr  r7   )r2   r7   r7   r8   r  1
  r   z9ClassPropertiesAndMethods.test_supers.<locals>.DDsub.getxN)ry   rz   r{   r  r   r   r7   r7   r7   r8   DDsub0
  s   rS  r  c               @   s   e Zd Zedd ZdS )z3ClassPropertiesAndMethods.test_supers.<locals>.Basec             S   s   dS )Nr   r7   )r2   r7   r7   r8   r  <
  r   z<ClassPropertiesAndMethods.test_supers.<locals>.Base.<lambda>N)ry   rz   r{   r   aPropr7   r7   r7   r8   Base;
  s   rU  c                   s"   e Zd Ze fddZ  ZS )z2ClassPropertiesAndMethods.test_supers.<locals>.Subc                s   t  | jS )N)r   rT  )klass)Subr   r7   r8   r  ?
  s    z7ClassPropertiesAndMethods.test_supers.<locals>.Sub.test)ry   rz   r{   r   r  r   r7   )rW  )r   r8   rW  >
  s   rW  )r   z#super shouldn't accept keyword args)r   r=   rD   r   r   rQ  r   r   r   r   r  rT  )r2   r   r|   r  rR  rS  ddrU  )r   )r   r   r   rW  rP  r8   test_supers	  s`    





z%ClassPropertiesAndMethods.test_supersc                s  G  fdddt  | t dd d | t dd d  d}| |d | t |d | t |jt  | t|td | |
 jt  | |d	? jt  | |d	> jt  |  d	d
> jt  |  d	d
? jt  G fdddt | tdd d | tdd d d}| |d | t |d | t|td | t |jt  | |
 jt  | | jt  | d	 jt  | |d	? jt  | |d	> jt  | |d	 jt  | |d jt  | |d jt  | |d jt  | d| jt  | |d	B jt  | |d	A jt  | |d@ jt  | d	d
> jt  | d	d
? jt  | td	jt  G dd dt }|d}| |d	 jt  | d	| jt  |d}| |ji  | t |d G dd dt	}| t|dd |d}| |d | t	|d | t	|jt	 | t|td | |
 jt	 G dd dt
}|dd}| t|d t
dd}| |jt
 | || | t
|| | t
|jt
 ||}| t|d | || | t
|| | t
|jt
 | t|t| | |
 jt
 | |d	 jt
 | |d	 | | |d	 jt
 | |d	 | | |d jt
 | |d | | |d jt
 | |d | G d d! d!t}|d"}| |d" | | |d# | |  |d" x:td$D ].}|t|}| }	|	 }
| |
| qBW |d%}| t|d% | t|jt | t|td% | |d d  jt | |d jt | |d	 jt | |d& jt |d&}| t|d& | t|jt | || jt | |d	 jt | |d jt | |d' jt | |d d  jt G d(d) d)t}|d*}| |d* | | |d+ | |  |d* xFtd,D ]:}|d-ttt|}| }| }	| |	| qW |d.}| t|d. | t|jt d/}||}| || | t|| | t|jt | t|t| | |di| d | |di| d | |d- jt | |d- | | d-| jt | d-| | | |d	 jt | |d	 d- | |d jt | |d | | |d' jt | |d' ||  | |d d  jt | |d d  | | |d	d	 jt | |d	d	 d- | | jt | | | | | jt | | | | | jt | | | i }| ||jt | ||| | |d0d0jt | |d0d0| | |t|jt | |t|| | |t|jt | |t|| | |t|jt | |t|| | | jt | | | G d1d2 d2t}|d3}	| |	d3 | |	 |d4 | |	  |d3 d.}||}	| t|	| | t|	jt | t|	t| | |	di| d | |di|	 d | |	 jt | |	 | | |	 jt | |	 | | |	 jt | |	 | | |	d0d0jt | |	d0d0| | |	d5d5jt | |	d5d5| | |	t|	jt | |	t|	| | |	t|	jt | |	t|	| | |	t|	jt | |	t|	| | |	 jt | |	 | | |	 jt | |	 | | |	 jt | |	 | | |	 jt | |	 | | |	d- jt | |	d- | | d-|	 jt | d-|	 | | |	d	 jt | |	d	 d- | |	d jt | |	d | | |	d' jt | |	d' ||  | |	d d  jt | |	d d  | | |	d	d	 jt | |	d	d	 d- G d6d7 d7t}|td}| |ttd |d8 | |ttdd8g  d|d< | |ttd9 | td9d: | |ttd: g |d;d < | |ttd< |d=d<= | t|d= | |ttd= | t|ttd= | |d	 d	 | |d d | |d> d	 | |d d | |d d ttd d S )?Nc                   s    e Zd Zdd Z fddZdS )z@ClassPropertiesAndMethods.test_basic_inheritance.<locals>.hexintc             S   s   t | S )N)hex)r2   r7   r7   r8   rn   Q
  s    zIClassPropertiesAndMethods.test_basic_inheritance.<locals>.hexint.__repr__c                s    t | |S )N)r%   rK   )r2   rx   )hexintr7   r8   rK   S
  s    zHClassPropertiesAndMethods.test_basic_inheritance.<locals>.hexint.__add__N)ry   rz   r{   rn   rK   r7   )r[  r7   r8   r[  P
  s   r[     	   Z0x10i  Z0x3efi90  r   r   c                   s.   e Zd Zg Zdd Z fddZeZ  ZS )zAClassPropertiesAndMethods.test_basic_inheritance.<locals>.octlongc             S   s   t | S )N)oct)r2   r7   r7   r8   r   f
  s    zIClassPropertiesAndMethods.test_basic_inheritance.<locals>.octlong.__str__c                s   |  t| |S )N)r   r   rK   )r2   rx   )r   octlongr7   r8   rK   h
  s    zIClassPropertiesAndMethods.test_basic_inheritance.<locals>.octlong.__add__)ry   rz   r{   r   r   rK   r   r   r7   )r_  )r   r8   r_  d
  s   r_  r_   re   Z0o10i  Z0o5675r]   r   c               @   s   e Zd ZdS )zCClassPropertiesAndMethods.test_basic_inheritance.<locals>.longcloneN)ry   rz   r{   r7   r7   r7   r8   	longclone
  s   r`  c               @   s$   e Zd ZdgZd	ddZdd ZdS )
zCClassPropertiesAndMethods.test_basic_inheritance.<locals>.precfloatr           r   c             S   s   t || _d S )N)r%   r   )r2   r   r   r7   r7   r8   r,   
  s    zLClassPropertiesAndMethods.test_basic_inheritance.<locals>.precfloat.__init__c             S   s   d| j | f S )Nz%.*g)r   )r2   r7   r7   r8   rn   
  s    zLClassPropertiesAndMethods.test_basic_inheritance.<locals>.precfloat.__repr__N)ra  r   )ry   rz   r{   r   r,   rn   r7   r7   r7   r8   	precfloat
  s   
rb  g?z1.1g    @c               @   s   e Zd Zdd ZdS )zDClassPropertiesAndMethods.test_basic_inheritance.<locals>.madcomplexc             S   s   d| j | jf S )Nz%.17gj%+.17g)r   r   )r2   r7   r7   r8   rn   
  s    zMClassPropertiesAndMethods.test_basic_inheritance.<locals>.madcomplex.__repr__N)ry   rz   r{   rn   r7   r7   r7   r8   
madcomplex
  s   rc  ra   z4j-3c               @   s   e Zd ZdZdd ZdS )zBClassPropertiesAndMethods.test_basic_inheritance.<locals>.madtupleNc             S   s2   | j d k	r| j S t| }|  | || _ | j S )N)_revr.   r  r   )r2   r  r7   r7   r8   rev
  s    
zFClassPropertiesAndMethods.test_basic_inheritance.<locals>.madtuple.rev)ry   rz   r{   re  rf  r7   r7   r7   r8   madtuple
  s   rg  )
r]   r^   r_   ra   re   rf   r\     r]  r   )
r   r]  rh  r\  rf   re   ra   r_   r^   r]   i   )r]   r^   r_   ra   re   r7   r^   c               @   s   e Zd ZdZdd ZdS )zCClassPropertiesAndMethods.test_basic_inheritance.<locals>.madstringNc             S   s8   | j d k	r| j S t| }|  | d|| _ | j S )Nr}   )re  r.   r  r   join)r2   r  r7   r7   r8   rf  
  s    
zGClassPropertiesAndMethods.test_basic_inheritance.<locals>.madstring.rev)ry   rz   r{   re  rf  r7   r7   r7   r8   	madstring
  s   rj  ZabcdefghijklmnopqrstuvwxyzZzyxwvutsrqponmlkjihgfedcba   r}   Z12345z     r   c               @   s   e Zd ZdZdd ZdS )zDClassPropertiesAndMethods.test_basic_inheritance.<locals>.madunicodeNc             S   s8   | j d k	r| j S t| }|  | d|| _ | j S )Nr}   )re  r.   r  r   ri  )r2   r  r7   r7   r8   rf    s    
zHClassPropertiesAndMethods.test_basic_inheritance.<locals>.madunicode.rev)ry   rz   r{   re  rf  r7   r7   r7   r8   
madunicode  s   rl  ZABCDEFZFEDCBAZxyc               @   s   e Zd ZdS )zAClassPropertiesAndMethods.test_basic_inheritance.<locals>.sublistN)ry   rz   r{   r7   r7   r7   r8   sublistX  s   rm  r  rf         r   i)!r%   r=   rm   r   r   r  r  r#   rA   r&   r   rN  rf  r   ri  mapr\  striplstriprstrip	translatereplaceljustr   rjustcenterlowerupper
capitalizetitler.   ri   r   )r2   r;   r`  rb  rc  baserg  rp   rF   r  r   rj  rj  Zidentitytabrl  rm  r7   )r[  r_  r8   test_basic_inheritanceM
  s   

			

z0ClassPropertiesAndMethods.test_basic_inheritancec          	   C   sF  |  td tdd W d Q R X |  td tdd W d Q R X |  td tdd W d Q R X | tdddtdd | tdd	d
 | tdddd |  td tt	dd W d Q R X |  td t
dd W d Q R X xRtttttttt
fD ]:}y|dd W n tk
r,   Y nX | d|  qW d S )Nzkeyword argumentr]   )r   r^   r   i  )r   r   i  )r   500s   abcstrict)r   errorsrY  r_   )Zsequence)r   r]   r^   )Zbogus_keyword_argz4expected TypeError from bogus keyword argument to %r)ZassertRaisesRegexr   r%   r&   boolr=   r   r  rN  r   r.   r   )r2   constructorr7   r7   r8   test_keywords  s*    z'ClassPropertiesAndMethods.test_keywordsc                s   G  fdddt  |  dd | d d | t  dd  dd dd	 d
di}| | d d | | d d	 | | d d |  d| | | dd d S )Nc                   s,   e Zd ZdZdd Z fddZdd ZdS )	zFClassPropertiesAndMethods.test_str_subclass_as_dict_key.<locals>.cistrzSublcass of str that computes __eq__ case-insensitively.

            Also computes a hash code of the string in canonical form.
            c             S   s   |  | _t| j| _d S )N)rz  	canonicalr  hashcode)r2   r   r7   r7   r8   r,     s    
zOClassPropertiesAndMethods.test_str_subclass_as_dict_key.<locals>.cistr.__init__c                s   t | s |}| j|jkS )N)r   r  )r2   rx   )cistrr7   r8   ra    s    
zMClassPropertiesAndMethods.test_str_subclass_as_dict_key.<locals>.cistr.__eq__c             S   s   | j S )N)r  )r2   r7   r7   r8   r    s    zOClassPropertiesAndMethods.test_str_subclass_as_dict_key.<locals>.cistr.__hash__N)ry   rz   r{   rV  r,   ra  r  r7   )r  r7   r8   r    s   r  ABCrY  ZaBcr*  r]   r+  r^   ZtHreer_   ZtWoZTHrEEZONeZthrEE)r  r=   r  r   )r2   rE   r7   )r  r8   test_str_subclass_as_dict_key  s    z7ClassPropertiesAndMethods.test_str_subclass_as_dict_keyc       
         s  G dd d}x|t tfD ]}G  fddd|  d} d} d}| |d |||d}xdD ]}xdD ]}x~d	D ]v}	| td
|	 td|	 d||f  | td|	 td|	 d||f  | td|	 td|	 d||f  q|W qrW qhW qW d S )Nc               @   s   e Zd ZdS )zCClassPropertiesAndMethods.test_classic_comparisons.<locals>.classicN)ry   rz   r{   r7   r7   r7   r8   classic  s   r  c                   s\   e Zd Zdd Z fddZ fddZ fddZ fd	d
Z fddZ fddZ	dS )z=ClassPropertiesAndMethods.test_classic_comparisons.<locals>.Cc             S   s   t || _d S )N)r%   r   )r2   r   r7   r7   r8   r,     s    zFClassPropertiesAndMethods.test_classic_comparisons.<locals>.C.__init__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   ra    s
    

zDClassPropertiesAndMethods.test_classic_comparisons.<locals>.C.__eq__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r     s
    

zDClassPropertiesAndMethods.test_classic_comparisons.<locals>.C.__ne__c                s8   t | r| j|jk S t |ts*t |tr4| j|k S tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r    s
    

zDClassPropertiesAndMethods.test_classic_comparisons.<locals>.C.__lt__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r    s
    

zDClassPropertiesAndMethods.test_classic_comparisons.<locals>.C.__le__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r    s
    

zDClassPropertiesAndMethods.test_classic_comparisons.<locals>.C.__gt__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r    s
    

zDClassPropertiesAndMethods.test_classic_comparisons.<locals>.C.__ge__N)
ry   rz   r{   r,   ra  r   r  r  r  r  r7   )r|   r7   r8   r|     s   r|   r]   r^   r_   )r]   r^   r_   )r   z<=z==z!=r   z>=zc[x] %s c[y]zx %s yz
x=%d, y=%dz	c[x] %s yz	x %s c[y])r%   r   r=   r>   )
r2   r  r~  r  r	  c3rP   r   yopr7   )r|   r8   test_classic_comparisons  s(    (





z2ClassPropertiesAndMethods.test_classic_comparisonsc                sj  G dd dt }|d}|d d| G dd dt }|d}|d d| G dd	 d	}x|tttfD ]}G  fd
dd|  d} d} d}	|d |||	d}
xdD ]}xdD ]}x~dD ]v}td| td| d||f  td| td| d||f  td| td| d||f  qW qW qW q|W d S )Nc               @   s   e Zd ZdS )z:ClassPropertiesAndMethods.test_rich_comparisons.<locals>.ZN)ry   rz   r{   r7   r7   r7   r8   r    s   r  r]   y      ?        c               @   s   e Zd Zdd ZdS )z;ClassPropertiesAndMethods.test_rich_comparisons.<locals>.ZZc             S   s    yt | | dkS    tS d S )Ngư>)r#   rw   )r2   rx   r7   r7   r8   ra    s    zBClassPropertiesAndMethods.test_rich_comparisons.<locals>.ZZ.__eq__N)ry   rz   r{   ra  r7   r7   r7   r8   ZZ  s   r  gׇP  ?c               @   s   e Zd ZdS )z@ClassPropertiesAndMethods.test_rich_comparisons.<locals>.classicN)ry   rz   r{   r7   r7   r7   r8   r  %  s   r  c                   sh   e Zd Zdd ZfddZ fddZ fddZ fd	d
Z fddZ fddZ	 fddZ
dS )z:ClassPropertiesAndMethods.test_rich_comparisons.<locals>.Cc             S   s   t || _d S )N)r%   r   )r2   r   r7   r7   r8   r,   )  s    zCClassPropertiesAndMethods.test_rich_comparisons.<locals>.C.__init__c                s     d d S )Nzshouldn't call __cmp__)r   )rb  rx   )r2   r7   r8   __cmp__+  s    zBClassPropertiesAndMethods.test_rich_comparisons.<locals>.C.__cmp__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   ra  -  s
    

zAClassPropertiesAndMethods.test_rich_comparisons.<locals>.C.__eq__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r   3  s
    

zAClassPropertiesAndMethods.test_rich_comparisons.<locals>.C.__ne__c                s8   t | r| j|jk S t |ts*t |tr4| j|k S tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r  9  s
    

zAClassPropertiesAndMethods.test_rich_comparisons.<locals>.C.__lt__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r  ?  s
    

zAClassPropertiesAndMethods.test_rich_comparisons.<locals>.C.__le__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r  E  s
    

zAClassPropertiesAndMethods.test_rich_comparisons.<locals>.C.__gt__c                s8   t | r| j|jkS t |ts*t |tr4| j|kS tS )N)r   r   r%   rw   )r2   rx   )r|   r7   r8   r  K  s
    

zAClassPropertiesAndMethods.test_rich_comparisons.<locals>.C.__ge__N)ry   rz   r{   r,   r  ra  r   r  r  r  r  r7   )r|   r2   r7   r8   r|   (  s   r|   r^   r_   )r]   r^   r_   )r   z<=z==z!=r   z>=zc[x] %s c[y]zx %s yz
x=%d, y=%dz	c[x] %s yz	x %s c[y])r   r=   r%   r   r.   r>   )r2   r  rg  r  Zzzr  r~  r  r	  r  rP   r   r  r  r7   )r|   r2   r8   test_rich_comparisons  s8    )





z/ClassPropertiesAndMethods.test_rich_comparisonsc                s4   ddl m}  fdd}||jd |tjd d S )Nr   )FileIOc                s     | j| d S )N)r=   rV  )descrZwhat)r2   r7   r8   checkf  s    z6ClassPropertiesAndMethods.test_descrdoc.<locals>.checkzTrue if the file is closedz!the real part of a complex number)_ior  closedr   r   )r2   r  r  r7   )r2   r8   test_descrdocc  s    z'ClassPropertiesAndMethods.test_descrdocc                sv   G dd dt  G  fddd}G  fdddt }| |jd | | jd | |jd	 | | jd
 d S )Nc               @   s   e Zd Zdd ZdS )z?ClassPropertiesAndMethods.test_doc_descriptor.<locals>.DocDescrc             S   s&   |r|j jd }|r|j}d||f S )Nz	 instancezobject=%s; type=%s)r   ry   )r2   r   Zotyper7   r7   r8   r   o  s
    zGClassPropertiesAndMethods.test_doc_descriptor.<locals>.DocDescr.__get__N)ry   rz   r{   r   r7   r7   r7   r8   DocDescrn  s   r  c                   s   e Zd Z  ZdS )z?ClassPropertiesAndMethods.test_doc_descriptor.<locals>.OldClassN)ry   rz   r{   rV  r7   )r  r7   r8   OldClassu  s   r  c                   s   e Zd Z  ZdS )z?ClassPropertiesAndMethods.test_doc_descriptor.<locals>.NewClassN)ry   rz   r{   rV  r7   )r  r7   r8   NewClassw  s   r  zobject=None; type=OldClassz'object=OldClass instance; type=OldClasszobject=None; type=NewClassz'object=NewClass instance; type=NewClass)r   r=   rV  )r2   r  r  r7   )r  r8   test_doc_descriptork  s    z-ClassPropertiesAndMethods.test_doc_descriptorc                s   G dd dt }G dd dt }G dd dt }G dd d||}xX||||fD ]H}xB||||fD ]2}| }||_|j| ||_|j| qbW qPW fd	d
}|| t |t | || d || t  |t  t |t t  G dd dt}	|dt |dt t  }
||
td ||
td  ~
G dd dt }G dd dt }G dd dt }G dd dt }G dd dt }G dd d|}G dd d|}G dd d|}G d d! d!|}G d"d# d#|}G d$d% d%|}x||f||f||f||f||ffD ]n\}}| }d|_||_|j|d&||f  |jd ||_|j|d&||f  |jd qW x`||||||||t|	f
D ]D}x<||||||||t|	f
D ] }||krȐq|| | qW qW G d'd( d(t G fd)d*d*t   fd+d,t	d-D }~d S ).Nc               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s    r|   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r     s    r   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.FN)ry   rz   r{   r7   r7   r7   r8   r    s    r  c          	      sl   y
|| _ W n tk
r   Y nX  d| |f  yt| d W n ttfk
rX   Y nX  d|   d S )Nz!shouldn't allow %r.__class__ = %rr   z shouldn't allow del %r.__class__)r   r   r   r  rB  )r   r|   )r2   r7   r8   cant  s    
z6ClassPropertiesAndMethods.test_set_class.<locals>.cantr]   c               @   s   e Zd Zg ZdS )z5ClassPropertiesAndMethods.test_set_class.<locals>.IntN)ry   rz   r{   r   r7   r7   r7   r8   Int  s    r  Tr^   c               @   s   e Zd ZddgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.Gr;   rL   N)ry   rz   r{   r   r7   r7   r7   r8   r!    s   r!  c               @   s   e Zd ZddgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.HrL   r;   N)ry   rz   r{   r   r7   r7   r7   r8   rc    s   rc  c               @   s   e Zd ZddgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.Ir;   rL   N)ry   rz   r{   r   r7   r7   r7   r8   r    s   r  c               @   s   e Zd ZddgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.JrP   rL   N)ry   rz   r{   r   r7   r7   r7   r8   J  s   r  c               @   s   e Zd ZdddgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.Kr;   rL   rE   N)ry   rz   r{   r   r7   r7   r7   r8   K  s   r  c               @   s   e Zd ZdgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.Lr_  N)ry   rz   r{   r   r7   r7   r7   r8   r    s   r  c               @   s   e Zd ZdgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.Mr_  N)ry   rz   r{   r   r7   r7   r7   r8   rE    s   rE  c               @   s   e Zd ZdgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.Nrn  N)ry   rz   r{   r   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.PrA   N)ry   rz   r{   r   r7   r7   r7   r8   P  s   r  c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.QN)ry   rz   r{   r7   r7   r7   r8   Q  s   r  c               @   s   e Zd ZddgZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.RrA   rn  N)ry   rz   r{   r   r7   r7   r7   r8   R  s   r  z0assigning %r as __class__ for %r silently failedc               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.ON)ry   rz   r{   r7   r7   r7   r8   O  s   r  c                   s   e Zd Z fddZdS )z3ClassPropertiesAndMethods.test_set_class.<locals>.Ac                s
    | _ d S )N)r   )r2   )r  r7   r8   r^    s    z;ClassPropertiesAndMethods.test_set_class.<locals>.A.__del__N)ry   rz   r{   r^  r7   )r  r7   r8   r     s   r   c                s   g | ]
}  qS r7   r7   )r3  r   )r   r7   r8   r4    s    z<ClassPropertiesAndMethods.test_set_class.<locals>.<listcomp>rv   )
r   r   r   r.   r%   r  r?   r;   r=   r   )r2   r|   r   r   r  r   Zcls2r   r  r  or!  rc  r  r  r  r  rE  r   r  r  r  rq   r7   )r   r  r2   r8   test_set_class~  sp    

,


z(ClassPropertiesAndMethods.test_set_classc          	      s  G dd dt }| }ddi|_|jd fdd|d  |g  |d |`G dd dt   fd	d
}G dd dt }G dd d t}G dd dt |d}G dd dt |d}xR|||fD ]D}|| |j}	yd|	d< W n tk
r   Y qX d|  qW G dd dtj }
G dd d tj}x,|
|fD ] }|d}|| d|jd< qNW dd }G dd dt	 }G dd  d  t	}xHt	||fD ]:}| }d!di|_|j
d |||t  qW d S )"Nc               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_set_dict.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s    r|   rL   r]   c          	      s:   y
|| _ W n ttfk
r"   Y nX  d| |f  d S )Nz shouldn't allow %r.__dict__ = %r)rA   rB  r   r   )r   rl   )r2   r7   r8   r    s
    
z5ClassPropertiesAndMethods.test_set_dict.<locals>.cantc               @   s   e Zd ZdS )z5ClassPropertiesAndMethods.test_set_dict.<locals>.BaseN)ry   rz   r{   r7   r7   r7   r8   rU    s   rU  c          	      s   | i  y| ` W n ttfk
r*   Y nX d|    j d }y|| i  W n ttfk
rl   Y nX d|   dS )zR
            x has to be an instance of a class inheriting from Base.
            zshouldn't allow del %r.__dict__rA   z&dict_descr allowed access to %r's dictN)rA   rB  r   r   r~  )r   Z
dict_descr)rU  r  r2   r7   r8   verify_dict_readonly  s    

zEClassPropertiesAndMethods.test_set_dict.<locals>.verify_dict_readonlyc               @   s   e Zd ZdS )z6ClassPropertiesAndMethods.test_set_dict.<locals>.Meta1N)ry   rz   r{   r7   r7   r7   r8   Meta1  s   r  c               @   s   e Zd ZdS )z6ClassPropertiesAndMethods.test_set_dict.<locals>.Meta2N)ry   rz   r{   r7   r7   r7   r8   Meta2  s   r  c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_set_dict.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   )r   c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_set_dict.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r     s   r   Zeggsr   z%r's __dict__ can be modifiedc               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_set_dict.<locals>.Module1N)ry   rz   r{   r7   r7   r7   r8   Module1  s   r  c               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_set_dict.<locals>.Module2N)ry   rz   r{   r7   r7   r7   r8   Module2  s   r  c          	   S   s*   y| ` W n ttfk
r    dS X dS d S )NFT)rA   r   rB  )r_  r7   r7   r8   can_delete_dict  s
    z@ClassPropertiesAndMethods.test_set_dict.<locals>.can_delete_dictc               @   s   e Zd ZdS )z;ClassPropertiesAndMethods.test_set_dict.<locals>.Exception1N)ry   rz   r{   r7   r7   r7   r8   
Exception1&  s   r  c               @   s   e Zd ZdS )z;ClassPropertiesAndMethods.test_set_dict.<locals>.Exception2N)ry   rz   r{   r7   r7   r7   r8   
Exception2(  s   r  r;   )r   rA   r=   rL   r?   r   r   r  r  r  r;   r5  )r2   r|   r;   r  r  r  r   r   r   Z
class_dictr  r  r  r   r  r  r  ZExceptionTyper_  r7   )rU  r  r2   r8   test_set_dict  sJ    




z'ClassPropertiesAndMethods.test_set_dictc                s   G  fdddt  | t d d d | t dd d | td d d | t d d d | td d d | t dd d | tt d d dd G d	d
 d
t}d S )Nc                   s@   e Zd Zdd Z fddZeZd
 fdd	Zd fdd		ZdS )zBClassPropertiesAndMethods.test_binary_operator_override.<locals>.Ic             S   s   dt |  S )NzI(%r))r%   )r2   r7   r7   r8   rn   3  s    zKClassPropertiesAndMethods.test_binary_operator_override.<locals>.I.__repr__c                s    t | t | S )N)r%   )r2   rx   )r  r7   r8   rK   5  s    zJClassPropertiesAndMethods.test_binary_operator_override.<locals>.I.__add__Nc                s>   |d kr t t| t|S  t t| t|t|S d S )N)r   r%   )r2   rx   r   )r  r7   r8   __pow__8  s    zJClassPropertiesAndMethods.test_binary_operator_override.<locals>.I.__pow__c                s@   |d kr  t t|t| |S  t t|t| t|S d S )N)r   r%   )r2   rx   r   )r  r7   r8   __rpow__=  s    zKClassPropertiesAndMethods.test_binary_operator_override.<locals>.I.__rpow__)N)N)ry   rz   r{   rn   rK   r   r  r  r7   )r  r7   r8   r  2  s
   r  r]   r^   zI(3)r_   zI(8)re   c               @   s   e Zd Zdd ZdS )zBClassPropertiesAndMethods.test_binary_operator_override.<locals>.Sc             S   s   |   |  kS )N)rz  )r2   rx   r7   r7   r8   ra  K  s    zIClassPropertiesAndMethods.test_binary_operator_override.<locals>.S.__eq__N)ry   rz   r{   ra  r7   r7   r7   r8   SJ  s   r  )r%   r=   rm   r   r  )r2   r  r7   )r  r8   test_binary_operator_override0  s    $z7ClassPropertiesAndMethods.test_binary_operator_overridec       	      C   s|  G dd dt }G dd d|}G dd d|}G dd d||}| }t|}d	d
 |_| t|d dd
 |_| t|d dd
 |_| t|d dd
 |_| t|d d |_| tt| |`| t|d d |_| tt| |`| t|d d |_| tt| |`| t|d d |_| tt| |`| t|| d|_d|_| |jd | |jd dd }||_| |jd | |jd dd }||_	| |j
d | |jd | |jd |`| |jd |`| |jd | |jd |`	y
|j W n tk
r8   Y nX | d G dd dt }G dd d|}~t  dd
 |_d S )Nc               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_subclass_propagation.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r   P  s   r   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_subclass_propagation.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r   R  s   r   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_subclass_propagation.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   T  s   r|   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_subclass_propagation.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r   V  s   r   c             S   s   dS )Nr   r7   )r2   r7   r7   r8   r  Z  r   zEClassPropertiesAndMethods.test_subclass_propagation.<locals>.<lambda>r   c             S   s   dS )Ni:  r7   )r2   r7   r7   r8   r  \  r   i:  c             S   s   dS )N   r7   )r2   r7   r7   r8   r  ^  r   r  c             S   s   dS )Nrv   r7   )r2   r7   r7   r8   r  `  r   rv   c             S   s   |dkrdS t | |S )Nr   r   )r   r  )r2   r5   r7   r7   r8   r  v  s    zMClassPropertiesAndMethods.test_subclass_propagation.<locals>.__getattribute__r   c             S   s   |dkrdS t |d S )N)r   r   r   r  )rB  )r2   r5   r7   r7   r8   r  }  s    zHClassPropertiesAndMethods.test_subclass_propagation.<locals>.__getattr__r  zd.foo should be undefined nowc               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_subclass_propagation.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_subclass_propagation.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   c              W   s   d S )Nr7   )r;   r7   r7   r8   r    r   )r   r  r  r=   r
  r   r   r   r  r  r   rB  r   r   rf  rY   )	r2   r   r   r|   r   rE   Z	orig_hashr  r  r7   r7   r8   test_subclass_propagationN  sv    





z3ClassPropertiesAndMethods.test_subclass_propagationc             C   s   dd l }G dd dt}d}||}| |||| G dd dt}|d}y|| | d W n tk
r   Y nX d S )	Nr   c               @   s   e Zd ZdS )zBClassPropertiesAndMethods.test_buffer_inheritance.<locals>.MyBytesN)ry   rz   r{   r7   r7   r7   r8   rI    s   rI  s   abcc               @   s   e Zd ZdS )z@ClassPropertiesAndMethods.test_buffer_inheritance.<locals>.MyIntN)ry   rz   r{   r7   r7   r7   r8   rE    s   rE  r   z2subclass of int should not have a buffer interface)binasciirM  r=   b2a_hexr%   r   r   )r2   r  rI  r~  rG   rE  r7   r7   r8   test_buffer_inheritance  s    
z1ClassPropertiesAndMethods.test_buffer_inheritancec                s   dd l  dd l}G  fdddt}|d}| t|| | tt|t | tt|t | t|d | t|d | t|d | | d | | d |	 }t
||d t
t||d | | d	 |  d S )
Nr   c                   s    e Zd Z fddZdd ZdS )zGClassPropertiesAndMethods.test_str_of_str_subclass.<locals>.octetstringc                s     | ddS )Nascii)r  encodedecode)r2   )r  r7   r8   r     s    zOClassPropertiesAndMethods.test_str_of_str_subclass.<locals>.octetstring.__str__c             S   s   | d S )Nz reprr7   )r2   r7   r7   r8   rn     s    zPClassPropertiesAndMethods.test_str_of_str_subclass.<locals>.octetstring.__repr__N)ry   rz   r{   r   rn   r7   )r  r7   r8   octetstring  s   r  r   A   Z41zA repr)filez41
41
)r  ior  r=   r?   rm   ordr   rn   StringIOprintri  close)r2   r  r  r  Zcapturer7   )r  r8   test_str_of_str_subclass  s"    z2ClassPropertiesAndMethods.test_str_of_str_subclassc             C   sD   dd }|  |jddd t }tj|dddd |  |d	 d S )
Nc             S   s   | S )Nr7   )r;   r7   r7   r8   r    r   z;ClassPropertiesAndMethods.test_keyword_arguments.<locals>.fr   )r;   u   abc½€latin1rv  )encodingr  s   abc?)r=   r   	bytearrayr,   )r2   r  Zbar7   r7   r8   test_keyword_arguments  s    
z0ClassPropertiesAndMethods.test_keyword_argumentsc             C   sH   G dd dt }| |_y|   W n tk
r8   Y nX | d d S )Nc               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_recursive_call.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   z7Recursion limit should have been reached for __call__())r   r   RecursionErrorr   )r2   r   r7   r7   r8   test_recursive_call  s    z-ClassPropertiesAndMethods.test_recursive_callc                s   g  G  fdddt }| }|  g  ~t  |  dg G dd dt }| }y
|d= W n tk
rv   Y nX | d d S )Nc                   s   e Zd Z fddZdS )z5ClassPropertiesAndMethods.test_delete_hook.<locals>.Cc                s     d d S )Nr]   )ri   )r2   )r  r7   r8   r^    s    z=ClassPropertiesAndMethods.test_delete_hook.<locals>.C.__del__N)ry   rz   r{   r^  r7   )r  r7   r8   r|     s   r|   r]   c               @   s   e Zd ZdS )z5ClassPropertiesAndMethods.test_delete_hook.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s    r   r   z$invalid del() didn't raise TypeError)r   r=   r   rf  r   r   )r2   r|   rP   r   rE   r7   )r  r8   test_delete_hook  s     
 z*ClassPropertiesAndMethods.test_delete_hookc             C   s   G dd dt }| }yt| W n tk
r6   Y nX | d G dd dt}| }yt| W n tk
rx   Y nX | d d S )Nc               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_hash_inheritance.<locals>.mydictN)ry   rz   r{   r7   r7   r7   r8   mydict  s   r  z#hash() of dict subclass should failc               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_hash_inheritance.<locals>.mylistN)ry   rz   r{   r7   r7   r7   r8   mylist  s   r  z#hash() of list subclass should fail)rl   r  r   r   r.   )r2   r  rE   r  r7   r7   r8   test_hash_inheritance  s    
z/ClassPropertiesAndMethods.test_hash_inheritancec             C   s  ydd  W n t k
r    Y nX | d ydd W n tk
rN   Y nX | d yddg W n t k
r~   Y nX | d ydd W n tk
r   Y nX | d	 yd
d   W n t k
r   Y nX | d ydi   W n tk
r   Y nX | d ydd  W n t k
r4   Y nX | d ydd  W n t k
rb   Y nX | d ydd  W n t k
r   Y nX | d ydd   W n tk
r   Y nX | d | d d | d d | dd d | dd d d S )Nr;   re   z'' + 5 doesn't raise TypeErrorr}   z%''.split('') doesn't raise ValueErrorr   z$''.join([0]) doesn't raise TypeError5z'''.rindex('5') doesn't raise ValueErrorz%(n)sz&'%(n)s' % None doesn't raise TypeErrorz%(nz&'%(n' % {} '' doesn't raise ValueErrorz%*srY  z''%*s' % ('abc') doesn't raise TypeErrorz%*.*s)rY  re   z,'%*.*s' % ('abc', 5) doesn't raise TypeErrorz%s)r]   r^   z%'%s' % (1, 2) doesn't raise TypeError%z#'%' % None doesn't raise ValueErrorZ534253r]   Z534253xz%c)r   r   splitr5  ri  rindexr=   isdigit)r2   r7   r7   r8   test_str_operations  sl      
  
  
  
  
  
  
  
  
  
z-ClassPropertiesAndMethods.test_str_operationsc             C   s2   G dd d}| }| }||_ ||_t|}d S )Nc               @   s   e Zd ZdS )z?ClassPropertiesAndMethods.test_deepcopy_recursive.<locals>.NodeN)ry   rz   r{   r7   r7   r7   r8   r  =  s   r  )rL   r;   r   )r2   r  r;   rL   rg  r7   r7   r8   test_deepcopy_recursive;  s    z1ClassPropertiesAndMethods.test_deepcopy_recursivec             C   sj   ddl m} ||}t| | |d | |d | |d | |j d|_| |jddi d S )Nr   )r  ry   __file__r   r]   )	r  r  r   r  r   r   rA   r   r=   )r2   rE  rG   r7   r7   r8   test_uninitialized_modulesE  s    
z4ClassPropertiesAndMethods.test_uninitialized_modulesc                sR  G  fdddt }G dd d| | |ddddg |  ddddg  d }| |jd  |d}| |  | |jd  d}| |  | |jd G d	d dt }| |dd|ddf G d
d d| |  dd ddf G dd dt }| |dd||ddf G dd d| |  dd  ddf d S )Nc                   s   e Zd Z fddZdS )z3ClassPropertiesAndMethods.test_funny_new.<locals>.Cc                s6   t |trdddgS t |tr(t S t| S d S )Nr]   r^   r_   )r   r  r%   r   r   )r   r  )r   r7   r8   r   T  s
    
 

 
z;ClassPropertiesAndMethods.test_funny_new.<locals>.C.__new__N)ry   rz   r{   r   r7   )r   r7   r8   r|   S  s   r|   c               @   s   e Zd Zdd ZdS )z3ClassPropertiesAndMethods.test_funny_new.<locals>.Dc             S   s
   || _ d S )N)r   )r2   r  r7   r7   r8   r,   Y  s    z<ClassPropertiesAndMethods.test_funny_new.<locals>.D.__init__N)ry   rz   r{   r,   r7   r7   r7   r8   r   X  s   r   rX  r]   r^   r_   c               @   s   e Zd Zedd ZdS )z3ClassPropertiesAndMethods.test_funny_new.<locals>.Cc              W   s   | S )Nr7   )r3   r7   r7   r8   r   g  s    z;ClassPropertiesAndMethods.test_funny_new.<locals>.C.__new__N)ry   rz   r{   r   r   r7   r7   r7   r8   r|   f  s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_funny_new.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r   k  s   c               @   s   e Zd Zedd ZdS )z3ClassPropertiesAndMethods.test_funny_new.<locals>.Cc              W   s   | S )Nr7   )r3   r7   r7   r8   r   p  s    z;ClassPropertiesAndMethods.test_funny_new.<locals>.C.__new__N)ry   rz   r{   r   r   r7   r7   r7   r8   r|   o  s   c               @   s   e Zd ZdS )z3ClassPropertiesAndMethods.test_funny_new.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r   t  s   )r   r=   r   r   )r2   r|   rE   r7   )r   r8   test_funny_newQ  s(    z(ClassPropertiesAndMethods.test_funny_newc             C   s   G dd dt }| }|}|d9 }| ||df |}|d9 }| ||df |}|d9 }| ||df |}|d9 }| ||df |}|d 9 }| ||d f |}|d9 }| ||df d S )Nc               @   s   e Zd Zdd ZdS )z2ClassPropertiesAndMethods.test_imul_bug.<locals>.Cc             S   s   | |fS )Nr7   )r2   rx   r7   r7   r8   rb   |  s    z;ClassPropertiesAndMethods.test_imul_bug.<locals>.C.__imul__N)ry   rz   r{   rb   r7   r7   r7   r8   r|   {  s   r|   g      ?r^   r_   l                r   )r   r=   )r2   r|   r   r  r7   r7   r8   test_imul_bugx  s(    z'ClassPropertiesAndMethods.test_imul_bugc                s   dd l }G  fdddt}|d}|d  |jd  | d | |} |jd  | d ||} |jd  | d d S )Nr   c                   s<   e Zd ZdddZdddZdd Zdd	 Z fd
dZdS )z7ClassPropertiesAndMethods.test_copy_setstate.<locals>.CNc             S   s   || _ || _d S )N)r   _C__foo)r2   r   r7   r7   r8   r,     s    z@ClassPropertiesAndMethods.test_copy_setstate.<locals>.C.__init__c             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   setfoo  s    z>ClassPropertiesAndMethods.test_copy_setstate.<locals>.C.setfooc             S   s   | j S )N)r  )r2   r7   r7   r8   getfoo  s    z>ClassPropertiesAndMethods.test_copy_setstate.<locals>.C.getfooc             S   s   | j gS )N)r   )r2   r7   r7   r8   __getstate__  s    zDClassPropertiesAndMethods.test_copy_setstate.<locals>.C.__getstate__c                s$     t|d |d  | _| _d S )Nr]   r   )r=   r   r  r   )rb  Zlst)r2   r7   r8   __setstate__  s    zDClassPropertiesAndMethods.test_copy_setstate.<locals>.C.__setstate__)N)N)ry   rz   r{   r,   r  r  r  r  r7   )r2   r7   r8   r|     s
   

r|   r   r   )r   r   r  r=   r   r  r   )r2   r   r|   r;   rL   r7   )r2   r8   test_copy_setstate  s    


z,ClassPropertiesAndMethods.test_copy_setstatec             C   s  |  dd d d |  dtd d |  tdtdd G dd dt}|  |dd d d |  |dtd d |  |dtdd |  dd d d |  dtd d |  tdtdd G d	d
 d
t}|  |dd d d |  |dtd d |  |dtdd |  dddgd d ddg |  dddgtd ddg |  tdddgtdddg G dd dt}|  |dddgd d ddg |  |dddgtd ddg |  |dddgtdddg |dddg}ddg|tdd< |  |dddg ddg|tddd< |  |dddg |tddddg |  |dddg |tdddddg |  |dddg d S )Nr  ra   Zhellc               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_slices.<locals>.Sc             S   s   t | |S )N)r  rO   )r2   r   r7   r7   r8   rO     s    z<ClassPropertiesAndMethods.test_slices.<locals>.S.__getitem__N)ry   rz   r{   rO   r7   r7   r7   r8   r    s   r  )r]   r^   r_   r^   )r]   r^   c               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_slices.<locals>.Tc             S   s   t | |S )N)rN  rO   )r2   r   r7   r7   r8   rO     s    z<ClassPropertiesAndMethods.test_slices.<locals>.T.__getitem__N)ry   rz   r{   rO   r7   r7   r7   r8   r     s   r   r]   r_   c               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_slices.<locals>.Lc             S   s   t | |S )N)r.   rO   )r2   r   r7   r7   r8   rO     s    z<ClassPropertiesAndMethods.test_slices.<locals>.L.__getitem__N)ry   rz   r{   rO   r7   r7   r7   r8   r    s   r  r   )r=   rQ   r  rO   rN  r.   rY   )r2   r  r   r  r;   r7   r7   r8   test_slices  s<    """$z%ClassPropertiesAndMethods.test_slicesc                sD   G  fdddt    }d|_~t  | t jd  `d S )Nc                   s   e Zd Zg Z fddZdS )z>ClassPropertiesAndMethods.test_subtype_resurrection.<locals>.Cc                s    j |  d S )N)	containerri   )r2   )r|   r7   r8   r^    s    zFClassPropertiesAndMethods.test_subtype_resurrection.<locals>.C.__del__N)ry   rz   r{   r  r^  r7   )r|   r7   r8   r|     s   r|   r   r]   )r   rr  r   rf  r=   r   r  r^  )r2   rP   r7   )r|   r8   test_subtype_resurrection  s    z3ClassPropertiesAndMethods.test_subtype_resurrectionc             C   s4   G dd dt }d }xtdD ]}||}qW ~d S )Nc               @   s   e Zd ZdgZdd ZdS )z9ClassPropertiesAndMethods.test_slots_trash.<locals>.trashr   c             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r,     s    zBClassPropertiesAndMethods.test_slots_trash.<locals>.trash.__init__N)ry   rz   r{   r   r,   r7   r7   r7   r8   trash  s   r  iP  )r   r   )r2   r  r  rp   r7   r7   r8   test_slots_trash  s
    z*ClassPropertiesAndMethods.test_slots_trashc             C   sn   G dd dt }G dd dt }G dd d||}t rJ| |j|j | |d | |d d	| _d S )
Nc               @   s   e Zd ZdZdS )zDClassPropertiesAndMethods.test_slots_multiple_inheritance.<locals>.Ar7   N)ry   rz   r{   r   r7   r7   r7   r8   r      s   r   c               @   s   e Zd ZdS )zDClassPropertiesAndMethods.test_slots_multiple_inheritance.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdZdS )zDClassPropertiesAndMethods.test_slots_multiple_inheritance.<locals>.Cr7   N)ry   rz   r{   r   r7   r7   r7   r8   r|     s   r|   rA   rn  r^   )r   r   r4  r=   __basicsize__r   r   )r2   r   r   r|   r7   r7   r8   test_slots_multiple_inheritance  s    z9ClassPropertiesAndMethods.test_slots_multiple_inheritancec             C   sZ   G dd dt }| }| |d d | |d d | d| d | d| d d S )Nc               @   s   e Zd Zdd Zdd ZdS )z.ClassPropertiesAndMethods.test_rmul.<locals>.Cc             S   s   dS )Nr   r7   )r2   rx   r7   r7   r8   rc     s    z6ClassPropertiesAndMethods.test_rmul.<locals>.C.__mul__c             S   s   dS )Nrmulr7   )r2   rx   r7   r7   r8   rd     s    z7ClassPropertiesAndMethods.test_rmul.<locals>.C.__rmul__N)ry   rz   r{   rc   rd   r7   r7   r7   r8   r|     s   r|   r^   r   g@r  )r   r=   )r2   r|   r;   r7   r7   r8   	test_rmul  s    z#ClassPropertiesAndMethods.test_rmulc             C   s"   G dd dt }| }|dC }d S )Nc               @   s   e Zd Zdd ZdS )z.ClassPropertiesAndMethods.test_ipow.<locals>.Cc             S   s   d S )Nr7   )r2   rx   r7   r7   r8   __ipow__  s    z7ClassPropertiesAndMethods.test_ipow.<locals>.C.__ipow__N)ry   rz   r{   r  r7   r7   r7   r8   r|     s   r|   r^   )r   )r2   r|   r;   r7   r7   r8   	test_ipow  s    z#ClassPropertiesAndMethods.test_ipowc          
      s  G dd dt }G  fdddt  G dd d|}G dd d|}| }| }|f|_ f|_| | d	 | | d	 | |jd
 | |jd
 |   |g y|`W n ttfk
r   Y nX | d y
d|_W n< tk
r  } zt	|dkr| d W d d }~X Y nX | d y|f|_W n tk
rN   Y nX | d y||f|_W n tk
r~   Y nX | d y|f|_W n tk
r   Y nX | d d S )Nc               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_mutable_bases.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   '  s   r|   c                   s&   e Zd Z fddZdd Z  ZS )z8ClassPropertiesAndMethods.test_mutable_bases.<locals>.C2c                s    |dkrdS t  | |S d S )Nr;   r^   )r   r  )r2   rr  )r   r   r7   r8   r  *  s    zIClassPropertiesAndMethods.test_mutable_bases.<locals>.C2.__getattribute__c             S   s   dS )Nr]   r7   )r2   r7   r7   r8   rD   /  s    z=ClassPropertiesAndMethods.test_mutable_bases.<locals>.C2.meth)ry   rz   r{   r  rD   r   r7   )r   )r   r8   r   )  s   r   c               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_mutable_bases.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r   1  s   r   c               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_mutable_bases.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r   3  s   r   r]   r^   z&shouldn't be able to delete .__bases__r7   z/a new-style class can't have only classic basesz'wrong error message for .__bases__ = ()z)shouldn't be able to set .__bases__ to ()z.shouldn't be able to create inheritance cyclesz#didn't detect repeated base classes)
r   rB   r=   rD   r;   __subclasses__r   rB  r   r  )r2   r|   r   r   rE   r_  r8  r7   )r   r8   test_mutable_bases#  sN    




z,ClassPropertiesAndMethods.test_mutable_basesc             C   s  dd t j D }x4|D ],}t|d |tk	r| t|jd| qW G dd dt}G dd dt}G d	d
 d
|}yt	f|_W n t
k
r   Y nX | d yt	ft_W n t
k
r   Y nX | d y|tf|_W n t
k
r   Y nX dstdd S )Nc             S   s   g | ]}t |tr|qS r7   )r   r?   )r3  tpr7   r7   r8   r4  g  s    z@ClassPropertiesAndMethods.test_builtin_bases.<locals>.<listcomp>rB   r]   c               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_builtin_bases.<locals>.LN)ry   rz   r{   r7   r7   r7   r8   r  n  s   r  c               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_builtin_bases.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   q  s   r|   c               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_builtin_bases.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r   t  s   r   z/shouldn't turn list subclass into dict subclassz-shouldn't be able to assign to list.__bases__r   z#best_base calculation found wanting)builtinsrA   valuesr   r  r=   r   rB   r.   rl   r   r   r  )r2   Zbuiltin_typesr  r  r|   r   r7   r7   r8   test_builtin_basesd  s.    


z,ClassPropertiesAndMethods.test_builtin_basesc          	   C   s  |  t G dd dtd }W d Q R X |  t G dd dttd }W d Q R X |  t G dd dtd t}W d Q R X G dd dt}|  t G dd d|td }W d Q R X |  t G dd dtd |}W d Q R X G d	d dt}|  t td f|_W d Q R X |  t ttd f|_W d Q R X |  t td tf|_W d Q R X |  t |td f|_W d Q R X |  t td |f|_W d Q R X d S )
Nc               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_unsubclassable_types.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_unsubclassable_types.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_unsubclassable_types.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_unsubclassable_types.<locals>.ON)ry   rz   r{   r7   r7   r7   r8   r    s   r  c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_unsubclassable_types.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_unsubclassable_types.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   c               @   s   e Zd ZdS )z>ClassPropertiesAndMethods.test_unsubclassable_types.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   )r
  r   r?   r   rB   )r2   r   r  r7   r7   r8   test_unsubclassable_types  s,        z3ClassPropertiesAndMethods.test_unsubclassable_typesc       
         s   G  fdddt  G dd dt }G dd dt}G dd dt}G d	d
 d
|}G dd d|}G dd d| d}G dd d||d}|j}|j}	y|f|_W n0 tk
r   | |j| | |j|	 Y nX | d d S )Nc                   s&   e Zd Z fddZdd Z  ZS )zOClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.WorkOncec                s   d| _ t |  |||S )Nr   )flagr   r   )r2   r5   r   r   )WorkOncer   r7   r8   r     s    zWClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.WorkOnce.__new__c             S   s0   | j dkrtdn|  j d7  _ t| S d S )Nr   Zbozor]   )r  r'  r?   r  )r2   r7   r7   r8   r    s    

zSClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.WorkOnce.mro)ry   rz   r{   r   r  r   r7   )r  )r   r8   r    s   r  c               @   s   e Zd Zdd ZdS )zQClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.WorkAlwaysc             S   s
   t | S )N)r?   r  )r2   r7   r7   r8   r    s    zUClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.WorkAlways.mroN)ry   rz   r{   r  r7   r7   r7   r8   
WorkAlways  s   r  c               @   s   e Zd ZdS )zHClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r|   c               @   s   e Zd ZdS )zIClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.C2N)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )zHClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )zHClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )zHClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.FN)ry   rz   r{   r7   r7   r7   r8   r    s   r  )r   c               @   s   e Zd ZdS )zHClassPropertiesAndMethods.test_mutable_bases_with_failing_mro.<locals>.GN)ry   rz   r{   r7   r7   r7   r8   r!    s   r!  zexception not propagated)r?   r   r  rB   r'  r=   r   )
r2   r  r|   r   r   r   r  r!  ZE_mro_beforeZD_mro_beforer7   )r  r8   #test_mutable_bases_with_failing_mro  s     z=ClassPropertiesAndMethods.test_mutable_bases_with_failing_mroc             C   s   G dd dt }G dd dt }G dd d||}G dd d||}G d	d
 d
||}y||f|_W n tk
rx   Y nX | d d S )Nc               @   s   e Zd ZdS )zJClassPropertiesAndMethods.test_mutable_bases_catch_mro_conflict.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )zJClassPropertiesAndMethods.test_mutable_bases_catch_mro_conflict.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )zJClassPropertiesAndMethods.test_mutable_bases_catch_mro_conflict.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r|   c               @   s   e Zd ZdS )zJClassPropertiesAndMethods.test_mutable_bases_catch_mro_conflict.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )zJClassPropertiesAndMethods.test_mutable_bases_catch_mro_conflict.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r     s   r   zdidn't catch MRO conflict)r   rB   r   r   )r2   r   r   r|   r   r   r7   r7   r8   %test_mutable_bases_catch_mro_conflict  s    z?ClassPropertiesAndMethods.test_mutable_bases_catch_mro_conflictc             C   sV   G dd dt }|j}d|_| |j|jf|df d|_| |j|jf|df d S )Nc               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_mutable_names.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r|   r   zD.E)r   rz   ry   r=   )r2   r|   r   r7   r7   r8   test_mutable_names  s    z,ClassPropertiesAndMethods.test_mutable_namesc                s6   G  fdddt }G dd d |d _d _d S )Nc                   s   e Zd Z fddZdS )z<ClassPropertiesAndMethods.test_evil_type_name.<locals>.Nastyc                s
   d _ d S )Nrx   )ry   )r2   )r|   r7   r8   r^    s    zDClassPropertiesAndMethods.test_evil_type_name.<locals>.Nasty.__del__N)ry   rz   r{   r^  r7   )r|   r7   r8   Nasty  s   r  c               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_evil_type_name.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r|   rY  Znormal)r  ry   )r2   r  r7   )r|   r8   test_evil_type_name  s    
z-ClassPropertiesAndMethods.test_evil_type_namec             C   s  G dd dt }| |dd d | d|d d G dd dt}| | d d | d|  d	 G d
d d|}| | |  d | | |  d G dd d|}| |j|j | | d d | d|  d	 | | |  d | | |  d d S )Nc               @   s   e Zd Zdd Zdd ZdS )z;ClassPropertiesAndMethods.test_subclass_right_op.<locals>.Bc             S   s   dS )NzB.__floordiv__r7   )r2   rx   r7   r7   r8   __floordiv__  s    zHClassPropertiesAndMethods.test_subclass_right_op.<locals>.B.__floordiv__c             S   s   dS )NzB.__rfloordiv__r7   )r2   rx   r7   r7   r8   __rfloordiv__!  s    zIClassPropertiesAndMethods.test_subclass_right_op.<locals>.B.__rfloordiv__N)ry   rz   r{   r  r  r7   r7   r7   r8   r     s   r   r]   zB.__floordiv__zB.__rfloordiv__c               @   s   e Zd Zdd Zdd ZdS )z;ClassPropertiesAndMethods.test_subclass_right_op.<locals>.Cc             S   s   dS )NzC.__floordiv__r7   )r2   rx   r7   r7   r8   r  *  s    zHClassPropertiesAndMethods.test_subclass_right_op.<locals>.C.__floordiv__c             S   s   dS )NzC.__rfloordiv__r7   )r2   rx   r7   r7   r8   r  ,  s    zIClassPropertiesAndMethods.test_subclass_right_op.<locals>.C.__rfloordiv__N)ry   rz   r{   r  r  r7   r7   r7   r8   r|   )  s   r|   zC.__floordiv__zC.__rfloordiv__c               @   s   e Zd Zdd Zdd ZdS )z;ClassPropertiesAndMethods.test_subclass_right_op.<locals>.Dc             S   s   dS )NzD.__floordiv__r7   )r2   rx   r7   r7   r8   r  5  s    zHClassPropertiesAndMethods.test_subclass_right_op.<locals>.D.__floordiv__c             S   s   dS )NzD.__rfloordiv__r7   )r2   rx   r7   r7   r8   r  7  s    zIClassPropertiesAndMethods.test_subclass_right_op.<locals>.D.__rfloordiv__N)ry   rz   r{   r  r  r7   r7   r7   r8   r   4  s   r   zD.__floordiv__zD.__rfloordiv__c               @   s   e Zd ZdS )z;ClassPropertiesAndMethods.test_subclass_right_op.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r   ?  s   r   )r%   r=   r   r  )r2   r   r|   r   r   r7   r7   r8   test_subclass_right_op  s    z0ClassPropertiesAndMethods.test_subclass_right_opz)testing an internal kind of method objectc             C   s6  dddg}d d d d}|  t|| |  i || tjd }|  |d t|| |  |i || y|d d  W n tk
r   Y nX | d y|d W n tk
r   Y nX | d y|d d W n tk
r   Y nX | d	 y|d t W n tk
r&   Y nX | d
 d S )Nr]   r^   r_   )r]   r^   r_   fromkeysz0shouldn't have allowed descr.__get__(None, None)r   z(shouldn't have allowed descr.__get__(42)z.shouldn't have allowed descr.__get__(None, 42)z/shouldn't have allowed descr.__get__(None, int))r=   rl   r  rA   r   r   r   r%   )r2   r  rC   r  r7   r7   r8   test_meth_class_getI  s6    




z-ClassPropertiesAndMethods.test_meth_class_getc             C   s   G dd dt }G dd d}| }||}| || | || G dd d|}| }||}| || | || G dd dt }| }||}| || | || G dd d|}| }||}| || | || d S )	Nc               @   s   e Zd Zdd Zdd ZdS )z<ClassPropertiesAndMethods.test_isinst_isclass.<locals>.Proxyc             S   s
   || _ d S )N)_Proxy__obj)r2   r   r7   r7   r8   r,   x  s    zEClassPropertiesAndMethods.test_isinst_isclass.<locals>.Proxy.__init__c             S   s&   | drt| |S t| j|S d S )N_Proxy__)r   r   r  r@   r   )r2   r5   r7   r7   r8   r  z  s    
zMClassPropertiesAndMethods.test_isinst_isclass.<locals>.Proxy.__getattribute__N)ry   rz   r{   r,   r  r7   r7   r7   r8   r  w  s   r  c               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_isinst_isclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r|   c               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_isinst_isclass.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_isinst_isclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   c               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_isinst_isclass.<locals>.DN)ry   rz   r{   r7   r7   r7   r8   r     s   )r   r   )r2   r  r|   r;   par   r7   r7   r8   test_isinst_isclassu  s*    	z-ClassPropertiesAndMethods.test_isinst_isclassc                s\   G dd dt }G dd dt }G  fddd|   }||}|  jd |d d S )	Nc               @   s   e Zd Zdd Zdd ZdS )z9ClassPropertiesAndMethods.test_proxy_super.<locals>.Proxyc             S   s
   || _ d S )N)r   )r2   r   r7   r7   r8   r,     s    zBClassPropertiesAndMethods.test_proxy_super.<locals>.Proxy.__init__c             S   s&   | drt| |S t| j|S d S )Nr  )r   r   r  r@   r   )r2   r5   r7   r7   r8   r    s    
zJClassPropertiesAndMethods.test_proxy_super.<locals>.Proxy.__getattribute__N)ry   rz   r{   r,   r  r7   r7   r7   r8   r    s   r  c               @   s   e Zd Zdd ZdS )z5ClassPropertiesAndMethods.test_proxy_super.<locals>.Bc             S   s   dS )NzB.fr7   )r2   r7   r7   r8   r    s    z7ClassPropertiesAndMethods.test_proxy_super.<locals>.B.fN)ry   rz   r{   r  r7   r7   r7   r8   r     s   r   c                   s   e Zd Z fddZ  ZS )z5ClassPropertiesAndMethods.test_proxy_super.<locals>.Cc                s   t  |  d S )Nz->C.f)r   r  )r2   )r|   r   r7   r8   r    s    z7ClassPropertiesAndMethods.test_proxy_super.<locals>.C.f)ry   rz   r{   r  r   r7   )r|   )r   r8   r|     s   r|   r  zB.f->C.f)r   r=   rA   )r2   r  r   r   r!  r7   )r|   r8   test_proxy_super  s    	z*ClassPropertiesAndMethods.test_proxy_superc             C   sf   yt tdd W n tk
r&   Y nX | d yt td W n tk
rV   Y nX | d d S )Nr   r   z"Carlo Verre __setattr__ succeeded!rz  z"Carlo Verre __delattr__ succeeded!)r   r  r  r   r   r  )r2   r7   r7   r8   test_carloverre  s    
z)ClassPropertiesAndMethods.test_carloverrec                s@   dd l  G  fddd}G dd dt}| }|||_~d S )Nr   c                   s    e Zd Z fddZdd ZdS )zAClassPropertiesAndMethods.test_weakref_segfault.<locals>.Provokerc                s     || _ d S )N)r  )r2   Z	referrent)r  r7   r8   r,     s    zJClassPropertiesAndMethods.test_weakref_segfault.<locals>.Provoker.__init__c             S   s   |   }d S )N)r  )r2   r   r7   r7   r8   r^    s    zIClassPropertiesAndMethods.test_weakref_segfault.<locals>.Provoker.__del__N)ry   rz   r{   r,   r^  r7   )r  r7   r8   Provoker  s   r  c               @   s   e Zd ZdS )z=ClassPropertiesAndMethods.test_weakref_segfault.<locals>.OopsN)ry   rz   r{   r7   r7   r7   r8   Oops  s   r  )r  r   Zwhatever)r2   r  r  r  r7   )r  r8   test_weakref_segfault  s    
z/ClassPropertiesAndMethods.test_weakref_segfaultc             C   s(   dd }xt dD ]
}|j}qW d }d S )Nc               S   s   d S )Nr7   r7   r7   r7   r8   r    r   zAClassPropertiesAndMethods.test_wrapper_segfault.<locals>.<lambda>i@B )r   r   )r2   r  rp   r7   r7   r8   test_wrapper_segfault  s    
z/ClassPropertiesAndMethods.test_wrapper_segfaultc             C   sP   t j}G dd d}| t _z&ytd W n tk
r>   Y nX W d |t _X d S )Nc               @   s   e Zd Zdd ZdS )z>ClassPropertiesAndMethods.test_file_fault.<locals>.StdoutGuardc             S   s   t jt _td| d S )Nz!Premature access to sys.stdout.%s)r   
__stdout__stdoutr'  )r2   rr  r7   r7   r8   r    s    zJClassPropertiesAndMethods.test_file_fault.<locals>.StdoutGuard.__getattr__N)ry   rz   r{   r  r7   r7   r7   r8   StdoutGuard  s   r  zOops!)r   r  r  r'  )r2   Ztest_stdoutr  r7   r7   r8   test_file_fault  s    
z)ClassPropertiesAndMethods.test_file_faultc                sp   G  fdddt }G dd dt G fdddt    }d|j| < | |jd t  | |d	 d S )
Nc                   s    e Zd Zdd Z fddZdS )zHClassPropertiesAndMethods.test_vicious_descriptor_nonsense.<locals>.Evilc             S   s   t dS )Nrr  )r  )r2   r7   r7   r8   r    s    zQClassPropertiesAndMethods.test_vicious_descriptor_nonsense.<locals>.Evil.__hash__c                s    ` dS )Nr   )rr  )r2   rx   )r|   r7   r8   ra    s    zOClassPropertiesAndMethods.test_vicious_descriptor_nonsense.<locals>.Evil.__eq__N)ry   rz   r{   r  ra  r7   )r|   r7   r8   Evil  s   r  c               @   s   e Zd ZdddZdS )zIClassPropertiesAndMethods.test_vicious_descriptor_nonsense.<locals>.DescrNc             S   s   dS )Nr]   r7   )r2   Zobr?   r7   r7   r8   r     s    zQClassPropertiesAndMethods.test_vicious_descriptor_nonsense.<locals>.Descr.__get__)N)ry   rz   r{   r   r7   r7   r7   r8   Descr  s   r  c                   s   e Zd Z  ZdS )zEClassPropertiesAndMethods.test_vicious_descriptor_nonsense.<locals>.CN)ry   rz   r{   rr  r7   )r  r7   r8   r|     s   r|   r   r]   rr  )r   rA   r=   rr  r   rf  r   )r2   r  rP   r7   )r|   r  r8    test_vicious_descriptor_nonsense  s    z:ClassPropertiesAndMethods.test_vicious_descriptor_nonsensec             C   s>   G dd dt }y
|  W n tk
r.   Y nX | d d S )Nc               @   s   e Zd Zdd ZdS )z0ClassPropertiesAndMethods.test_init.<locals>.Fooc             S   s   dS )Nr   r7   )r2   r7   r7   r8   r,     s    z9ClassPropertiesAndMethods.test_init.<locals>.Foo.__init__N)ry   rz   r{   r,   r7   r7   r7   r8   Foo
  s   r  z'did not test __init__() for None return)r   r   r   )r2   r  r7   r7   r8   	test_init  s    
z#ClassPropertiesAndMethods.test_initc             C   s  g }|  |j|j |  |jg j | |jdgj | |j|j |  |jjd t|jdr| |jj| | |jjt	 n | |jj
| | |jjt	 |  |jjt	jj yt|j W n tk
r   Y nX | d d}|d7 }|  |jdj |  t|jtdj d S )Nre   rK   r  z"no TypeError from hash([].__add__)r7   )r\  )r=   rK   rA  rc   ry   rs   r   r  __objclass__r.   Zim_selfZim_classrV  r  r   r   )r2   rq   rF   r7   r7   r8   test_method_wrapper  s*    
z-ClassPropertiesAndMethods.test_method_wrapperc                s  dd l  dd } fdd}tjd }tj}xdD ]\}}}d|d	d   }td
d||i}	|	 }
|||
|
 |||
| |||
| |r4|||
|
 |||
| |||
| d|d	d   }tdd||i}| }||||
 |||| |||| q4W d S )Nr   c             S   s   t S )N)rw   )r2   rx   r7   r7   r8   specialmethod:  s    zEClassPropertiesAndMethods.test_not_implemented.<locals>.specialmethodc                s@   yt | || d W n tk
r*   Y nX d| f  d S )N)r   r  operatorzno TypeError from %r)rU   r   r   )r6   r   r  )r  r2   r7   r8   r  =  s
    z=ClassPropertiesAndMethods.test_not_implemented.<locals>.checkr]   ))rK   zx + yzx += y)__sub__zx - yzx -= y)rc   zx * yzx *= y)
__matmul__zx @ yzx @= y)__truediv__zx / yzx /= y)r  zx // yzx //= y)__mod__zx % yzx %= y)
__divmod__zdivmod(x, y)N)r  zx ** yzx **= y)
__lshift__zx << yzx <<= y)
__rshift__zx >> yzx >>= y)__and__zx & yzx &= y)__or__zx | yzx |= y)__xor__zx ^ yzx ^= yZ__rr^   r   r7   Z__ir|   )r  r   r   r?   )r2   r  r  ZN1ZN2r5   r6   ZiexprZrnamer   r;   Zinamer|   rP   r7   )r  r2   r8   test_not_implemented5  s,    
z.ClassPropertiesAndMethods.test_not_implementedc             C   s4   G dd dt }| }d|dd< | |jd d S )Nc               @   s   e Zd Zdd ZdS )z6ClassPropertiesAndMethods.test_assign_slice.<locals>.Cc             S   s
   || _ d S )N)r   )r2   idxr   r7   r7   r8   rY   o  s    zBClassPropertiesAndMethods.test_assign_slice.<locals>.C.__setitem__N)ry   rz   r{   rY   r7   r7   r7   r8   r|   n  s   r|   r_   r]   r^   )r   r=   r   )r2   r|   rP   r7   r7   r8   test_assign_slicei  s    z+ClassPropertiesAndMethods.test_assign_slicec                s   G dd dt }|d G  fdddt }| }| |j  d|_| |jd G dd dt}G d	d d|d
}d|_|d|_| |jd d S )Nc               @   s   e Zd Zdd Zdd ZdS )z<ClassPropertiesAndMethods.test_set_and_no_get.<locals>.Descrc             S   s
   || _ d S )N)r5   )r2   r5   r7   r7   r8   r,   {  s    zEClassPropertiesAndMethods.test_set_and_no_get.<locals>.Descr.__init__c             S   s   ||j | j< d S )N)rA   r5   )r2   r   r   r7   r7   r8   r~  ~  s    zDClassPropertiesAndMethods.test_set_and_no_get.<locals>.Descr.__set__N)ry   rz   r{   r,   r~  r7   r7   r7   r8   r  y  s   r  r;   c                   s   e Zd Z ZdS )z8ClassPropertiesAndMethods.test_set_and_no_get.<locals>.XN)ry   rz   r{   r;   r7   )r  r7   r8   r     s   r   r   c               @   s   e Zd ZdS )z;ClassPropertiesAndMethods.test_set_and_no_get.<locals>.MetaN)ry   rz   r{   r7   r7   r7   r8   rs    s   rs  c               @   s   e Zd ZdS )z8ClassPropertiesAndMethods.test_set_and_no_get.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   )r   )r   r   r;   r=   r?   )r2   r  r   r   rs  r7   )r  r8   test_set_and_no_getv  s    
z-ClassPropertiesAndMethods.test_set_and_no_getc                s   G dd dt }| G fdddt }G fdddt }G fdddt }| tt| d	 | jd
 | tt| d	 | jd | tt| d	 | jd G  fdddt  | tt  d	 d S )Nc               @   s   e Zd ZdZdddZdS )z@ClassPropertiesAndMethods.test_getattr_hooks.<locals>.Descriptorr   Nc                s    fdd}|S )Nc                s     j d7  _ t| d S )Nr]   )r   rB  )r5   )r2   r7   r8   r    s    zXClassPropertiesAndMethods.test_getattr_hooks.<locals>.Descriptor.__get__.<locals>.getterr7   )r2   r   Zobjtyper  r7   )r2   r8   r     s    zHClassPropertiesAndMethods.test_getattr_hooks.<locals>.Descriptor.__get__)N)ry   rz   r{   r   r   r7   r7   r7   r8   
Descriptor  s   r%  c                   s   e Zd Z ZdS )z7ClassPropertiesAndMethods.test_getattr_hooks.<locals>.AN)ry   rz   r{   r  r7   )r  r7   r8   r     s   r   c                   s   e Zd Z ZdS )z7ClassPropertiesAndMethods.test_getattr_hooks.<locals>.BN)ry   rz   r{   r  r7   )r  r7   r8   r     s   r   c                   s   e Zd Z Z ZdS )z7ClassPropertiesAndMethods.test_getattr_hooks.<locals>.CN)ry   rz   r{   r  r  r7   )r  r7   r8   r|     s   r|   rr  r]   r^   ra   c                   s    e Zd Zdd Z fddZdS )zFClassPropertiesAndMethods.test_getattr_hooks.<locals>.EvilGetattributec             S   s   t |d S )N)rB  )r2   r5   r7   r7   r8   r    s    zRClassPropertiesAndMethods.test_getattr_hooks.<locals>.EvilGetattribute.__getattr__c                s*    ` xtdD ]}t  qW t|d S )Nre   )r  r   rh  ZcollectrB  )r2   r5   rp   )EvilGetattributer7   r8   r    s    zWClassPropertiesAndMethods.test_getattr_hooks.<locals>.EvilGetattribute.__getattribute__N)ry   rz   r{   r  r  r7   )r&  r7   r8   r&    s   r&  )r   r
  rB  r@   r=   r   )r2   r%  r   r   r|   r7   )r&  r  r8   test_getattr_hooks  s    
z,ClassPropertiesAndMethods.test_getattr_hooksc             C   s   |  ttjtt d S )N)r
  r   r?   r  r.   )r2   r7   r7   r8   test_type___getattribute__  s    z4ClassPropertiesAndMethods.test_type___getattribute__c          	   C   s^   |  tttd G dd dt}|  tt|d G dd dt}|  t
 |`W d Q R X d S )N__abstractmethods__c               @   s   e Zd ZdS )z<ClassPropertiesAndMethods.test_abstractmethods.<locals>.metaN)ry   rz   r{   r7   r7   r7   r8   meta  s   r*  c               @   s   e Zd ZdS )z9ClassPropertiesAndMethods.test_abstractmethods.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   r   )r
  rB  r@   r?   r   r)  )r2   r*  r   r7   r7   r8   test_abstractmethods  s    z.ClassPropertiesAndMethods.test_abstractmethodsc          	   C   sf   G dd d}| }|  |t | t t| W d Q R X | t t|d W d Q R X d S )Nc               @   s   e Zd ZeZdS )z:ClassPropertiesAndMethods.test_proxy_call.<locals>.FakeStrN)ry   rz   r{   r  r   r7   r7   r7   r8   FakeStr  s   r,  rY  )r   r  r
  r   r  rK   )r2   r,  Zfake_strr7   r7   r8   test_proxy_call  s    z)ClassPropertiesAndMethods.test_proxy_callc             C   s<   G dd d}|j |_| }| tt| | tt| d S )Nc               @   s   e Zd ZdS )z7ClassPropertiesAndMethods.test_repr_as_str.<locals>.FooN)ry   rz   r{   r7   r7   r7   r8   r    s   r  )r   rn   r
  r  r  rm   )r2   r  r   r7   r7   r8   test_repr_as_str  s
    z*ClassPropertiesAndMethods.test_repr_as_strc             C   s0   G dd dt }| }d|_| |d d d S )Nc               @   s   e Zd ZejZdS )z>ClassPropertiesAndMethods.test_mixing_slot_wrappers.<locals>.XN)ry   rz   r{   rl   rY   r  r7   r7   r7   r8   r     s   r   r   r  )rl   r  r=   )r2   r   r   r7   r7   r8   test_mixing_slot_wrappers  s    z3ClassPropertiesAndMethods.test_mixing_slot_wrappersc          	   C   s>   |  t}G dd d}W d Q R X t|j}| d| d S )Nc               @   s   e Zd ZdgZdZdS )zEClassPropertiesAndMethods.test_slot_shadows_class_variable.<locals>.Xr   N)ry   rz   r{   r   r   r7   r7   r7   r8   r     s   r   z0'foo' in __slots__ conflicts with class variable)r
  r5  r  r  r=   )r2   r  r   rG   r7   r7   r8    test_slot_shadows_class_variable  s    
z:ClassPropertiesAndMethods.test_slot_shadows_class_variablec          	   C   s   G dd d}d|_ | |j d | t}ttjd td W d Q R X | dt	|j
 | t}t|jd | W d Q R X | dt	|j
 | |j d d S )Nc               @   s   e Zd ZdZdS )z1ClassPropertiesAndMethods.test_set_doc.<locals>.XZelephantN)ry   rz   r{   rV  r7   r7   r7   r8   r     s   r   ZbananarV  Zblahzcan't set list.__doc__zcan't delete X.__doc__)rV  r=   r
  r   r?   r.   rA   r~  r  r  r  r  )r2   r   r  r7   r7   r8   test_set_doc  s     z&ClassPropertiesAndMethods.test_set_docc          	   C   s,  t jtjtjtjg}ddddg}x,t||D ]\}}| t	|j
|d  q,W x,|D ]$}|jjd |j
 }| |j| qTW | t jjd | tjjd | tjjd	 | tjjd
 G dd d}| t
 |`W d Q R X | tt	jd jt d G dd da| tjd | tjjd d S )Nr  memberZgetsetwrapperZ_descriptor.z	str.lowerzcomplex.realz
float.realzint.__add__c               @   s   e Zd ZdS )z2ClassPropertiesAndMethods.test_qualname.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   r   r{   ZOinkc               @   s   e Zd ZG dd dZdS )r  c               @   s   e Zd ZdS )zY.InsideN)ry   rz   r{   r7   r7   r7   r8   Inside  s   r5  N)ry   rz   r{   r5  r7   r7   r7   r8   r    s   r  zY.Inside)r  rz  r   r   r&   r%   rK   r6  r=   r?   ry   r  r{   r
  r   rA   r~  r  r5  )r2   Zdescriptorsr  rE   nqualnamer   r7   r7   r8   test_qualname  s&    
z'ClassPropertiesAndMethods.test_qualnamec             C   s^   ddi}t dd|}| |jd | d|j | |ddi ddi}| tt dd| d S )Nr{   z	some.namer  r7   r]   )r?   r=   r{   r  rA   r
  r   )r2   r   r  r7   r7   r8   test_qualname_dict  s    z,ClassPropertiesAndMethods.test_qualname_dictc             C   sb   G dd dt }| }d|_t|}~t  | |  x t D ]}| 	t
|| qFW d S )Nc               @   s   e Zd Zdd ZdS )z<ClassPropertiesAndMethods.test_cycle_through_dict.<locals>.Xc             S   s   t |  | | _d S )N)rl   r,   rA   )r2   r7   r7   r8   r,   +  s    
zEClassPropertiesAndMethods.test_cycle_through_dict.<locals>.X.__init__N)ry   rz   r{   r,   r7   r7   r7   r8   r   *  s   r   r   )rl   rr  r  r  r   rf  assertIsNonerh  r`  assertIsNotr?   )r2   r   r   Zwrr  r7   r7   r8   test_cycle_through_dict(  s    
z1ClassPropertiesAndMethods.test_cycle_through_dictc             C   s   G dd d}|  t|d | j t|dd G dd d}G dd d}G d	d
 d
||}xL|||fD ]>}|d |ddd |  t|ddd | j t|dddd qfW d S )Nc               @   s   e Zd ZdS )z[ClassPropertiesAndMethods.test_object_new_and_init_with_parameters.<locals>.OverrideNeitherN)ry   rz   r{   r7   r7   r7   r8   OverrideNeither9  s   r=  r]   )r   c               @   s   e Zd ZdddZdS )zWClassPropertiesAndMethods.test_object_new_and_init_with_parameters.<locals>.OverrideNewr   c             _   s   t j| f||S )N)r   r   )r   r   r   r3   r   r7   r7   r8   r   >  s    z_ClassPropertiesAndMethods.test_object_new_and_init_with_parameters.<locals>.OverrideNew.__new__N)r   )ry   rz   r{   r   r7   r7   r7   r8   OverrideNew=  s   r>  c               @   s   e Zd ZdddZdS )zXClassPropertiesAndMethods.test_object_new_and_init_with_parameters.<locals>.OverrideInitr   c             _   s   t j| f||S )N)r   r,   )r2   r   r   r3   r4   r7   r7   r8   r,   A  s    zaClassPropertiesAndMethods.test_object_new_and_init_with_parameters.<locals>.OverrideInit.__init__N)r   )ry   rz   r{   r,   r7   r7   r7   r8   OverrideInit@  s   r?  c               @   s   e Zd ZdS )zXClassPropertiesAndMethods.test_object_new_and_init_with_parameters.<locals>.OverrideBothN)ry   rz   r{   r7   r7   r7   r8   OverrideBothC  s   r@  r^   r_   )r   )r
  r   )r2   r=  r>  r?  r@  Zcaser7   r7   r8   (test_object_new_and_init_with_parameters7  s    zBClassPropertiesAndMethods.test_object_new_and_init_with_parametersc             C   s>   G dd d}G dd d|}|  d|j | d|j d S )Nc               @   s   e Zd ZdS )z\ClassPropertiesAndMethods.test_subclassing_does_not_duplicate_dict_descriptors.<locals>.BaseN)ry   rz   r{   r7   r7   r7   r8   rU  L  s   rU  c               @   s   e Zd ZdS )z[ClassPropertiesAndMethods.test_subclassing_does_not_duplicate_dict_descriptors.<locals>.SubN)ry   rz   r{   r7   r7   r7   r8   rW  N  s   rW  rA   )r  rA   r  )r2   rU  rW  r7   r7   r8   4test_subclassing_does_not_duplicate_dict_descriptorsK  s    zNClassPropertiesAndMethods.test_subclassing_does_not_duplicate_dict_descriptorsc                sR  G dd d}|  t| jd G dd d}G dd d|}G dd	 d	|}| }| }| }t||}|  t|jd
 |  t|jd |  t|jd |  t|jd G dd d}| }	|  t|	jd |  t|jd G dd d}
|
 }t }t||}|  t|d d|_|  t|d d|_|  t|d d S )Nc               @   s   e Zd Zdd ZdS )z=ClassPropertiesAndMethods.test_bound_method_repr.<locals>.Fooc             S   s   d S )Nr7   )r2   r7   r7   r8   r  U  s    zDClassPropertiesAndMethods.test_bound_method_repr.<locals>.Foo.methodN)ry   rz   r{   r  r7   r7   r7   r8   r  T  s   r  z4<bound method .*Foo\.method of <.*Foo object at .*>>c               @   s   e Zd Zdd ZdS )z>ClassPropertiesAndMethods.test_bound_method_repr.<locals>.Basec             S   s   d S )Nr7   )r2   r7   r7   r8   r  \  s    zEClassPropertiesAndMethods.test_bound_method_repr.<locals>.Base.methodN)ry   rz   r{   r  r7   r7   r7   r8   rU  [  s   rU  c               @   s   e Zd ZdS )zBClassPropertiesAndMethods.test_bound_method_repr.<locals>.Derived1N)ry   rz   r{   r7   r7   r7   r8   Derived1^  s   rC  c               @   s   e Zd Zdd ZdS )zBClassPropertiesAndMethods.test_bound_method_repr.<locals>.Derived2c             S   s   d S )Nr7   )r2   r7   r7   r8   r  a  s    zIClassPropertiesAndMethods.test_bound_method_repr.<locals>.Derived2.methodN)ry   rz   r{   r  r7   r7   r7   r8   Derived2`  s   rD  z6<bound method .*Base\.method of <.*Base object at .*>>z:<bound method .*Base\.method of <.*Derived1 object at .*>>z><bound method .*Derived2\.method of <.*Derived2 object at .*>>z:<bound method .*Base\.method of <.*Derived2 object at .*>>c               @   s   e Zd Zedd ZdS )z=ClassPropertiesAndMethods.test_bound_method_repr.<locals>.Fooc             S   s   d S )Nr7   )r   r7   r7   r8   r  q  s    zDClassPropertiesAndMethods.test_bound_method_repr.<locals>.Foo.methodN)ry   rz   r{   r   r  r7   r7   r7   r8   r  p  s   z/<bound method .*Foo\.method of <class '.*Foo'>>c               @   s   e Zd Zdd ZdS )zDClassPropertiesAndMethods.test_bound_method_repr.<locals>.MyCallablec             S   s   d S )Nr7   )r2   r  r7   r7   r8   r   |  s    zMClassPropertiesAndMethods.test_bound_method_repr.<locals>.MyCallable.__call__N)ry   rz   r{   r   r7   r7   r7   r8   
MyCallable{  s   rE  z*<bound method \? of <object object at .*>>r5   z,<bound method name of <object object at .*>>r7  z0<bound method qualname of <object object at .*>>)	ZassertRegexrm   r  r   r   r  
MethodTypery   r{   )r2   r  rU  rC  rD  r~  Zderived1Zderived2Zsuper_d2r   rE  r   instancer  )r   r7   r8   test_bound_method_reprS  sH    



z0ClassPropertiesAndMethods.test_bound_method_repr){ry   rz   r{   r   r   r   r   r  r  r  r"  r#  r,  r3  r?  rC  rP  rm  rp  ry  r  r  r  r  r   Zrefcount_testr  r   r  r  r  r  r  r  r  r*   ZexpectedFailurer  r  r  r  r  r  r  r
  r  r  skipIfr   flagsoptimizer   cpython_onlyr$  r)  r7  rM  rY  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(  r+  r-  r.  r/  r0  r1  r8  r9  r<  rA  rB  rH  r   r7   r7   )r   r8   r     s   4  X")%%= K&(F<2	.	""G1ib?CS^t  N @OYYM	.
',	A( 63,'!4'
 
r   c               @   s   e Zd Zdd Zeeedo$e ddd Z	eeedoFe ddd Z
eeedohe dd	d
 Zdd Zdd ZdS )DictProxyTestsc             C   s   G dd dt }|| _d S )Nc               @   s   e Zd Zdd ZdS )zDictProxyTests.setUp.<locals>.Cc             S   s   d S )Nr7   )r2   r7   r7   r8   rD     s    z$DictProxyTests.setUp.<locals>.C.methN)ry   rz   r{   rD   r7   r7   r7   r8   r|     s   r|   )r   r|   )r2   r|   r7   r7   r8   setUp  s    zDictProxyTests.setUpgettracez#trace function introduces __local__c             C   sB   | j j }| |t t|}|  | |dddddg d S )NrA   rV  rz   rn  rD   )r|   rA   rh   assertNotIsInstancer.   sortr=   )r2   r   rh   r7   r7   r8   test_iter_keys  s    zDictProxyTests.test_iter_keysc             C   s4   | j j }| |t t|}| t|d d S )Nre   )r|   rA   r  rP  r.   r=   r   )r2   r   r  r7   r7   r8   test_iter_values  s    zDictProxyTests.test_iter_valuesc             C   sH   | j j }| |t dd |D }|  | |dddddg d S )Nc             S   s   g | ]}|d  qS )r   r7   )r3  itemr7   r7   r8   r4    s    z2DictProxyTests.test_iter_items.<locals>.<listcomp>rA   rV  rz   rn  rD   )r|   rA   r/   rP  r.   rQ  r=   )r2   r   rh   r7   r7   r8   test_iter_items  s    zDictProxyTests.test_iter_itemsc             C   sN   G dd dt }G dd dt}G dd d|d}| t|jt|j d S )Nc               @   s   e Zd ZdS )z7DictProxyTests.test_dict_type_with_metaclass.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z7DictProxyTests.test_dict_type_with_metaclass.<locals>.MN)ry   rz   r{   r7   r7   r7   r8   rE    s   rE  c               @   s   e Zd ZdS )z7DictProxyTests.test_dict_type_with_metaclass.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r|   )r   )r   r?   r=   rA   )r2   r   rE  r|   r7   r7   r8   test_dict_type_with_metaclass  s    z,DictProxyTests.test_dict_type_with_metaclassc             C   sb   t | jj}| |d| | |d| x,| jj D ]\}}| d||| q>W d S )Nzmappingproxy()z
{!r}: {!r})	rm   r|   rA   r   r   endswithr/   r  r  )r2   r  r   r   r7   r7   r8   	test_repr  s
    zDictProxyTests.test_reprN)ry   rz   r{   rN  r*   rI  rs   r   rO  rR  rS  rU  rV  rY  r7   r7   r7   r8   rM    s   

rM  c               @   s   e Zd Zdd ZdS )PTypesLongInitTestc             C   s>   G dd dt }ytd| d W n   Y nX tt d S )Nc               @   s   e Zd Zdd ZdS )z;PTypesLongInitTest.test_pytype_long_ready.<locals>.UserLongc             W   s   d S )Nr7   )r2   r3   r7   r7   r8   r    s    zCPTypesLongInitTest.test_pytype_long_ready.<locals>.UserLong.__pow__N)ry   rz   r{   r  r7   r7   r7   r8   UserLong  s   r[  r   )r   r   r?   r  rN  )r2   r[  r7   r7   r8   test_pytype_long_ready  s    z)PTypesLongInitTest.test_pytype_long_readyN)ry   rz   r{   r\  r7   r7   r7   r8   rZ    s   rZ  c               @   s   e Zd Zdd ZdS )	MiscTestsc                sj   G  fdddt }G dd dt }G dd dt  td|f| di| jd	 | jd
 d S )Nc                   s"   e Zd Zdd Z fddZdS )z7MiscTests.test_type_lookup_mro_reference.<locals>.MyKeyc             S   s   t dS )Nmykey)r  )r2   r7   r7   r8   r    s    z@MiscTests.test_type_lookup_mro_reference.<locals>.MyKey.__hash__c                s    f_ d S )N)rB   )r2   rx   )Base2r   r7   r8   ra    s    z>MiscTests.test_type_lookup_mro_reference.<locals>.MyKey.__eq__N)ry   rz   r{   r  ra  r7   )r_  r   r7   r8   MyKey  s   r`  c               @   s   e Zd ZdZdZdS )z6MiscTests.test_type_lookup_mro_reference.<locals>.Basez	from BaseN)ry   rz   r{   r^  mykey2r7   r7   r7   r8   rU    s   rU  c               @   s   e Zd ZdZdZdS )z7MiscTests.test_type_lookup_mro_reference.<locals>.Base2z
from Base2N)ry   rz   r{   r^  ra  r7   r7   r7   r8   r_    s   r_  r   re   z	from Basez
from Base2)r   r?   r=   r^  ra  )r2   r`  rU  r7   )r_  r   r8   test_type_lookup_mro_reference  s    z(MiscTests.test_type_lookup_mro_referenceN)ry   rz   r{   rb  r7   r7   r7   r8   r]    s   r]  c               @   sf   e Zd Zdi dddfddZdd Zdd Zdd	d
Zedd Zdd Z	dd Z
dd Zdd ZdS )PicklingTestsr7   Nc       
      C   sB  |dkr| |}|rD| |d tj | |d t|||f n,| |d tj | |d t|f|  | |d | |d k	r| t|d | n| |d  |d k	r| 	t
|d | n| |d  ndt|j}	tjt||	|	tkrd n|	|ff}|d k	r||f7 }| | || | | | d S )Nr^   r   r]   r_   ra   )__reduce_ex__r=   copyreg__newobj_ex__r?   
__newobj__assertListEqualr.   r:  assertDictEqualrl   __base___reconstructorr   
__reduce__)
r2   protor   r3   r4   r   	listitems	dictitemsZreduce_valueZ	base_typer7   r7   r8   _check_reduce  s.    



zPicklingTests._check_reducec                s(  t tjd }d dddddiG  fdd	d	}| }x|D ]}| ||  qBW x  D ]\}}t||| qbW x|D ]}| j|| d
 qW G dd d}| }x4|D ],}|dkr| t || W d Q R X qW G  fddd}| }x(|D ] }|dkr| ||  qW G  fddd}	G fddd}
G dd d}G dd d}xZ|D ]R}xJ|	|
||fD ]:}| }|dkr| tt	f || W d Q R X qW qnW G  fddd}| }x|D ]}| ||  qW G dd d}| }x8|D ]0}|dkr| t
 || W d Q R X qW G fddd}| }x|D ]}| j||d
 qfW G dd d}| }x|D ]}| j||d d
 qW G d!d" d"}| }xV|D ]N}| t
 || W d Q R X |dk r| t
 |  W d Q R X qW G fd#d$d$}| }xl|D ]d}|dkrb| j||d fd
 n>| t || W d Q R X | t |  W d Q R X q>W G d%d& d&t}|d'd(i}x"|D ]}| j||t|d) qW G d*d+ d+t}|d,g}x"|D ]}| j||t|d- qW d S ).Nr]   )ir   i7i)ZbaconZfishcheeseioc                   s   e Zd Z fddZdS )z%PicklingTests.test_reduce.<locals>.C1c                s    S )Nr7   )r2   )r3   r7   r8   __getnewargs__  s    z4PicklingTests.test_reduce.<locals>.C1.__getnewargs__N)ry   rz   r{   rr  r7   )r3   r7   r8   rR    s   rR  )r   c               @   s   e Zd Zdd ZdS )z%PicklingTests.test_reduce.<locals>.C2c             S   s   dS )Nzbad argsr7   )r2   r7   r7   r8   rr  +  s    z4PicklingTests.test_reduce.<locals>.C2.__getnewargs__N)ry   rz   r{   rr  r7   r7   r7   r8   r   *  s   r   r^   c                   s   e Zd Z fddZdS )z%PicklingTests.test_reduce.<locals>.C3c                s    fS )Nr7   )r2   )r3   r4   r7   r8   __getnewargs_ex__4  s    z7PicklingTests.test_reduce.<locals>.C3.__getnewargs_ex__N)ry   rz   r{   rs  r7   )r3   r4   r7   r8   rS  3  s   rS  c                   s   e Zd Z fddZdS )z%PicklingTests.test_reduce.<locals>.C4c                s    dfS )Nzbad dictr7   )r2   )r3   r7   r8   rs  <  s    z7PicklingTests.test_reduce.<locals>.C4.__getnewargs_ex__N)ry   rz   r{   rs  r7   )r3   r7   r8   rW  ;  s   rW  c                   s   e Zd Z fddZdS )z%PicklingTests.test_reduce.<locals>.C5c                s   d fS )Nz	bad tupler7   )r2   )r4   r7   r8   rs  ?  s    z7PicklingTests.test_reduce.<locals>.C5.__getnewargs_ex__N)ry   rz   r{   rs  r7   )r4   r7   r8   C5>  s   rt  c               @   s   e Zd Zdd ZdS )z%PicklingTests.test_reduce.<locals>.C6c             S   s   dS )Nr7   r7   )r2   r7   r7   r8   rs  B  s    z7PicklingTests.test_reduce.<locals>.C6.__getnewargs_ex__N)ry   rz   r{   rs  r7   r7   r7   r8   C6A  s   ru  c               @   s   e Zd Zdd ZdS )z%PicklingTests.test_reduce.<locals>.C7c             S   s   dS )Nzbad argsr7   )r2   r7   r7   r8   rs  E  s    z7PicklingTests.test_reduce.<locals>.C7.__getnewargs_ex__N)ry   rz   r{   rs  r7   r7   r7   r8   C7D  s   rv  c                   s   e Zd Z fddZdS )z%PicklingTests.test_reduce.<locals>.C9c                s    i fS )Nr7   )r2   )r3   r7   r8   rs  O  s    z7PicklingTests.test_reduce.<locals>.C9.__getnewargs_ex__N)ry   rz   r{   rs  r7   )r3   r7   r8   C9N  s   rw  c               @   s   e Zd Zdd ZdS )z&PicklingTests.test_reduce.<locals>.C10c             S   s   t d S )N)r  )r2   r7   r7   r8   rs  V  s    z8PicklingTests.test_reduce.<locals>.C10.__getnewargs_ex__N)ry   rz   r{   rs  r7   r7   r7   r8   C10U  s   rx  c                   s   e Zd Z fddZdS )z&PicklingTests.test_reduce.<locals>.C11c                s    S )Nr7   )r2   )r   r7   r8   r  _  s    z3PicklingTests.test_reduce.<locals>.C11.__getstate__N)ry   rz   r{   r  r7   )r   r7   r8   C11^  s   ry  c               @   s   e Zd Zdd ZdS )z&PicklingTests.test_reduce.<locals>.C12c             S   s   dS )Nznot dictr7   )r2   r7   r7   r8   r  f  s    z3PicklingTests.test_reduce.<locals>.C12.__getstate__N)ry   rz   r{   r  r7   r7   r7   r8   C12e  s   rz  znot dictc               @   s   e Zd Zdd ZdS )z&PicklingTests.test_reduce.<locals>.C13c             S   s   t d S )N)r  )r2   r7   r7   r8   r  m  s    z3PicklingTests.test_reduce.<locals>.C13.__getstate__N)ry   rz   r{   r  r7   r7   r7   r8   C13l  s   r{  c                   s    e Zd Ze Z fddZdS )z&PicklingTests.test_reduce.<locals>.C14c                s&   x    D ]\}}t| || q
W d S )N)r/   r   )r2   r5   r   )r   r7   r8   r,   y  s    z/PicklingTests.test_reduce.<locals>.C14.__init__N)ry   rz   r{   rN  r   r,   r7   )r   r7   r8   C14w  s   r|  c               @   s   e Zd ZdS )z&PicklingTests.test_reduce.<locals>.C15N)ry   rz   r{   r7   r7   r7   r8   C15  s   r}  Zquebeci)ro  c               @   s   e Zd ZdS )z&PicklingTests.test_reduce.<locals>.C16N)ry   rz   r{   r7   r7   r7   r8   C16  s   r~  Zyukon)rn  )r   pickleHIGHEST_PROTOCOLrp  r/   r   r
  r   rd  r5  r  rl  rl   r.   )r2   	protocolsrR  r   rm  r5   r   r   rS  rW  rt  ru  rv  r   rw  rx  ry  rz  r{  r|  r}  r~  r7   )r3   r4   r   r8   test_reduce  s    







 











zPicklingTests.test_reducec             C   sP   t tjd }G dd d}x.|D ]&}|dkr2i nd }| j|| |d q"W d S )Nr]   c               @   s   e Zd Zdd Zdd ZdS )z7PicklingTests.test_special_method_lookup.<locals>.Pickyc             S   s   i S )Nr7   )r2   r7   r7   r8   r    s    zDPicklingTests.test_special_method_lookup.<locals>.Picky.__getstate__c             S   s   |dkrt |d S )N)rr  rs  )r  )r2   rr  r7   r7   r8   r    s    zCPicklingTests.test_special_method_lookup.<locals>.Picky.__getattr__N)ry   rz   r{   r  r  r7   r7   r7   r8   Picky  s   r  r^   )r   )r   r  r  rp  )r2   r  r  Zprotocolr   r7   r7   r8   r    s
    
z(PicklingTests.test_special_method_lookupc             C   s  |dkrd ||}t|jtjkr,td| j|||d | jt|t||d t|dr| j|j	|j	|d | j|j	|j	|d t|dr| j
|j|j|d xJ|jD ]@}| jt||t|||d | jt||dt||d|d qW | jt|t||d dS )zKUtility method to verify if two objects are copies of each others.
        Nz{!r} is not a copy of {!r}zCobject passed to _assert_is_copy must override the __repr__ method.)r8  rA   r   )r  r?   rn   r   r5  r;  r   rs   ri  rA   rh  r   r=   r@   rm   )r2   r   objcopyr8  slotr7   r7   r8   _assert_is_copy  s"    

zPicklingTests._assert_is_copyc                  sD   G dd d  fddt ttjd tjtjhtjtjhD S )zLUtility method to generate the many possible pickle configurations.
        c               @   s(   e Zd ZdZdd Zdd Zdd ZdS )	z<PicklingTests._generate_pickle_copiers.<locals>.PickleCopierz&This class copies object using pickle.c             S   s   || _ || _|| _d S )N)rm  dumpsloads)r2   rm  r  r  r7   r7   r8   r,     s    zEPicklingTests._generate_pickle_copiers.<locals>.PickleCopier.__init__c             S   s   |  | || jS )N)r  r  rm  )r2   r   r7   r7   r8   r     s    zAPicklingTests._generate_pickle_copiers.<locals>.PickleCopier.copyc             S   s$   d | j| jj| jj| jj| jjS )Nz0PickleCopier(proto={}, dumps={}.{}, loads={}.{}))r  rm  r  rz   r{   r  )r2   r7   r7   r8   rn     s    zEPicklingTests._generate_pickle_copiers.<locals>.PickleCopier.__repr__N)ry   rz   r{   rV  r,   r   rn   r7   r7   r7   r8   PickleCopier  s   r  c             3   s   | ]} | V  qd S )Nr7   )r3  r3   )r  r7   r8   	<genexpr>  s    z9PicklingTests._generate_pickle_copiers.<locals>.<genexpr>r]   )		itertoolsproductr   r  r  r  Z_dumpsr  Z_loadsr7   r7   )r  r8   _generate_pickle_copiers  s
    

z&PicklingTests._generate_pickle_copiersc          
   C   sJ  G dd da | t tt  d W d Q R X G dd dt a| t tt d W d Q R X G dd da G dd dt aG dd	 d	t ax|  D ]}| j|d
 t  }|	|}| 
|| d|_|	|}| 
|| t }d|_d|_|	|}| 
|| t }d|_d|_|	|}| 
|| W d Q R X qW d S )Nc               @   s   e Zd ZdgZdS )r|   r;   N)ry   rz   r{   r   r7   r7   r7   r8   r|     s   r|   r   c               @   s   e Zd ZdS )r   N)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s.   e Zd ZdZdgZdd Zdd Zdd Zd	S )
r|   z7A class with __getstate__ and __setstate__ implemented.r;   c          
   S   sh   t | di  }xRt| jD ]D}x>|jddD ],}yt | |||< W q0 tk
rZ   Y q0X q0W qW |S )NrA   r   r7   )r@   r   r?   r  rA   r   rB  )r2   r   r   r  r7   r7   r8   r    s    zC.__getstate__c             S   s&   x |  D ]\}}t| || q
W d S )N)r/   r   )r2   r   r   r   r7   r7   r8   r    s    zC.__setstate__c             S   s   dt | j|  f S )Nz%s()<%r>)r?   ry   r  )r2   r7   r7   r8   rn     s    z
C.__repr__N)ry   rz   r{   rV  r   r  r  rn   r7   r7   r7   r8   r|     s
   	c               @   s   e Zd ZdZdS )r   z!A subclass of a class with slots.N)ry   rz   r{   rV  r7   r7   r7   r8   r     s   c               @   s   e Zd ZdZdgZdS )r   zA subclass with an extra slot.rL   N)ry   rz   r{   rV  r   r7   r7   r7   r8   r     s   r   )pickle_copierr   rv   r   )r|   r
  r   r  r  r   r   r  subTestr   r  r;   rL   )r2   r  r   r  r7   r7   r8   test_pickle_slots  s6    



zPicklingTests.test_pickle_slotsc       
   
   C   sx  G dd da G dd dtaG dd dtaG dd dtaG d	d
 d
tat ttttf}|  }xt	||D ]\}}| j
||dh t|di }||j|}|j}||}| || |dkr|js|j  ||}	| ||	 W d Q R X qrW xx|D ]p}| j
|dX t|di }||j|}t|}| || |jsd|j  t|}	| ||	 W d Q R X q W d S )Nc                   s0   e Zd ZdZdZdZ fddZdd Z  ZS )rR  z:The state of this class is copyable via its instance dict.)r]   r^   Tc                s   t    || _|| _d S )N)r   r,   r;   rL   )r2   r;   rL   )r   r7   r8   r,     s    
zC1.__init__c             S   s   d| j | jf S )Nz
C1(%r, %r))r;   rL   )r2   r7   r7   r8   rn   "  s    zC1.__repr__)	ry   rz   r{   rV  ARGSNEED_DICT_COPYINGr,   rn   r   r7   r7   )r   r8   rR    s
   rR  c                   sH   e Zd ZdZdZdZ fddZ fddZedd	 Z	d
d Z
  ZS )r   z,A list subclass copyable via __getnewargs__.)r]   r^   Fc                s   t  | }||_||_|S )N)r   r   r;   rL   )r   r;   rL   r2   )r   r7   r8   r   *  s    z
C2.__new__c                s   t    | d d S )Nrq  )r   r,   ri   )r2   r3   )r   r7   r8   r,   /  s    
zC2.__init__c             S   s   | j S )N)r  )r   r7   r7   r8   rr  4  s    zC2.__getnewargs__c             S   s   d| j | jt| f S )NzC2(%r, %r)<%r>)r;   rL   r.   )r2   r7   r7   r8   rn   7  s    zC2.__repr__)ry   rz   r{   rV  r  r  r   r,   r   rr  rn   r   r7   r7   )r   r8   r   &  s   r   c               @   s<   e Zd ZdZdZdZdd Zedd Zdd	 Z	d
d Z
dS )rS  z*A list subclass copyable via __getstate__.)r]   r^   Fc             S   s   || _ || _| d d S )Nrq  )r;   rL   ri   )r2   r;   rL   r7   r7   r8   r,   ?  s    zC3.__init__c             S   s   | j S )N)r  )r   r7   r7   r8   r  E  s    zC3.__getstate__c             S   s   |\}}|| _ || _d S )N)r;   rL   )r2   r   r;   rL   r7   r7   r8   r  H  s    zC3.__setstate__c             S   s   d| j | jt| f S )NzC3(%r, %r)<%r>)r;   rL   r.   )r2   r7   r7   r8   rn   L  s    zC3.__repr__N)ry   rz   r{   rV  r  r  r,   r   r  r  rn   r7   r7   r7   r8   rS  ;  s   rS  c                   s<   e Zd ZdZdZdZ fddZedd Zdd	 Z	  Z
S )
rW  z,An int subclass copyable via __getnewargs__.)r  r  r]   Fc                s   t  | |}||_||_|S )N)r   r   r;   rL   )r   r;   rL   r   r2   )r   r7   r8   r   T  s    z
C4.__new__c             S   s   | j S )N)r  )r   r7   r7   r8   rr  Y  s    zC4.__getnewargs__c             S   s   d| j | jt| f S )NzC4(%r, %r)<%r>)r;   rL   r%   )r2   r7   r7   r8   rn   \  s    zC4.__repr__)ry   rz   r{   rV  r  r  r   r   rr  rn   r   r7   r7   )r   r8   rW  P  s   rW  c                   sJ   e Zd ZdZdZddiZdZdd fdd	
Zed
d Z	dd Z
  ZS )rt  z/An int subclass copyable via __getnewargs_ex__.)r]   r^   r   r_   Fr   )r   c               s   t  | |}||_||_|S )N)r   r   r;   rL   )r   r;   rL   r   r2   )r   r7   r8   r   e  s    z
C5.__new__c             S   s   | j | jfS )N)r  KWARGS)r   r7   r7   r8   rs  j  s    zC5.__getnewargs_ex__c             S   s   d| j | jt| f S )NzC5(%r, %r)<%r>)r;   rL   r%   )r2   r7   r7   r8   rn   m  s    zC5.__repr__)ry   rz   r{   rV  r  r  r  r   r   rs  rn   r   r7   r7   )r   r8   rt  `  s   rt  )r   r  r  r^   )r   )rR  r.   r   rS  r%   rW  rt  r  r  r  r  r@   r  rm  r   r  r  rA   r	  r   )
r2   Ztest_classesZpickle_copiersr   r  r4   r   rm  r  Zobjcopy2r7   r7   r8   test_reduce_copying  s8    




z!PicklingTests.test_reduce_copyingc                s^   G dd dt G  fddd dd l}|j fd ddifd d f}|   d| d S )	Nc               @   s   e Zd ZdS )z(PicklingTests.test_issue24097.<locals>.SN)ry   rz   r{   r7   r7   r7   r8   r    s   r  c                   s$   e Zd ZdgZ fddZdS )z(PicklingTests.test_issue24097.<locals>.Ar   c                s(   |dkr dg j d d < dS td S )Nr   r   )__slotnames__rB  )r2   rr  )r   r  r7   r8   r    s    z4PicklingTests.test_issue24097.<locals>.A.__getattr__N)ry   rz   r{   r  r  r7   )r   r  r7   r8   r     s   
r   r   r   r   r^   )r  re  rg  r=   rd  )r2   re  r6  r7   )r   r  r8   test_issue24097  s
    	zPicklingTests.test_issue24097c          	   C   s~   t    | t t  d W d Q R X t  d | t t    W d Q R X | t t  d  W d Q R X d S )Nr   )r   rl  r
  r   rd  )r2   r7   r7   r8   test_object_reduce  s    
z PicklingTests.test_object_reduce)N)ry   rz   r{   rp  r  r  r  r   r  r  r  r  r  r7   r7   r7   r8   rc    s   {
C|rc  c               @   s   e Zd Zejdd ZdS )SharedKeyTestsc             C   s*  G dd d}G dd d|}| |  }}|  tt|tt| | tt|ti  td\|_|_|_|_	|_
|_| tt|tt| | }|  tt|tt| | tt|ti  td\|_|_
|_	|_|_|_| tt|ti  d S )Nc               @   s   e Zd ZdS )z)SharedKeyTests.test_subclasses.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z)SharedKeyTests.test_subclasses.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   r   rf   )r=   r   r  varsZ
assertLessr   r   r  rg  wr   r  rA  rF   rj  r  )r2   r   r   r;   rL   r   r7   r7   r8   test_subclasses  s         zSharedKeyTests.test_subclassesN)ry   rz   r{   r   rL  r  r7   r7   r7   r8   r    s   r  c               @   s    e Zd ZdZdd Zdd ZdS )DebugHelperMetaz<
    Sets default __doc__ and simplifies repr() output.
    c             C   s&   | dd kr||d< t| |||S )NrV  )r   r?   r   )r   r5   r   r  r7   r7   r8   r     s    zDebugHelperMeta.__new__c             C   s
   t | jS )N)rm   ry   )r   r7   r7   r8   rn     s    zDebugHelperMeta.__repr__N)ry   rz   r{   rV  r   rn   r7   r7   r7   r8   r    s   r  c               @   s`   e Zd 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 )MroTestz
    Regressions for some bugs revealed through
    mcsl.mro() customization (typeobject.c: mro_internal()) and
    cls.__bases__ assignment (typeobject.c: type_set_bases()).
    c             C   s   d| _ d| _d S )Nr   F)stepready)r2   r7   r7   r8   rN    s    zMroTest.setUpc             C   s    | j |k }|r|  j d7  _ |S )Nr]   )r  )r2   limitretr7   r7   r8   
step_until  s    
zMroTest.step_untilc                s*   G  fdddt }G dd d|d}dS )zM
        type_set_bases must be aware that type->tp_mro can be NULL.
        c                   s   e Zd Z fddZdS )z4MroTest.test_incomplete_set_bases_on_self.<locals>.Mc                s0     dr&| jd kst|  jd7  _t| S )Nr]   r7   )r  r  r  rB   r?   r  )r   )r2   r7   r8   r    s    
z8MroTest.test_incomplete_set_bases_on_self.<locals>.M.mroN)ry   rz   r{   r  r7   )r2   r7   r8   rE    s   rE  c               @   s   e Zd ZdS )z4MroTest.test_incomplete_set_bases_on_self.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   )r   N)r  )r2   rE  r   r7   )r2   r8   !test_incomplete_set_bases_on_self  s    z)MroTest.test_incomplete_set_bases_on_selfc                sJ   G  fdddt }G dd d|d G dd d }| jd7  _d	S )
z?
        Deep reentrancy must not over-decref old_mro.
        c                   s   e Zd Z fddZdS )z/MroTest.test_reent_set_bases_on_base.<locals>.Mc                s6   | j d k	r,| jdkr,dr,  jd7  _t| S )Nr   r   r7   )r  ry   r  rB   r?   r  )r   )r   r2   r7   r8   r    s    
z3MroTest.test_reent_set_bases_on_base.<locals>.M.mroN)ry   rz   r{   r  r7   )r   r2   r7   r8   rE    s   rE  c               @   s   e Zd ZdS )z/MroTest.test_reent_set_bases_on_base.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   )r   c               @   s   e Zd ZdS )z/MroTest.test_reent_set_bases_on_base.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   r   r7   N)r  rB   )r2   rE  r   r7   )r   r2   r8   test_reent_set_bases_on_base  s    	z$MroTest.test_reent_set_bases_on_basec                sJ   G  fdddt }G dd d|d}G dd d|}G dd	 d	|}d
S )zU
        Similar to test_reent_set_bases_on_base, but may crash differently.
        c                   s   e Zd Z fddZdS )z6MroTest.test_reent_set_bases_on_direct_base.<locals>.Mc                s4   | j d }|tk	r* dr*| j d7  _ t| S )Nr   re   r7   )rB   r   r  r?   r  )r   r~  )r2   r7   r8   r    s
    

z:MroTest.test_reent_set_bases_on_direct_base.<locals>.M.mroN)ry   rz   r{   r  r7   )r2   r7   r8   rE    s   rE  c               @   s   e Zd ZdS )z6MroTest.test_reent_set_bases_on_direct_base.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   )r   c               @   s   e Zd ZdS )z6MroTest.test_reent_set_bases_on_direct_base.<locals>.BN)ry   rz   r{   r7   r7   r7   r8   r     s   r   c               @   s   e Zd ZdS )z6MroTest.test_reent_set_bases_on_direct_base.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|     s   r|   N)r  )r2   rE  r   r   r|   r7   )r2   r8   #test_reent_set_bases_on_direct_base	  s    	z+MroTest.test_reent_set_bases_on_direct_basec          	      sx   G  fdddt }G dd d|d}G dd d| G dd	 d	|d
_t   jd7  _W dQ R X dS )aM  
        type_set_bases must check for an inheritance cycle not only through
        MRO of the type, which may be not yet updated in case of reentrance,
        but also through tp_base chain, which is assigned before diving into
        inner calls to mro().

        Otherwise, the following snippet can loop forever:
            do {
                // ...
                type = type->tp_base;
            } while (type != NULL);

        Functions that rely on tp_base (like solid_base and PyType_IsSubtype)
        would not be happy in that case, causing a stack overflow.
        c                   s   e Zd Z fddZdS )z5MroTest.test_reent_set_bases_tp_base_cycle.<locals>.Mc                s4   j r*| jdkr f_| jdkr*f _t| S )NB1B2)r  ry   rB   r?   r  )r   )r  r  r2   r7   r8   r  .  s    

z9MroTest.test_reent_set_bases_tp_base_cycle.<locals>.M.mroN)ry   rz   r{   r  r7   )r  r  r2   r7   r8   rE  -  s   rE  c               @   s   e Zd ZdS )z5MroTest.test_reent_set_bases_tp_base_cycle.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r   6  s   r   )r   c               @   s   e Zd ZdS )z6MroTest.test_reent_set_bases_tp_base_cycle.<locals>.B1N)ry   rz   r{   r7   r7   r7   r8   r  8  s   r  c               @   s   e Zd ZdS )z6MroTest.test_reent_set_bases_tp_base_cycle.<locals>.B2N)ry   rz   r{   r7   r7   r7   r8   r  :  s   r  Tr7   N)r  r  r
  r   rB   )r2   rE  r   r7   )r  r  r2   r8   "test_reent_set_bases_tp_base_cycle  s    	z*MroTest.test_reent_set_bases_tp_base_cyclec                s   G  fdddt }G dd d|d}G dd d|}G dd	 d	| G d
d d|d_|f_f|_j f   g | g  |jf  |g dS )a  
        type_set_bases must check for reentrancy upon finishing its job
        by updating tp_subclasses of old/new bases of the type.
        Otherwise, an implicit inheritance cycle through tp_subclasses
        can break functions that recurse on elements of that field
        (like recurse_down_subclasses and mro_hierarchy) eventually
        leading to a stack overflow.
        c                   s   e Zd Z fddZdS )z;MroTest.test_tp_subclasses_cycle_in_update_slots.<locals>.Mc                s(   j r| jdkrd_  f_t| S )Nr|   F)r  ry   rB   r?   r  )r   )r  r|   r2   r7   r8   r  K  s    z?MroTest.test_tp_subclasses_cycle_in_update_slots.<locals>.M.mroN)ry   rz   r{   r  r7   )r  r|   r2   r7   r8   rE  J  s   rE  c               @   s   e Zd ZdS )z;MroTest.test_tp_subclasses_cycle_in_update_slots.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r   Q  s   r   )r   c               @   s   e Zd ZdS )z<MroTest.test_tp_subclasses_cycle_in_update_slots.<locals>.B1N)ry   rz   r{   r7   r7   r7   r8   r  S  s   r  c               @   s   e Zd ZdS )z<MroTest.test_tp_subclasses_cycle_in_update_slots.<locals>.B2N)ry   rz   r{   r7   r7   r7   r8   r  U  s   r  c               @   s   e Zd ZdS )z;MroTest.test_tp_subclasses_cycle_in_update_slots.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   W  s   r|   TN)r  r  rB   r=   r  )r2   rE  r   r  r7   )r  r|   r2   r8   (test_tp_subclasses_cycle_in_update_slotsA  s    	z0MroTest.test_tp_subclasses_cycle_in_update_slotsc          	      s   G dd dt G  fdddt}G dd d|d}G dd	 d	|}G d
d d| G dd d|d_ |f_W dQ R X f|_j f jtt	 dS )z
        The same as test_tp_subclasses_cycle_in_update_slots, but tests
        a code path executed on error (goto bail).
        c               @   s   e Zd ZdS )z=MroTest.test_tp_subclasses_cycle_error_return_path.<locals>.EN)ry   rz   r{   r7   r7   r7   r8   r   j  s   r   c                   s   e Zd Z fddZdS )z=MroTest.test_tp_subclasses_cycle_error_return_path.<locals>.Mc                s:   j r0| jdkr0j fkr$d_ n f_t| S )Nr|   F)r  ry   rB   r?   r  )r   )r  r|   r   r2   r7   r8   r  m  s    zAMroTest.test_tp_subclasses_cycle_error_return_path.<locals>.M.mroN)ry   rz   r{   r  r7   )r  r|   r   r2   r7   r8   rE  l  s   rE  c               @   s   e Zd ZdS )z=MroTest.test_tp_subclasses_cycle_error_return_path.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r   v  s   r   )r   c               @   s   e Zd ZdS )z>MroTest.test_tp_subclasses_cycle_error_return_path.<locals>.B1N)ry   rz   r{   r7   r7   r7   r8   r  x  s   r  c               @   s   e Zd ZdS )z>MroTest.test_tp_subclasses_cycle_error_return_path.<locals>.B2N)ry   rz   r{   r7   r7   r7   r8   r  z  s   r  c               @   s   e Zd ZdS )z=MroTest.test_tp_subclasses_cycle_error_return_path.<locals>.CN)ry   rz   r{   r7   r7   r7   r8   r|   |  s   r|   TN)
r  r  r  r
  rB   r=   r  rN  r?   r  )r2   rE  r   r  r7   )r  r|   r   r2   r8   *test_tp_subclasses_cycle_error_return_pathe  s    
z2MroTest.test_tp_subclasses_cycle_error_return_pathc                s*   G  fdddt }G dd d|d}dS )z
        Extending an unitialized type with type->tp_mro == NULL must
        throw a reasonable TypeError exception, instead of failing
        with PyErr_BadInternalCall.
        c                   s   e Zd Z fddZdS )z)MroTest.test_incomplete_extend.<locals>.Mc          	      sD   | j d kr:| jdkr: t G dd d| }W d Q R X t| S )Nr   c               @   s   e Zd ZdS )z8MroTest.test_incomplete_extend.<locals>.M.mro.<locals>.XN)ry   rz   r{   r7   r7   r7   r8   r     s   )r  ry   r
  r   r?   r  )r   r   )r2   r7   r8   r    s    z-MroTest.test_incomplete_extend.<locals>.M.mroN)ry   rz   r{   r  r7   )r2   r7   r8   rE    s   rE  c               @   s   e Zd ZdS )z)MroTest.test_incomplete_extend.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   )r   N)r  )r2   rE  r   r7   )r2   r8   test_incomplete_extend  s    	zMroTest.test_incomplete_extendc                s*   G  fdddt }G dd d|d}dS )z
        Attrubute lookup on a super object must be aware that
        its target type can be uninitialized (type->tp_mro == NULL).
        c                   s   e Zd Z fddZ  ZS )z(MroTest.test_incomplete_super.<locals>.Mc          	      s6   | j d kr,t t| | j W d Q R X t| S )N)r  r
  rB  r   Zxxxr?   r  )r   )r   r2   r7   r8   r    s    
z,MroTest.test_incomplete_super.<locals>.M.mro)ry   rz   r{   r  r   r7   )r2   )r   r8   rE    s   rE  c               @   s   e Zd ZdS )z(MroTest.test_incomplete_super.<locals>.AN)ry   rz   r{   r7   r7   r7   r8   r     s   r   )r   N)r  )r2   rE  r   r7   )r2   r8   test_incomplete_super  s    zMroTest.test_incomplete_superN)ry   rz   r{   rV  rN  r  r  r  r  r  r  r  r  r  r7   r7   r7   r8   r    s   $$"r  c            
   C   s   t tttttttt	 d S )N)
r   Zrun_unittestrZ  r   r   rM  r]  rc  r  r  r7   r7   r7   r8   	test_main  s    r  __main__)r  re  rh  r  r  r  r   r  r*   r  r  r   r   r  r   r+   r   r   rM  rZ  r]  rc  r  r?   r  r  r  ry   r7   r7   r7   r8   <module>   s     x                                  &<   = U
