U
    Pe                     @   sd  d Z ddlZddlZddlmZ ddlmZ G dd deZe Zej	ddd	d
 Z
e	 dd Zejdddgdd Zejdddgdd Zejdddgdd Zejdddgdd Zejdddgdd Zejdddgdd Zejdddgdd Zejdddgdd Zejdddgdd  Zejdddgd!d" Zejdddgd#d$ Zejdddgd%d& Zejdddgd'd( Zejdddgd)d* Zejdddgd+d, Zejdddgd-d. Zd/d0 Zejdddgd1d2 Zejd3ddgd4d5 Z ejd3ddgd6d7 Z!ejd3ddgd8d9 Z"ejd3ddgd:d; Z#ejd3ddgd<d= Z$ejd3ddgd>d? Z%ejd3ddgd@dA Z&dBdC Z'dDdE Z(dFdG Z)dHdI Z*dJdK Z+dLdM Z,dNdO Z-dPdQ Z.ejdRddgdSdT Z/dUdV Z0dWdX Z1dYdZ Z2d[d\ Z3d]d^ Z4dS )_z&
Test properties attached to a widget
    NEventDispatcher)partialc                   @   s   e Zd ZdS )_TestPropertyN__name__
__module____qualname__ r
   r
   >/tmp/pip-unpacked-wheel-xzebddm3/kivy/tests/test_properties.pyr      s   r   T)Zautousec                 C   s   d S Nr
   )Z
kivy_clockr
   r
   r   	set_clock   s    r   c                   C   s   t  S r   )unittestZTestCaser
   r
   r
   r   self   s    r   set_nameFc                 C   s   ddl m} |d}|r0|td |t n|td |td | |td |	td | |td |	td | |td d S )Nr   Propertya   )
kivy.propertiesr   r   widlink_eagerlylink	link_depsassertEqualgetset)r   r   r   r   r
   r
   r   	test_base   s    r   c                 C   s   ddl m} |d}|r0|td |t n|td |td | |td da	dd }|
t| |td | |td | t	d da	|td | |td | t	d |td | |td | t	d d S )Nr   r   r   r   c                 S   s   da d S Nr   observe_calledobjvaluer
   r
   r   observe=   s    ztest_observer.<locals>.observer   )r   r   r   r   r   r   r   r   r   r!   bindr   )r   r   r   r   r%   r
   r
   r   test_observer.   s*    r'   c                 C   s|   ddl m} |d}|r0|td |t n|td |td | |td |	td | |td d S )Nr   ObjectPropertyFr   T)
r   r)   r   r   r   r   r   r   r   r   )r   r   r)   r   r
   r
   r   test_objectcheckN   s    r*   c                 C   s   ddl m} | }|r.|td |t n|td |td | |td |	td | |td z|	td | 
d W n tk
r   Y nX d S )Nr   StringPropertyr    helloX   zstring accept number, fail.)r   r,   r   r   r   r   r   r   r   r   Zfail
ValueError)r   r   r,   r   r
   r
   r   test_stringcheck^   s    r1   c                 C   sz   ddl m} | }|r.|td |t n|td |td | |td |	td | |td d S )Nr   NumericPropertyr   c   
r   r3   r   r   r   r   r   r   r   r   r   r   r3   r   r
   r
   r   test_numericcheckt   s    r7   c                 C   s   ddl m} | }|r.|td |t n|td |td | |tg  |	tdddg | |tdddg d S )Nr   ListPropertyr   r         )
r   r9   r   r   r   r   r   r   r   r   )r   r   r9   r   r
   r
   r   test_listcheck   s    r<   c                 C   s   ddl m} | }|r.|td |t n|td |td | |ti  |	tddi | |tddi d S )Nr   DictPropertyr   foobar)
r   r>   r   r   r   r   r   r   r   r   )r   r   r>   r   r
   r
   r   test_dictcheck   s    rA   c                 C   s   ddl m} |ddd}|r4|td |t n|td |td | |td z"|	td  | |td  W n t
