U
    x¡Ê]à  ã                   @   sœ   d Z ddlZdd„ Zdd„ Zdd„ ZG d	d
„ d
eƒZG dd„ deƒZG dd„ deejƒZ	G dd„ deejƒZ
G dd„ dee	ƒZG dd„ dee
ƒZdd„ ZdS )z$Test the hookable support Extension
é    Nc                   C   s   dS ©NÚFOO© r   r   r   úC/usr/lib/python3/dist-packages/zope/hookable/tests/test_hookable.pyÚ
return_foo   s    r   c                   C   s   dS ©NÚBARr   r   r   r   r   Ú
return_bar   s    r	   c                   C   s   t dƒ‚d S )NzThis should not be called)ÚAssertionErrorr   r   r   r   Ú
not_called   s    r   c                   @   s   e Zd Zdd„ ZdS )ÚPyHookableMixinc                 O   s   ddl m} |||ŽS )Nr   )Ú_py_hookable)Úzope.hookabler   )ÚselfÚargsÚkwr   r   r   r   Ú_callFUT   s    zPyHookableMixin._callFUTN©Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd„ ZdS )ÚHookableMixinc                 O   s,   ddl m}m} ||kr"t d¡‚|||ŽS )Nr   )Úhookabler   z$Hookable and PyHookable are the same)r   r   r   ÚunittestZSkipTest)r   r   r   r   r   r   r   r   r   #   s    
zHookableMixin._callFUTNr   r   r   r   r   r   !   s   r   c                   @   sd   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S )ÚPyHookableTestsc                 C   s0   ddl m}m}m}m} |  ||r&|n|¡ d S )Nr   )Ú_PURE_PYTHONr   r   Ú_c_hookable)r   r   r   r   r   ÚassertIs)r   r   r   r   r   r   r   r   Útest_pure_python-   s    z PyHookableTests.test_pure_pythonc                 C   s8   |   t¡}|  |jt¡ |  |jt¡ |  |ƒ d¡ d S r   ©r   r   r   ÚoriginalÚimplementationÚassertEqual©r   Úhookedr   r   r   Útest_before_hook1   s    
z PyHookableTests.test_before_hookc                 C   sN   |   t¡}| t¡}|  |t¡ |  |jt¡ |  |jt¡ |  |ƒ d¡ d S r   )r   r   Úsethookr	   r   r    r!   r"   ©r   r$   Úoldr   r   r   Útest_after_hook7   s    

zPyHookableTests.test_after_hookc                 C   sV   |   t¡}| t¡}| ¡  |  |t¡ |  |jt¡ |  |jt¡ |  |ƒ d¡ d S r   )	r   r   r&   r   Úresetr   r    r!   r"   r'   r   r   r   Útest_after_hook_and_reset?   s    

z)PyHookableTests.test_after_hook_and_resetc              	   C   s,   |   t¡}|  ttf¡
 |`W 5 Q R X d S ©N)r   r   ÚassertRaisesÚ	TypeErrorÚAttributeErrorr    r#   r   r   r   Útest_original_cannot_be_deletedH   s    
z/PyHookableTests.test_original_cannot_be_deletedc              	   C   s,   |   t¡}|  ttf¡
 |`W 5 Q R X d S r,   )r   r   r-   r.   r/   r!   r#   r   r   r   Ú%test_implementation_cannot_be_deletedM   s    
z5PyHookableTests.test_implementation_cannot_be_deletedc              	   C   s"   |   t¡ |  ¡  W 5 Q R X d S r,   ©r-   r.   r   ©r   r   r   r   Útest_no_argsR   s    zPyHookableTests.test_no_argsc              	   C   s&   |   t¡ |  tt¡ W 5 Q R X d S r,   )r-   r.   r   r   r3   r   r   r   Útest_too_many_argsV   s    z"PyHookableTests.test_too_many_argsc                 C   s:   | j td}|  |jt¡ |  |jt¡ |  |ƒ d¡ d S )N)r!   r   r   r#   r   r   r   Útest_w_implementation_kwargZ   s    z+PyHookableTests.test_w_implementation_kwargc              	   C   s&   |   t¡ | jdd W 5 Q R X d S )Né*   )Znonesuchr2   r3   r   r   r   Útest_w_unknown_kwarg`   s    z$PyHookableTests.test_w_unknown_kwargc                 C   sD   G dd„ dt ƒ}|  |¡}|  |ƒ |¡ | t¡ |  |ƒ d¡ d S )Nc                   @   s   e Zd ZdS )z%PyHookableTests.test_class.<locals>.CN©r   r   r   r   r   r   r   ÚCe   s   r:   r   )Úobjectr   ZassertIsInstancer&   r	   r"   ©r   r:   r$   r   r   r   Ú
test_classd   s
    

