B
    u9a%                 @   s   d dl Z d dl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Zed
dZeefdZ	G dd dZ
G dd de
ZG dd de jZdd Zedkre   dS )    Nc               @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestIsInstanceExceptionsc             C   s:   G dd dt }G dd dt }| dt| |  d S )Nc               @   s   e Zd Zdd ZeeZdS )z;TestIsInstanceExceptions.test_class_has_no_bases.<locals>.Ic             S   s   d S )N )selfr   r   %/usr/lib/python3.7/test_isinstance.pygetclass   s    zDTestIsInstanceExceptions.test_class_has_no_bases.<locals>.I.getclassN)__name__
__module____qualname__r   property	__class__r   r   r   r   I   s   r   c               @   s   e Zd Zdd ZeeZdS )z;TestIsInstanceExceptions.test_class_has_no_bases.<locals>.Cc             S   s   dS )Nr   r   )r   r   r   r   getbases!   s    zDTestIsInstanceExceptions.test_class_has_no_bases.<locals>.C.getbasesN)r   r   r	   r   r
   	__bases__r   r   r   r   C    s   r   F)objectassertEqual
isinstance)r   r   r   r   r   r   test_class_has_no_bases   s    z0TestIsInstanceExceptions.test_class_has_no_basesc                sL   G dd dt  G  fdddt }G dd dt }| tt| |  d S )Nc               @   s   e Zd Zdd ZeeZdS )zPTestIsInstanceExceptions.test_bases_raises_other_than_attribute_error.<locals>.Ec             S   s   t d S )N)RuntimeError)r   r   r   r   r   +   s    zYTestIsInstanceExceptions.test_bases_raises_other_than_attribute_error.<locals>.E.getbasesN)r   r   r	   r   r
   r   r   r   r   r   E*   s   r   c                   s    e Zd Z fddZeeZdS )zPTestIsInstanceExceptions.test_bases_raises_other_than_attribute_error.<locals>.Ic                s     S )Nr   )r   )r   r   r   r   0   s    zYTestIsInstanceExceptions.test_bases_raises_other_than_attribute_error.<locals>.I.getclassN)r   r   r	   r   r
   r   r   )r   r   r   r   /   s   r   c               @   s   e Zd Zdd ZeeZdS )zPTestIsInstanceExceptions.test_bases_raises_other_than_attribute_error.<locals>.Cc             S   s   dS )Nr   r   )r   r   r   r   r   5   s    zYTestIsInstanceExceptions.test_bases_raises_other_than_attribute_error.<locals>.C.getbasesN)r   r   r	   r   r
   r   r   r   r   r   r   4   s   r   )r   assertRaisesr   r   )r   r   r   r   )r   r   ,test_bases_raises_other_than_attribute_error)   s    zETestIsInstanceExceptions.test_bases_raises_other_than_attribute_errorc             C   s6   G dd d}G dd dt }| tt| |  d S )Nc               @   s   e Zd ZdS )zFTestIsInstanceExceptions.test_dont_mask_non_attribute_error.<locals>.IN)r   r   r	   r   r   r   r   r   >   s    r   c               @   s   e Zd Zdd ZeeZdS )zFTestIsInstanceExceptions.test_dont_mask_non_attribute_error.<locals>.Cc             S   s   t d S )N)r   )r   r   r   r   r   A   s    zOTestIsInstanceExceptions.test_dont_mask_non_attribute_error.<locals>.C.getbasesN)r   r   r	   r   r
   r   r   r   r   r   r   @   s   r   )r   r   r   r   )r   r   r   r   r   r   "test_dont_mask_non_attribute_error=   s    z;TestIsInstanceExceptions.test_dont_mask_non_attribute_errorc             C   s6   G dd d}G dd dt }| tt| |  d S )Nc               @   s   e Zd ZdS )z=TestIsInstanceExceptions.test_mask_attribute_error.<locals>.IN)r   r   r	   r   r   r   r   r   J   s    r   c               @   s   e Zd Zdd ZeeZdS )z=TestIsInstanceExceptions.test_mask_attribute_error.<locals>.Cc             S   s   t d S )N)AttributeError)r   r   r   r   r   M   s    zFTestIsInstanceExceptions.test_mask_attribute_error.<locals>.C.getbasesN)r   r   r	   r   r
   r   r   r   r   r   r   L   s   r   )r   r   	TypeErrorr   )r   r   r   r   r   r   test_mask_attribute_errorI   s    z2TestIsInstanceExceptions.test_mask_attribute_errorc             C   sH   G dd dt }| }| tt|t G dd d}| tt|| d S )Nc               @   s   e Zd Zdd ZeeZdS )zQTestIsInstanceExceptions.test_isinstance_dont_mask_non_attribute_error.<locals>.Cc             S   s   t d S )N)r   )r   r   r   r   r   W   s    zZTestIsInstanceExceptions.test_isinstance_dont_mask_non_attribute_error.<locals>.C.getclassN)r   r   r	   r   r
   r   r   r   r   r   r   V   s   r   c               @   s   e Zd ZdS )zQTestIsInstanceExceptions.test_isinstance_dont_mask_non_attribute_error.<locals>.DN)r   r   r	   r   r   r   r   D_   s    r   )r   r   r   r   bool)r   r   cr   r   r   r   -test_isinstance_dont_mask_non_attribute_errorU   s
    zFTestIsInstanceExceptions.test_isinstance_dont_mask_non_attribute_errorN)r   r   r	   r   r   r   r   r   r   r   r   r   r   
   s
   r   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestIsSubclassExceptionsc             C   s8   G dd dt }G dd d|}| tt| |  d S )Nc               @   s   e Zd Zdd ZeeZdS )zFTestIsSubclassExceptions.test_dont_mask_non_attribute_error.<locals>.Cc             S   s   t d S )N)r   )r   r   r   r   r   i   s    zOTestIsSubclassExceptions.test_dont_mask_non_attribute_error.<locals>.C.getbasesN)r   r   r	   r   r
   r   r   r   r   r   r   h   s   r   c               @   s   e Zd ZdS )zFTestIsSubclassExceptions.test_dont_mask_non_attribute_error.<locals>.SN)r   r   r	   r   r   r   r   Sm   s    r!   )r   r   r   