k
r   Y nX |	td | |td d S )Nr   r2   T	allownoner   r   )r   r3   r   r   r   r   r   r   r   r   r0   r6   r
   r
   r   test_propertynone   s    rD   c                 C   s  ddl m}m} |d}|r4|td |t n|td |td |d}|rp|td |t n|td |td |||}|r|td |t n|td |td | |	td | |	td | |	tddg |
td | |	tddg |
td | |	tddg |
tddg | |	tddg | |	td | |	td dadd }|t| | td |
td	 | td
 d S )Nr   r3   ReferenceListPropertyxypos2   c                 S   s   da d S r   r    r"   r
   r
   r   r%      s    ztest_reference.<locals>.observer4   r   )r   r3   rF   r   r   r   r   r   r   r   r   r!   r&   )r   r   r3   rF   rG   rH   rI   r%   r
   r
   r   test_reference   sH    
rK   c                 C   s  ddl m}m} |d}|r4|td |t n|td |td |d}|rp|td |t n|td |td |||}|r|td |t n|td |td d|td< | 	|tddg d|td d < | 	|tdd	g d S )
Nr   rE   rG   rH   rI   
   )      rM   rN   )
r   r3   rF   r   r   r   r   r   r   r   )r   r   r3   rF   rG   rH   rI   r
   r
   r   test_reference_child_update   s.    
rO   c                 C   s   ddl m} | }|r.|td |t n|td |td dadd }|t| dad|	td< | 
td dad|	td< | 
td dad|	td	< | 
td da|	td= | 
td da|	td
di | 
td d S )Nr   r=   rG   c                 S   s   da d S r   r    r"   r
   r
   r   r%   '  s    ztest_dict.<locals>.observer   Ztotor:   ZyouupiZbleh   )r   r>   r   r   r   r   r   r!   r&   r   r   update)r   r   r>   rG   r%   r
   r
   r   	test_dict  s2    rR   c                 C   s   ddl m} |dddd}|r6|td |t n|td |td |td |td |td |td | t	t
|jtd	 | t	t
|jtd
 d S )Nr   BoundedNumericProperty        g      @)minmaxbnpr   g@g@)r   rT   r   r   r   r   r   r   assertRaisesr0   r   r   r   rT   rX   r
   r
   r   test_bounded_numeric_propertyB  s    r\   c                 C   s   ddl m} |ddddd}|r8|td |t n|td |td |td | |	td |td | |	td |td | |	td |td | |	td |td	 | |	td d S )
Nr   rS   rP   r   )rV   rW   Z
errorvaluerX      i
r   rT   r   r   r   r   r   r   r   r   r[   r
   r
   r   )test_bounded_numeric_property_error_valueW  s"    r`   c                 C   s   ddl m} |ddddd d}|r<|td |t n|td |td |td	 | |	td	 |td | |	td |td
 | |	td |td | |	td |td | |	td d S )Nr   rS   r]   rP   c                 S   s   | dkrdS dS )NrP   r]   r
   )rG   r
   r
   r   <lambda>y      z=test_bounded_numeric_property_error_handler.<locals>.<lambda>)rV   rW   ZerrorhandlerrX   r   rL   ir_   r[   r
   r
   r   +test_bounded_numeric_property_error_handlers  s,      rc   c                 C   s>  ddl m} ddlm} | }|r:|td |t n|td |td | 	|
td |td |j}| 	|
td|  | 	|td |td | 	|
td|  | 	|td |td | 	|
td	|  | 	|td
 |td | 	|
td	|  | 	|td
 d S )Nr   r2   )Metricsr   Z55dp7   dpZ99ing     @in)r   r3   Zkivy.metricsrd   r   r   r   r   r   r   r   r   densityZ
