3
d	                 @   s^   d Z ddlZddlmZmZmZmZmZ ddlm	Z	m
Z
 G dd deZG dd dejZdS )	z 
Tests for the Bool trait type.
    N)BoolDict	HasTraitsInt
TraitError)numpyrequires_numpyc               @   s   e Zd ZeZdS )AN)__name__
__module____qualname__r   foo r   r   8/tmp/pip-build-7vycvbft/traits/traits/tests/test_bool.pyr	      s   r	   c               @   sT   e Zd Zdd Zdd Zdd Zedd Zed	d
 Zedd Z	edd Z
dS )TestBoolc             C   s(   t  }| jt|jt | j|j d S )N)r	   assertEqualtyper   boolassertFalse)selfar   r   r   test_default_value   s    zTestBool.test_default_valuec             C   s.   t  }d|_| j|j d|_| j|j d S )NTF)r	   r   
assertTruer   )r   r   r   r   r   test_accepts_bool   s
    zTestBool.test_accepts_boolc          
   C   s\   t  }dddg}x(|D ] }| jt ||_W d Q R X qW | jt|jt | j|j d S )N   za stringg      ?)r	   ZassertRaisesr   r   r   r   r   r   )r   r   Z
bad_valuesZ	bad_valuer   r   r   !test_does_not_accept_int_or_float&   s    

z*TestBool.test_does_not_accept_int_or_floatc             C   s"   t  }tjd|_| j|j d S )NT)r	   r   bool_r   r   )r   r   r   r   r   test_accepts_numpy_bool2   s    z TestBool.test_accepts_numpy_boolc             C   s>   t  }tjd|_| j|jt tjd|_| j|jt d S )NTF)r	   r   r   r   ZassertIsInstancer   )r   r   r   r   r   !test_numpy_bool_retrieved_as_bool9   s
    z*TestBool.test_numpy_bool_retrieved_as_boolc             C   s:   G dd dt }| }tjd|jd< | j|jd  d S )Nc               @   s   e Zd ZeeeZdS )zDTestBool.test_numpy_bool_accepted_as_dict_value.<locals>.HasBoolDictN)r
   r   r   r   r   r   r   r   r   r   r   HasBoolDictE   s   r    Tr   )r   r   r   r   r   )r   r    has_bool_dictr   r   r   &test_numpy_bool_accepted_as_dict_valueB   s    z/TestBool.test_numpy_bool_accepted_as_dict_valuec             C   s@   G dd dt }| }tjd}d|j|< | j|j| d d S )Nc               @   s   e Zd ZeeeZdS )zBTestBool.test_numpy_bool_accepted_as_dict_key.<locals>.HasBoolDictN)r
   r   r   r   r   r   r   r   r   r   r   r    O   s   r    Tr   )r   r   r   r   r   )r   r    r!   keyr   r   r   $test_numpy_bool_accepted_as_dict_keyL   s
    

z-TestBool.test_numpy_bool_accepted_as_dict_keyN)r
   r   r   r   r   r   r   r   r   r"   r$   r   r   r   r   r      s   	
r   )__doc__ZunittestZ
traits.apir   r   r   r   r   Z$traits.testing.optional_dependenciesr   r   r	   ZTestCaser   r   r   r   r   <module>   s
   