File: //usr/local/lib/python3.7/test/__pycache__/test_baseexception.cpython-37.pyc
B
��gu � @ s\ d dl Z d dlZd dlZd dlmZ G dd� de j�ZG dd� de j�Ze dkrXe �
� dS )� N)�systemc @ sL e Zd ZdZdd� Zdd� Zdd� ZdZd d
� Zdd� Z d
d� Z
dd� ZdS )�ExceptionClassTestsz]Tests for anything relating to exception objects themselves (e.g.,
inheritance hierarchy)c C s | � ttt�� d S )N)�
assertTrue�
issubclass� Exception�object)�self� r �3/usr/local/lib/python3.7/test/test_baseexception.py�test_builtins_new_style s z+ExceptionClassTests.test_builtins_new_stylec C s0 x*dD ]"}| � t||�d|jj|f � qW d S )N)�args�__str__�__repr__z%s missing %s attribute)r �hasattr� __class__�__name__)r Zins�attrr r r
�verify_instance_interface s
z-ExceptionClassTests.verify_instance_interfacec C s� t � }xBtj�� D ]4}yt|t�r.|�|j� W q tk
rD Y qX qW t t
j�t
j�
t�d d��}�z�|�� �� }ytt|�}W n" tk
r� | �d| � Y nX | �||d| � |�|� g }d}�x�|D �]�}|�� }|�d�} || d d � }
d|
k�rJ|
�d�}|
|d d � }|
d |d � }
t� |k�rJ|�|
� q�d
|
k�rn|
�d
�}
|
d |
d � }
ytt|
�}W n$ tk
�r� | �d|
� Y nX || k �r�|�||f� n,|| k�r�x |d d | k�r�|�� �q�W | �t||d d �d|j|d d jf � y| �|� � W n tk
�r< Y nX | �|
|� |�|
� |}| }q�W W d |�� X | �t|�dd
| � d S )Nr zexception_hierarchy.txtzbase class %s not a built-inz%s not found�-� �(� ����[z%s not a built-in exceptionz%s is not a subclass of %sz%s not accounted for) �set�builtins�__dict__�valuesr �
BaseException�addr � TypeError�open�os�path�join�split�__file__�readline�rstrip�getattr�AttributeError�failZassertIn�discard�rindex�index�platform_system�append�popr r �close�assertEqual�len)r Zexc_set�object_Zinheritance_treeZsuperclass_name�last_excZsuperclassesZ
last_depthZexc_line�depthZexc_nameZparen_indexZ
platform_nameZleft_bracket�excr r r
�test_inheritance sp
z$ExceptionClassTests.test_inheritance)�lengthr �str�reprc C s: x4t | j|�D ]$\}\}}| �||d|||f � qW d S )Nz%s: %s != %s)�zip�interface_testsr3 )r �resultsZ test_nameZgivenZexpectedr r r
�interface_test_driverT s z)ExceptionClassTests.interface_test_driverc C sZ d}t |�}t|j�dg|jd |gt|�t|�gt|�d|jj|f gf}| �|� d S )N�spamr r z%s(%r))r r4 r r; r<