get_format)r   r   r3   rd   r   rh   r
   r
   r   $test_numeric_string_with_units_check  s,    ri   c                 C   sz   ddl m} | }|r.|td |t n|td |td | |td |	td | |td d S )Nr   r2   r   2r:   r5   r6   r
   r
   r   !test_numeric_string_without_units  s    rk   c                    s  ddl m} ddlm} ddlm} ddlmmm	  ddl
m} G fddd|}G fd	d
d
|}G fddd|}G fddd|}G  fddd|}	|d | }
| }| }| }|	 }| }|  | |
jd | |jd | |jd | |jd | |jd ||
_||_||j_||j_||_|  | |
jd | |jd | |jd | |jd | |jd d|_|  | |
jd | |jd | |jd | |jd | |jd d|_|  | |
jd | |jd | |jd | |jd | |jd d |
_d |_d |j_d |j_d |_|  | |
jd | |jd | |jd | |jd | |jd d S )Nr   )Label)ToggleButton)Builder)r)   r>   AliasProperty)Clockc                       s   e Zd Z ddddZdS )z'test_property_rebind.<locals>.ObjWidgetNTrebindrC   r   r   r	   buttonr
   r(   r
   r   	ObjWidget  s   ru   c                       s   e Zd Z ddddZdS )z2test_property_rebind.<locals>.ObjWidgetRebindFalseNFTrq   rs   r
   r(   r
   r   ObjWidgetRebindFalse  s   rv   c                       s   e Zd Z ddidddZdS )z(test_property_rebind.<locals>.DictWidgetrt   NTrq   rs   r
   r=   r
   r   
DictWidget  s   
rw   c                       s   e Zd Z ddiddZdS )z-test_property_rebind.<locals>.DictWidgetFalsert   NFrr   rs   r
   r=   r
   r   DictWidgetFalse  s   ry   c                       s.   e Zd ZdZdd Zdd Z eeddZdS )z)test_property_rebind.<locals>.AliasWidgetNc                 S   s
   || _ dS )NT_buttonr   r$   r
   r
   r   setter  s    z0test_property_rebind.<locals>.AliasWidget.setterc                 S   s   | j S r   rz   r   r
   r
   r   getter  s    z0test_property_rebind.<locals>.AliasWidget.getterTrx   )r   r   r	   r{   r}   r   rt   r
   ro   r
   r   AliasWidget  s   r   a  
<ObjWidget>:
    text: self.button.state if self.button is not None else 'Unset'

<ObjWidgetRebindFalse>:
    text: self.button.state if self.button is not None else 'Unset'

<AliasWidget>:
    text: self.button.state if self.button is not None else 'Unset'

<DictWidget>:
    text: self.button.button.state if self.button.button is not None else 'Unset'

<DictWidgetFalse>:
    text: self.button.button.state if self.button.button is not None else 'Unset'
ZUnsetnormalZdown)Zkivy.uix.labelrl   Zkivy.uix.togglebuttonrm   Z	kivy.langrn   r   r)   r>   ro   Z
kivy.clockrp   load_stringZtickr   textrt   state)r   rl   rm   rn   rp   ru   rv   rw   ry   r   r#   Z	obj_falseZdict_rebindZ
dict_falseZalias_rebindrt   r
   )ro   r>   r)   r   test_property_rebind  sv    
r   c                 C   s  ddl m} | }|r.|td |t n|td |td | |tddddg | }|r|td |t n|td |td | |tddddg |	td | |tddddg |	td	 | |tddddg |	td
 | |td d | |td d | |td d | |td d |	td | |tddddg |	td | |tddddg |	tddddg |t}d|d< | |tddddg | |tddddg |	t|t | |tddddg |	tddddg |t}ddddg|d d < | |tddddg d S )Nr   )ColorPropertycolorr   color2Zyellowg      ?rU   z#00ff00z	#7f7fff7fg?r:   r;   )r   r   r   )r   r   r   r   g      ?)
r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   Zcolor_valuer
   r
   r   test_color_property+  sN    