issubclass)r   r   r!   r   r   r   r   g   s    z;TestIsSubclassExceptions.test_dont_mask_non_attribute_errorc             C   s8   G dd dt }G dd d|}| tt| |  d S )Nc               @   s   e Zd Zdd ZeeZdS )z=TestIsSubclassExceptions.test_mask_attribute_error.<locals>.Cc             S   s   t d S )N)r   )r   r   r   r   r   s   s    zFTestIsSubclassExceptions.test_mask_attribute_error.<locals>.C.getbasesN)r   r   r	   r   r
   r   r   r   r   r   r   r   s   r   c               @   s   e Zd ZdS )z=TestIsSubclassExceptions.test_mask_attribute_error.<locals>.SN)r   r   r	   r   r   r   r   r!   w   s    r!   )r   r   r   r"   )r   r   r!   r   r   r   r   q   s    z2TestIsSubclassExceptions.test_mask_attribute_errorc             C   s4   G dd d}G dd dt }| tt||  d S )Nc               @   s   e Zd ZdS )zQTestIsSubclassExceptions.test_dont_mask_non_attribute_error_in_cls_arg.<locals>.BN)r   r   r	   r   r   r   r   B   s    r#   c               @   s   e Zd Zdd ZeeZdS )zQTestIsSubclassExceptions.test_dont_mask_non_attribute_error_in_cls_arg.<locals>.Cc             S   s   t d S )N)r   )r   r   r   r   r      s    zZTestIsSubclassExceptions.test_dont_mask_non_attribute_error_in_cls_arg.<locals>.C.getbasesN)r   r   r	   r   r
   r   r   r   r   r   r      s   r   )r   r   r   r"   )r   r#   r   r   r   r   -test_dont_mask_non_attribute_error_in_cls_arg   s    zFTestIsSubclassExceptions.test_dont_mask_non_attribute_error_in_cls_argc             C   s4   G dd d}G dd dt }| tt||  d S )Nc               @   s   e Zd ZdS )zHTestIsSubclassExceptions.test_mask_attribute_error_in_cls_arg.<locals>.BN)r   r   r	   r   r   r   r   r#      s    r#   c               @   s   e Zd Zdd ZeeZdS )zHTestIsSubclassExceptions.test_mask_attribute_error_in_cls_arg.<locals>.Cc             S   s   t d S )N)r   )r   r   r   r   r      s    zQTestIsSubclassExceptions.test_mask_attribute_error_in_cls_arg.<locals>.C.getbasesN)r   r   r	   r   r
   r   r   r   r   r   r      s   r   )r   r   r   r"   )r   r#   r   r   r   r   $test_mask_attribute_error_in_cls_arg   s    z=TestIsSubclassExceptions.test_mask_attribute_error_in_cls_argN)r   r   r	   r   r   r$   r%   r   r   r   r   r    f   s   

