B
    0d                 @   sP   d dl Z d dlZd dlmZ d dlmZ eddddgdd	gZG d
d dZdS )    N)assert_equal)_make_tuple_bunchResultxyzwbetac               @   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ejd%d&d'gd(gfd)d*gd+gfd)d'gd,gfgd-d. Zejd%d)d'd(d'gd+gfd)d'd(gd(d+gfgd/d0 Zejd%d)d1gd+gfd)d'gd2gfgd3d4 Zejd%d)d5gd+gfd)d'gd6gfd7d'gd+gfgd8d9 Zd:d; Zd<S )=TestMakeTupleBunchc             C   s   t dddddd| _d S )N         c   g      ?)r   r   r   r   r	   )r   result)self r   M/var/www/html/venv/lib/python3.7/site-packages/scipy/_lib/tests/test_bunch.pysetup   s    zTestMakeTupleBunch.setupc             C   sJ   t | jjd t | jjd t | jjd t | jjd t | jjd d S )Nr   r   r   r   g      ?)r   r   r   r   r   r   r	   )r   r   r   r   test_attribute_access   s
    z(TestMakeTupleBunch.test_attribute_accessc          	   C   sh   t | jd d t | jd d t | jd d t | jd d tjtdd | jd  W d Q R X d S )Nr   r   r   r   zindex out of range)match)r   r   pytestraises
IndexError)r   r   r   r   test_indexing   s    z TestMakeTupleBunch.test_indexingc             C   s,   | j \}}}t|||fd t| j d d S )N)r   r   r   )r   r   )r   Zx0Zy0Zz0r   r   r   test_unpacking&   s    z!TestMakeTupleBunch.test_unpackingc             C   sD   t | jdd  d t | jd d d d t | jd d d d d S )Nr   )r   r   r   )r   r   r   )r   r   r   )r   r   )r   r   r   r   
test_slice+   s    zTestMakeTupleBunch.test_slicec             C   s   t t| jd d S )Nr   )r   lenr   )r   r   r   r   test_len0   s    zTestMakeTupleBunch.test_lenc             C   s   t | j}t|d d S )Nz%Result(x=1, y=2, z=3, w=99, beta=0.5))reprr   r   )r   sr   r   r   	test_repr3   s    
zTestMakeTupleBunch.test_reprc             C   s   t t| jtd d S )N)r   r   r   )r   hashr   )r   r   r   r   	test_hash7   s    zTestMakeTupleBunch.test_hashc             C   sx   t | j}t |}t|ts$tt|j| jj t|j	| jj	 t|j
| jj
 t|j| jj t|j| jj d S )N)pickledumpsr   loads
isinstancer   AssertionErrorr   r   r   r   r   r	   )r   r    objr   r   r   test_pickle:   s    
zTestMakeTupleBunch.test_picklec          	   C   s&   t jtdd d| j_W d Q R X d S )Nzcan't set attribute)r   r   )r   r   AttributeErrorr   r   )r   r   r   r   test_read_only_existingD   s    z*TestMakeTupleBunch.test_read_only_existingc          	   C   s&   t jtdd d| j_W d Q R X d S )Nzcan't set attribute)r   zlattice of coincidence)r   r   r+   r   Zplate_of_shrimp)r   r   r   r   test_read_only_newH   s    z%TestMakeTupleBunch.test_read_only_newc          	   C   s.   t jtdd tddddd W d Q R X d S )Nmissing)r   r   r   r   g      ?)r   r   r   r	   )r   r   	TypeErrorr   )r   r   r   r   "test_constructor_missing_parameterL   s    z5TestMakeTupleBunch.test_constructor_missing_parameterc          	   C   s2   t jtdd tddddddd	 W d Q R X d S )
NZ
unexpected)r   r   r   r   {   g      ?i  )r   r   r   r   r	   foo)r   r   r/   r   )r   r   r   r   $test_constructor_incorrect_parameterQ   s    z7TestMakeTupleBunch.test_constructor_incorrect_parameterc             C   s"   d}t tj| t | jj| d S )Nzscipy._lib.tests.test_bunch)r   r   
__module__r   )r   mr   r   r   test_moduleV   s    zTestMakeTupleBunch.test_modulec             C   s|   t dddddd}t ddd	d
dd}t|jd t|jd t|d d  d t|jd
 t|jd t|d d  d d S )Nr   r   r   r   g        )r   r   r   r   r	            r   g      ?)r   r   r   )r7   r8   r9   )r   r   r   r	   )r   Zresult1Zresult2r   r   r   test_extra_fields_per_instance[   s    z1TestMakeTupleBunch.test_extra_fields_per_instancec             C   sH   t dddg}|ddd}t|jd t|jd t|}t|d d S )NSquarewidthheightr   r   )r<   r=   zSquare(width=1, height=2))r   r   r<   r=   r   )r   r;   sqr    r   r   r   "test_extra_field_names_is_optionaln   s    z5TestMakeTupleBunch.test_extra_field_names_is_optionalc             C   s>   t dddg}|ddd}t|ts(tt|d ts:td S )NTupabr   r   )rA   rB   )r   )r   r'   tupler(   )r   r@   Ztur   r   r   test_tuple_likev   s    z"TestMakeTupleBunch.test_tuple_likec             C   sD   d}t ddgddg|d}|ddd	d
}t|j| t|j| d S )Nzsome.module.nameFoor   rA   rB   )moduler   ic  q   )r   rA   rB   )r   r   r4   )r   r5   rE   r2   r   r   r   test_explicit_module|   s
    z'TestMakeTupleBunch.test_explicit_moduleargsZ123rA   rB   rE   z-3r   z+-*/c          	   C   s&   t jtdd t|  W d Q R X d S )NZidentifiers)r   )r   r   
ValueErrorr   )r   rI   r   r   r   test_identifiers_not_allowed   s    z/TestMakeTupleBunch.test_identifiers_not_allowedc          	   C   s&   t jtdd t|  W d Q R X d S )NZ	Duplicate)r   )r   r   rJ   r   )r   rI   r   r   r   test_repeated_field_names   s    z,TestMakeTupleBunch.test_repeated_field_namesZ_aZ_xc          	   C   s&   t jtdd t|  W d Q R X d S )NZ
underscore)r   )r   r   rJ   r   )r   rI   r   r   r   #test_leading_underscore_not_allowed   s    z6TestMakeTupleBunch.test_leading_underscore_not_alloweddeforandc          	   C   s&   t jtdd t|  W d Q R X d S )Nkeyword)r   )r   r   rJ   r   )r   rI   r   r   r   "test_keyword_not_allowed_in_fields   s    z5TestMakeTupleBunch.test_keyword_not_allowed_in_fieldsc          	   C   s.   t jtdd tdg ddg W d Q R X d S )Nzat least one name)r   ZQwertyrA   rB   )r   r   rJ   r   )r   r   r   r   %test_at_least_one_field_name_required   s    z8TestMakeTupleBunch.test_at_least_one_field_name_requiredN)__name__r4   __qualname__r   r   r   r   r   r   r!   r#   r*   r,   r-   r0   r3   r6   r:   r?   rD   rH   r   markZparametrizerK   rL   rM   rR   rS   r   r   r   r   r
      s:   
r
   )r   r$   Znumpy.testingr   Zscipy._lib._bunchr   r   r
   r   r   r   r   <module>   s
   