r   watch_before_usec                    sx   ddl m  dG  fdddt }| |jd |j}| | | |jd | ttt	|dd d S )Nr   r   rP   c                       s8   e Zd ZfddZeddZ fddZ  ZS )z7test_alias_property_without_setter.<locals>.CustomAliasc                    s   |  j d7  _  S r   getter_calledr~   expected_valuer
   r   	_get_propi  s    zAtest_alias_property_without_setter.<locals>.CustomAlias._get_propNr   c                    s   t  | jf | d| _d S Nr   super__init__r   r   kwargsCustomAlias	__class__r
   r   r   o  s    z@test_alias_property_without_setter.<locals>.CustomAlias.__init__)r   r   r	   r   propr   __classcell__r
   ro   r   r   r   r   r   r   g  s   r   r   r   )
r   ro   r   r   r   r   rZ   AttributeErrorr   setattrr   r   r   r$   r
   r   r   "test_alias_property_without_settera  s    r   c                    s  ddl m  G  fdddtdd } }|j|d | |jd | |jd | |jd d|_| |jd | |jd | |jd d|_| |jd | |jd	 | |jd | |jd  | |jd | |jd	 | |jd d S )
Nr   r   c                       s<   e Zd Zdd Zdd ZeedZ fddZ  ZS )z(test_alias_property.<locals>.CustomAliasc                 S   s   |  j d7  _ d S r   r   r~   r
   r
   r   r     s    z2test_alias_property.<locals>.CustomAlias._get_propc                 S   s   |  j d7  _ d S r   setter_calledr|   r
   r
   r   	_set_prop  s    z2test_alias_property.<locals>.CustomAlias._set_propr   c                    s(   t  | jf | d| _d| _d| _d S r   r   r   r   r   callback_calledr   r   r
   r   r     s    z1test_alias_property.<locals>.CustomAlias.__init__r   r   r	   r   r   r   r   r   r
   ro   r   r   r   r   r     s     r   c                 S   s   |  j d7  _ d S r   r   Zwidgetr$   r
   r
   r   callback  s    z%test_alias_property.<locals>.callbackr   r   r:   	r   ro   r   r&   r   r   r   r   r   r   r   r   r   r
   r   r   test_alias_property  s(    r   c                    s   ddl m  dG  fdddt }| |jd | |jd |j}| | | |jd | |jd |j}| | | |jd | |jd d|_|j}| | | |jd | |jd d S )	Nr   r   rP   c                       sB   e Zd ZfddZdd ZeeddZ fddZ  ZS )	z3test_alias_property_cache_true.<locals>.CustomAliasc                    s   |  j d7  _  S r   r   r~   r   r
   r   r     s    z=test_alias_property_cache_true.<locals>.CustomAlias._get_propc                 S   s   |  j d7  _ dS )Nr   Tr   r|   r
   r
   r   r     s    z=test_alias_property_cache_true.<locals>.CustomAlias._set_propT)cacher   c                    s"   t  | jf | d| _d| _d S r   )r   r   r   r   r   r   r
   r   r     s    z<test_alias_property_cache_true.<locals>.CustomAlias.__init__r   r
   r   r   r   r     s      r   r   rL   r:   )r   ro   r   r   r   r   r   r   r
   r   r   test_alias_property_cache_true  s&    r   c                    s  ddl mm  G  fdddt }| |jd d|_| |jd d|_| |jd	 d|_| |jd | |jd d
d }|j|d d|_| |j	d d|_| |j	d d|_| |j	d d|_| |j	d d|_| |j	d d S )Nr   r3   ro   c                       sN   e Zd ZdZdZdd Zdd ZeeddZ fd	d
Z  Z	S )z2test_alias_property_with_bind.<locals>.CustomAliasr   d   c                 S   s   | j | j S r   rG   widthr~   r
   r
   r   	get_right  s    z<test_alias_property_with_bind.<locals>.CustomAlias.get_rightc                 S   s   || j  | _d S r   )r   rG   r|   r
   r
   r   	set_right  s    z<test_alias_property_with_bind.<locals>.CustomAlias.set_rightr   )r&   r   c                    s   t  | jf | d| _d S r   )r   r   r   r   r   r
   r   r     s    z;test_alias_property_with_bind.<locals>.CustomAlias.__init__)
