U
    #c                     @   sr   d Z ddlZddlZddlZejjjZejjjZG dd dZ	G dd dZ
ejddd	d
gG dd dZdS )zQ
Tests of the ._exceptions module. Primarily for exercising the __str__ methods.
    Nc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestArrayMemoryErrorc                 C   s6   t dttj}tt|}|j|jks2tdS )z, Test that _ArrayMemoryError can be pickled   N)	_ArrayMemoryErrornpdtypeuint8pickleloadsdumps_total_sizeAssertionError)selferrorres r   E/tmp/pip-unpacked-wheel-b2rbor69/numpy/core/tests/test__exceptions.pytest_pickling   s    z"TestArrayMemoryError.test_picklingc                 C   s   t dttj}t| d S )Nr   )r   r   r   r   strr   er   r   r   test_str   s    zTestArrayMemoryError.test_strc                 C   sB  t j}d}|ddkst|ddks*t|ddks:t||dksJt||d dks^t|d	| d
ksrt|td| dkst|td| dkst|td| dkst||| dkst|t|| | d dkst||| | | | | dkst||| | | | | d dks>tdS )z Test e._size_to_string    r   z0 bytes   z1 bytesr   z
1023 bytesz1.00 KiB
   z10.0 KiBg33333;@z999. KiBg33333@z	1023. KiBg     @z1.00 MiBgH.?z1.00 GiBz1.00 EiBi@ z123456. EiBN)r   Z_size_to_stringr   int)r   fZKir   r   r   test__size_to_string   s     &z)TestArrayMemoryError.test__size_to_stringc                 C   sH   t dttj}|jdks tt dttjdf}|jdksDtdS )z Test e._total_size )r   r   )         r   N)r   r   r   r   r   r   Zuint64r   r   r   r   test__total_size/   s    z%TestArrayMemoryError.test__total_sizeN)__name__
__module____qualname__r   r   r   r!   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd ZdS )TestUFuncNoLoopErrorc                 C   s   t tttstdS )z, Test that _UFuncNoLoopError can be pickled N)
isinstancer	   r   _UFuncNoLoopErrorbytesr   )r   r   r   r   r   9   s    z"TestUFuncNoLoopError.test_picklingN)r"   r#   r$   r   r   r   r   r   r%   8   s   r%   args)r   r   N)r   r   Ztest_prefix)ztest messagec                   @   s   e Zd Zdd Zdd ZdS )TestAxisErrorc                 C   s^   t j| }t|dkr4|jdks$t|jdksZtn&|^}}}|j|ksLt|j|ksZtdS )zValidate attribute types.r   N)r   	AxisErrorlenaxisr   ndim)r   r)   excr-   r.   _r   r   r   	test_attrD   s    

zTestAxisError.test_attrc                 C   s`   t j| }tt|}t|t|ks.tdD ](}t||}t||}||ks2t|q2dS )z%Test that `AxisError` can be pickled.)r-   r.   r)   N)r   r+   r	   r
   r   typer   getattr)r   r)   r/   Zexc2nameZattr1Zattr2r   r   r   r   O   s    


zTestAxisError.test_picklingN)r"   r#   r$   r1   r   r   r   r   r   r*   >   s   r*   )__doc__r	   ZpytestZnumpyr   core_exceptionsr   r'   r   r%   markZparametrizer*   r   r   r   r   <module>   s   

+