zPyHookableTests.test_classN)r   r   r   r   r%   r)   r+   r0   r1   r4   r5   r6   r8   r=   r   r   r   r   r   *   s   	r   c                   @   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S )ÚTestIssue6Pyc                 C   s,   |   d|j¡ |  |¡}|   |j|j¡ d S )NúI have some docs)r"   Ú__doc__r   )r   Údocsr$   r   r   r   Ú_check_preserves_docv   s    
z!TestIssue6Py._check_preserves_docc                 C   s   dd„ }|   |¡ d S )Nc                   S   s   dS )r?   Nr   r   r   r   r   rA   }   s    z6TestIssue6Py.test_preserves_doc_function.<locals>.docs)rB   )r   rA   r   r   r   Útest_preserves_doc_function|   s    z(TestIssue6Py.test_preserves_doc_functionc                 C   s   G dd„ dt ƒ}|  |¡ d S )Nc                   @   s   e Zd ZdZdS )z3TestIssue6Py.test_preserves_doc_class.<locals>.Docsr?   N)r   r   r   r@   r   r   r   r   ÚDocs‚   s   rD   )r;   rB   )r   rD   r   r   r   Útest_preserves_doc_class   s    z%TestIssue6Py.test_preserves_doc_classc                 C   s   |   t¡}|  d|j¡ d S )Nr   )r   r   r"   Ú	__bases__r#   r   r   r   Útest_empty_bases_function‡   s    
z&TestIssue6Py.test_empty_bases_functionc                 C   s   |   t¡}|  i |j¡ d S r,   )r   r   r"   Ú__dict__r#   r   r   r   Útest_empty_dict_function‹   s    
z%TestIssue6Py.test_empty_dict_functionc                 C   s>   G dd„ dt ƒ}|  |jt f¡ |  |¡}|  |jt f¡ d S )Nc                   @   s   e Zd ZdS )z(TestIssue6Py.test_bases_class.<locals>.CNr9   r   r   r   r   r:      s   r:   )r;   r"   rF   r   r<   r   r   r   Útest_bases_class   s    
zTestIssue6Py.test_bases_classc                 C   s.   G dd„ dt ƒ}|  |¡}|  |j|j¡ d S )Nc                   @   s   e Zd ZdS )z'TestIssue6Py.test_dict_class.<locals>.CNr9   r   r   r   r   r:   —   s   r:   )r;   r   r"   rH   r<   r   r   r   Útest_dict_class–   s    
zTestIssue6Py.test_dict_classc              	   C   sN   |   t¡}|  t¡ t|dƒ W 5 Q R X |  t¡ | d¡ W 5 Q R X d S )Nr7   )r   r   r-   r.   ÚgetattrÚ__getattribute__r#   r   r   r   Útest_non_string_attr_name   s
    
z&TestIssue6Py.test_non_string_attr_namec                 C   s$   |   t¡}| d¡}|  |d¡ d S )NrF   r   )r   r   rM   r"   )r   r$   Úresultr   r   r   Útest_unicode_attribute_name¦   s    

z(TestIssue6Py.test_unicode_attribute_namec              	   C   s.   |   t¡}|  t¡ | d¡ W 5 Q R X d S )NÚ )r   r   r-   r/   rM   r#   r   r   r   Útest_short_name¬   s    
zTestIssue6Py.test_short_nameN)r   r   r   rB   rC   rE   rG   rI   rJ   rK   rN   rP   rR   r   r   r   r   r>   n   s   	r>   c                   @   s   e Zd ZdS )ÚHookableTestsNr9   r   r   r   r   rS   ²   s   rS   c                   @   s   e Zd ZdS )Ú
TestIssue6Nr9   r   r   r   r   rT   µ   s   rT   c                   C   s   t j t¡S r,   )r   ZdefaultTestLoaderZloadTestsFromNamer   r   r   r   r   Ú
test_suite¸   s    rU   )r@   r   r   r	   r   r;   r   r   ZTestCaser   r>   rS   rT   rU   r   r   r   r   Ú<module>   s   	ÿDÿD