r   r   r	   rG   r   r   r   rightr   r   r
   ro   r   r3   r   r   r   r     s     r   r   i  iX  rJ   i&  c                 S   s   |  j d7  _ d S r   r   r   r
   r
   r   r     s    z/test_alias_property_with_bind.<locals>.callback)r   r   i  r:   i  r;   )
r   r3   ro   r   r   r   rG   r   r&   r   )r   r   r   r   r
   r   r   test_alias_property_with_bind  s.    r   c                    s   ddl m  G  fdddtdd } }|j|d | |jd | |jd | |jd d|_| |jd | |jd | |jd d|_| |jd	 | |jd	 | |jd	 d S )
Nr   r   c                       s>   e Zd Zdd Zdd ZeeddZ fddZ  ZS )	zAtest_alias_property_with_force_dispatch_true.<locals>.CustomAliasc                 S   s   |  j d7  _ d S r   r   r~   r
   r
   r   r      s    zKtest_alias_property_with_force_dispatch_true.<locals>.CustomAlias._get_propc                 S   s   |  j d7  _ d S r   r   r|   r
   r
   r   r   #  s    zKtest_alias_property_with_force_dispatch_true.<locals>.CustomAlias._set_propT)force_dispatchr   c                    s(   t  | jf | d| _d| _d| _d S r   r   r   r   r
   r   r   *  s    zJtest_alias_property_with_force_dispatch_true.<locals>.CustomAlias.__init__r   r
   r   r   r   r     s     r   c                 S   s   |  j d7  _ d S r   r   r   r
   r
   r   r   0  s    z>test_alias_property_with_force_dispatch_true.<locals>.callbackr   r   r:   r   r   r
   r   r   ,test_alias_property_with_force_dispatch_true  s     r   c                    s   ddl mm  G  fdddt }| |jd | |jd | |jd d|_| |jt | |jd | |jd d|_| |jd | |jd | |jd | |jd d S )	Nr   r   c                       sH   e Zd ZdZdd Zdd ZeedddZ fd	d
Z  ZS )z=test_alias_property_cache_true_with_bind.<locals>.CustomAliasr   c                 S   s   |  j d7  _ | jd S Nr   r:   r   
base_valuer~   r
   r
   r   r   Q  s    zGtest_alias_property_cache_true_with_bind.<locals>.CustomAlias._get_propc                 S   s   |d | _ d S )Nr:   r   r|   r
   r
   r   r   U  s    zGtest_alias_property_cache_true_with_bind.<locals>.CustomAlias._set_propr   T)r&   r   r   c                    s   t  | jf | d| _d S r   r   r   r   r
   r   r   \  s    zFtest_alias_property_cache_true_with_bind.<locals>.CustomAlias.__init__)	r   r   r	   r   r   r   r   r   r   r
   r   r   r   r   M  s    r   r         r:   )	r   r3   ro   r   r   r   r   intr   )r   r   r   r
   r   r   (test_alias_property_cache_true_with_bindI  s    r   c                    s2  ddl m  G  fdddtdd } }|j|d | |jd | |jd | |jd | |jd d	|_	| |jd
 | |jd | |jd | |jd d	|_	| |jd
 | |jd | |jd | |jd |j	}| |d	 | |jd | |jd | |jd d S )Nr   r   c                       s@   e Zd Zdd Zdd ZeedddZ fddZ  ZS )	zGtest_alias_property_cache_true_force_dispatch_true.<locals>.CustomAliasc                 S   s   |  j d7  _ | jd S r   r   r~   r
   r
   r   r   |  s    zQtest_alias_property_cache_true_force_dispatch_true.<locals>.CustomAlias._get_propc                 S   s   |  j d7  _ |d | _dS )Nr   r:   T)r   r   r|   r
   r
   r   r     s    