r    c               @   s,   e Zd Zdd Zdd ZeeZdd ZdS )AbstractClassc             C   s
   || _ d S )N)bases)r   r'   r   r   r   __init__   s    zAbstractClass.__init__c             C   s   | j S )N)r'   )r   r   r   r   r      s    zAbstractClass.getbasesc             C   s   t | S )N)AbstractInstance)r   r   r   r   __call__   s    zAbstractClass.__call__N)r   r   r	   r(   r   r
   r   r*   r   r   r   r   r&      s   r&   c               @   s$   e Zd Zdd Zdd ZeeZdS )r)   c             C   s
   || _ d S )N)klass)r   r+   r   r   r   r(      s    zAbstractInstance.__init__c             C   s   | j S )N)r+   )r   r   r   r   r      s    zAbstractInstance.getclassN)r   r   r	   r(   r   r
   r   r   r   r   r   r)      s   r)   r   )r'   c               @   s   e Zd ZdS )SuperN)r   r   r	   r   r   r   r   r,      s   r,   c               @   s   e Zd ZdS )ChildN)r   r   r	   r   r   r   r   r-      s   r-   c               @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )TestIsInstanceIsSubclassc             C   s|   |  dtt t |  dtt t |  dtt t |  dtt t |  dtt t |  dtt t d S )NTF)r   r   r,   r-   AbstractSuperAbstractChild)r   r   r   r   test_isinstance_normal   s    z/TestIsInstanceIsSubclass.test_isinstance_normalc             C   s   |  dtt t |  dtt t |  dtt t |  dtt t |  dtt t |  dtt t |  dtt t |  dtt t d S )NTF)r   r   r/   r0   r,   r-   )r   r   r   r   test_isinstance_abstract   s    z1TestIsInstanceIsSubclass.test_isinstance_abstractc             C   sp   |  dttt |  dttt |  dttt |  dttt |  dttt |  dttt d S )NTF)r   r"   r,   r/   r-   )r   r   r   r   test_subclass_normal   s    z-TestIsInstanceIsSubclass.test_subclass_normalc             C   s   |  dttt |  dttt |  dttt |  dttt |  dttt |  dttt |  dttt d S )NTF)r   r"   r/   r0   r-   r,   )r   r   r   r   test_subclass_abstract   s    z/TestIsInstanceIsSubclass.test_subclass_abstractc             C   s   |  dtttf |  dtttf |  dtttf |  dttttf |  dttd |  dttttff |  dtttttff |  dtttttff d S )NTFr   )r   r"   r-   r,   intfloatstr)r   r   r   r   test_subclass_tuple   s    z,TestIsInstanceIsSubclass.test_subclass_tuplec             C   s   |  ttttt d S )N)r   RecursionError	blowstackr"   r7   )r   r   r   r   test_subclass_recursion_limit   s    z6TestIsInstanceIsSubclass.test_subclass_recursion_limitc             C   s   |  tttdt d S )N )r   r9   r:   r   r7   )r   r   r   r   test_isinstance_recursion_limit   s    z8TestIsInstanceIsSubclass.test_isinstance_recursion_limitN)
r   r   r	   r1   r2   r3   r4   r8   r;   r=   r   r   r   r   r.      s   

r.   c             C   s4   |f}x(t t d D ]}|f}| || qW d S )N   )rangesysgetrecursionlimit)fxnargZ
compare_toZ	tuple_argZcntr   r   r   r:      s    r:   __main__)Zunittestr@   ZTestCaser   r    r   r&   r)   r/   r0   r,   r-   r.   r:   r   mainr   r   r   r   <module>   s   \0	
I	