zQtest_alias_property_cache_true_force_dispatch_true.<locals>.CustomAlias._set_propT)r   r   r   c                    s.   t  | jf | d| _d| _d| _d| _d S )Nr   r   )r   r   r   r   r   r   r   r   r
   r   r     s
    zPtest_alias_property_cache_true_force_dispatch_true.<locals>.CustomAlias.__init__r   r
   r   r   r   r   z  s      r   c                 S   s   |  j d7  _ d S r   r   r   r
   r
   r   r     s    zDtest_alias_property_cache_true_force_dispatch_true.<locals>.callbackr   r      r   r:   )
r   ro   r   r&   r   r   r   r   r   r   )r   r   r   r   r$   r
   r   r   2test_alias_property_cache_true_force_dispatch_truev  s0    r   c                  C   s   ddl m}  | d }|td |t |td ks<t| ddddd}|td	 |t |td  |td kstd S )
Nr   r=   d1r   r:   )r   bTrB   d2)r   r>   r   r   r   r   AssertionErrorr   )r>   r   r   r
   r
   r   test_dictproperty_is_none  s    

r   c                  C   s   ddl m}  | d }|td |t |td ks<t| dddgdd}|td	 |t |td  |td kstd S )
Nr   r8   l1r   r:   r;   TrB   l2)r   r9   r   r   r   r   r   r   )r9   r   r   r
   r
   r   test_listproperty_is_none  s    

r   c                    s6  ddl m} ddlm  d| _G  fddd|}| }ddddfdd	}|d
|d
 |d|d |d|d d
 rtd rtd rt|jdkst|jdkst|j	dkstd|_d
 dkst|jdkstd| _d
 dkstd rtd dks$t|jdks4t|jdksDt|j	dksTtd|_d|_d
 dksrtd dkstd dkst|jdkst|jdkst|j	dkstd| _d
 dkstd dkstd dkst|jdkst|jdks"t|j	dks2td S )Nr   r   r2   r   c                       s$   e Zd Z dZ dZ dZdS )z(test_numeric_property_dp.<locals>.NumberrP   rL   10dpN)r   r   r	   with_dpno_dp
default_dpr
   r2   r
   r   Number  s   r   )r   r   r   c                    s    |   d7  < d S r   r
   nameargscounterr
   r   r     s    z*test_numeric_property_dp.<locals>.callbackr   r   r   rP   rL   r:   rM   Z20dp(   r;   )

kivy.eventr   r   r3   rh   fbindr   r   r   r   Zkivy_metricsr   r   numberr   r
   )r3   r   r   test_numeric_property_dp  sR    r   c                    s   ddl m} ddlm  d| _G  fddd|}| }dfdd}|d	| t|jd
dddgksntrvtd| _dkstt|jddddgkstd| _dkstt|jd
dddgkstd S )Nr   r   VariableListPropertyr   c                       s   e Zd Z ddddgZdS )z6test_variable_list_property_dp_default.<locals>.Numberr   rM   rf   r;         @Nr   r   r	   r   r
   r   r
   r   r     s   r   c                    s    d7  d S r   r
   r   r   r
   r   r     s    z8test_variable_list_property_dp_default.<locals>.callbackr   rL   rM   r;   r   r:   r   	r   r   r   r   rh   r   listr   r   r   r
   r   r   r   &test_variable_list_property_dp_default  s     r   c                    s  ddl m} ddlm  d| _G  fddd|}| }dfdd}|d	| t|jdd
ddgksntrvtddddg|_t|jdd
ddgkstdkstd| _dkstt|jd
dddgkstd| _dkstt|jdd
ddgkstd S )Nr   r   r   r   c                       s   e Zd Z ddddgZdS )z.test_variable_list_property_dp.<locals>.Numberr   rM   r;   r   Nr   r
   r   r
   r   r   4  s   r   c                    s    d7  d S r   r
   r   r   r
   r   r   ;  s    z0test_variable_list_property_dp.<locals>.callbackr   rM   r;   r   r   r   r   rL   r:   r   r   r   r
   r   r   test_variable_list_property_dp/  s&    r   c                     s   ddl m}  ddlm  G  fddd| }| }ddfdd}fdd	}|d
| |d
d  |d
| d|_rtdkstd S )Nr   r   r(   c                       s   e Zd Z dZdS )z+test_property_duplicate_name.<locals>.EventrP   Nr   r
   r(   r
   r   EventV  s   r   c                     s    d7  d S r   r
   r   r   r
   r   r   ^  s    z.test_property_duplicate_name.<locals>.callbackc                     s    d7  d S r   r
   r   counter2r
   r   	callback2b  s    z/test_property_duplicate_name.<locals>.callback2r      r   )r   r   r   r)   r   create_propertyr   r   r   r   eventr   r   r
   r)   r   r   r   test_property_duplicate_nameR  s    r   c                     s   ddl m}  ddlm  G  fddd| }| }ddfdd}fdd	}|d
| |d| d|_dks|tdkst|jdkst|jdkstd|_dkstdkst|jdkst|jdkstd S )Nr   r   r(   c                       s   e Zd Z dZeZdS )z-test_property_rename_duplicate.<locals>.EventrP   N)r   r   r	   r   r   r
   r(   r
   r   r   t  s   r   c                     s    d7  d S r   r
   r   r   r
   r   r   }  s    z0test_property_rename_duplicate.<locals>.callbackc                     s    d7  d S r   r
   r   r   r
   r   r     s    z1test_property_rename_duplicate.<locals>.callback2r   r   r   r      r:   )r   r   r   r)   r   r   r   r   r   r
   r   r   test_property_rename_duplicatep  s(    r   c                     s   ddl m}  ddlmm  dG fddd| }G  fddd|}| }| }d|_|jdksjtdksvt|jd	kstd	kst|jdkstt|d
stt|d
 std S )Nr   r   )r)   ro   c                       s   e Zd Z  ZdS )z.test_override_prop_inheritance.<locals>.ParentN)r   r   r	   r   r
   r(   r
   r   Parent  s   r   c                       s    e Zd ZfddZ eZdS )z-test_override_prop_inheritance.<locals>.Childc                    s    d7   S r   r
   )r   r   r   r
   r   inc  s    z1test_override_prop_inheritance.<locals>.Child.incN)r   r   r	   r   r   r
   )ro   r   r
   r   Child  s   r   ,   r   r   )	r   r   r   r)   ro   r   r   
isinstanceproperty)r   r   r   parentchildr
   )ro   r)   r   r   test_override_prop_inheritance  s    	r   by_valc                    s   ddl m} ddlm} G dd d|}| }t|dr<t| rN|dd n|j|dd d  fd	d
}|d| |j	dkstd|_	|j	dkst |dfkst| }|j	dkst|d| d|_	|j	dkst |dfkstd S )Nr   r   r+   c                   @   s   e Zd ZdS )z,test_manually_create_property.<locals>.EventNr   r
   r
   r
   r   r     s   r   r   r.   )r   c                    s   | |f d S r   r
   r#   valr   r
   r   r     s    z/test_manually_create_property.<locals>.callbackbyegoodbye)
r   r   r   r,   hasattrr   r   Zapply_propertyr   r   )r   r   r,   r   r   r   Zevent2r
   r   r   test_manually_create_property  s*    r  c                     s   ddl m}  ddlm  G  fddd| }G  fddd|}| }dfdd	}|d
| |d| |jdks|t|jdkstd|_|jdkst|dfkstd|_|jdkst|dfkstd S )Nr   r   r+   c                       s   e Zd Z dZdS )z$test_inherit_property.<locals>.Eventr.   Nr   r
   r+   r
   r   r     s   r   c                       s   e Zd Z dZdS )z%test_inherit_property.<locals>.Event2hello2N)r   r   r	   r   r
   r+   r
   r   Event2  s   r  c                    s   | |f d S r   r
   r  r   r
   r   r     s    z'test_inherit_property.<locals>.callbackr   r   r.   r  r  r  )r   r   r   r,   r   r   r   r   )r   r   r  r   r   r
   )r,   r   r   test_inherit_property  s"    r	  c               	      sX   ddl m  G  fdddt} tt}| ddd W 5 Q R X dt|jksTtd S )	Nr   r2   c                       s   e Zd Z dZdS )z'test_unknown_property.<locals>.MyWidgetr   N)r   r   r	   r   r
   r2   r
   r   MyWidget  s   r
  r   abc)r   ZunknziProperties ['unkn'] passed to __init__ may not be existing property names. Valid properties are ['width'])	r   r3   r   pytestraises	TypeErrorstrr$   r   )r
  cmr
   r2   r   test_unknown_property  s    r  c               	   C   s|   G dd d} G dd d| t }G dd dt | }tt}t dd W 5 Q R X d	t|jksdt|dd |dd d S )
Nc                       s   e Zd Z fddZ  ZS )z:test_known_property_multiple_inheritance.<locals>.Behaviorc                    s"   t d|  d|  t   d S )Nz
Behavior: z, name=)printr   r   r   r   r   r
   r   r     s    zCtest_known_property_multiple_inheritance.<locals>.Behavior.__init__r   r   r	   r   r   r
   r
   r   r   Behavior  s   r  c                   @   s   e Zd ZdS )z9test_known_property_multiple_inheritance.<locals>.Widget2Nr   r
   r
   r
   r   Widget2  s   r  c                   @   s   e Zd ZdS )z9test_known_property_multiple_inheritance.<locals>.Widget3Nr   r
   r
   r
   r   Widget3  s   r  Pastar   z:Properties ['name'] passed to __init__ may not be existingr   r  r  r  r  r$   r   )r  r  r  r  r
   r
   r   (test_known_property_multiple_inheritance  s    
r  c               
   C   sv   G dd d} G dd d| t }G dd dt | }||fD ]6}tt}|dd W 5 Q R X d	t|jks:tq:d S )
Nc                       s   e Zd Z fddZ  ZS )z+test_pass_other_typeerror.<locals>.Behaviorc                    s   t    tdd S )N'this is a typeerror unrelated to object)r   r   r  r  r   r
   r   r     s    
z4test_pass_other_typeerror.<locals>.Behavior.__init__r  r
   r
   r   r   r    s   r  c                   @   s   e Zd ZdS )z*test_pass_other_typeerror.<locals>.Widget2Nr   r
   r
   r
   r   r  !  s   r  c                   @   s   e Zd ZdS )z*test_pass_other_typeerror.<locals>.Widget3Nr   r
   r
   r
   r   r  $  s   r  r  r  r  r  )r  r  r  clsr  r
   r
   r   test_pass_other_typeerror  s    r  c               	      sL   G  fdddt  tt}  dd W 5 Q R X t| jdsHtd S )Nc                       s   e Zd Z fddZ  ZS )z'test_object_init_error.<locals>.TestClsc                    s   t  | jf | d S r   )r   r   r   )TestClsr   r
   r   r   /  s    z0test_object_init_error.<locals>.TestCls.__init__r  r
   r  r   r   r  .  s   r  r?   r  zobject.__init__() takes)objectr  r  r  r  r$   
startswithr   )r  r
   r   r   test_object_init_error-  s    r#  )5__doc__r   r  r   r   	functoolsr   r   r   Zfixturer   r   markZparametrizer   r'   r*   r1   r7   r<   rA   rD   rK   rO   rR   r\   r`   rc   ri   rk   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r  r#  r
   r
   r
   r   <module>   s   











6
 
*




h
5

3
1
3
.
,
<?#%
!!