U
    ÌZj  ã                   @   s*   d Z ddlZG dd„ dejƒZdd„ ZdS )zPure-Python hookable tests
é    Nc                   @   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 )ÚHookableTestsc                 C   s   ddl m} |  t|¡ d S )Nr   ©Úhookable©Úzope.component.hookabler   ZassertRaisesÚ	TypeError)Úselfr   © r	   úe/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/zope/component/tests/test_hookable.pyÚtest_ctor_no_func   s    zHookableTests.test_ctor_no_funcc                 C   s@   ddl m} dd„ }||ƒ}|  |j|k¡ |  |j|k¡ d S )Nr   r   c                   S   s   d S ©Nr	   r	   r	   r	   r
   Úfoo   s    z+HookableTests.test_ctor_simple.<locals>.foo)r   r   Ú
assertTrueÚoriginalÚimplementation©r   r   r   Úhookedr	   r	   r
   Útest_ctor_simple   s
    zHookableTests.test_ctor_simplec                 C   s(   ddl m} dd„ }|  t|||¡ d S )Nr   r   c                   S   s   d S r   r	   r	   r	   r	   r
   r   #   s    z.HookableTests.test_ctor_extra_arg.<locals>.foor   ©r   r   r   r	   r	   r
   Útest_ctor_extra_arg!   s    z!HookableTests.test_ctor_extra_argc                 C   s*   ddl m} dd„ }| jt|||d� d S )Nr   r   c                   S   s   d S r   r	   r	   r	   r	   r
   r   )   s    z3HookableTests.test_ctor_extra_arg_miss.<locals>.foo)Znonesuchr   r   r	   r	   r
   Útest_ctor_extra_arg_miss'   s    z&HookableTests.test_ctor_extra_arg_missc                 C   sR   ddl m} dd„ }dd„ }||ƒ}| |¡ |  |j|k¡ |  |j|k¡ d S )Nr   r   c                   S   s   d S r   r	   r	   r	   r	   r
   r   /   s    z'HookableTests.test_sethook.<locals>.fooc                   S   s   d S r   r	   r	   r	   r	   r
   Úbar1   s    z'HookableTests.test_sethook.<locals>.bar)r   r   Úsethookr   r   r   ©r   r   r   r   r   r	   r	   r
   Útest_sethook-   s    
zHookableTests.test_sethookc                 C   sZ   ddl m} dd„ }dd„ }||ƒ}| |¡ | ¡  |  |j|k¡ |  |j|k¡ d S )Nr   r   c                   S   s   d S r   r	   r	   r	   r	   r
   r   :   s    z%HookableTests.test_reset.<locals>.fooc                   S   s   d S r   r	   r	   r	   r	   r
   r   <   s    z%HookableTests.test_reset.<locals>.bar)r   r   r   Úresetr   r   r   r   r	   r	   r
   Ú
test_reset8   s    
zHookableTests.test_resetc                 C   sd   ddl m} dd„ }dd„ }||ƒ}z
||_W n& tk
rB   Y n tk
rT   Y nX |  d¡ d S )Nr   r   c                   S   s   d S r   r	   r	   r	   r	   r
   r   F   s    z4HookableTests.test_cant_assign_original.<locals>.fooc                   S   s   d S r   r	   r	   r	   r	   r
   r   H   s    z4HookableTests.test_cant_assign_original.<locals>.barzAssigned original©r   r   r   r   ÚAttributeErrorÚfailr   r	   r	   r
   Útest_cant_assign_originalD   s    
z'HookableTests.test_cant_assign_originalc                 C   sZ   ddl m} dd„ }||ƒ}z|`W n& tk
r8   Y n tk
rJ   Y nX |  d¡ d S )Nr   r   c                   S   s   d S r   r	   r	   r	   r	   r
   r   V   s    z4HookableTests.test_cant_delete_original.<locals>.foozDeleted originalr   r   r	   r	   r
   Útest_cant_delete_originalT   s    z'HookableTests.test_cant_delete_originalc                 C   sd   ddl m} dd„ }dd„ }||ƒ}z
||_W n& tk
rB   Y n tk
rT   Y nX |  d¡ d S )Nr   r   c                   S   s   d S r   r	   r	   r	   r	   r
   r   d   s    z:HookableTests.test_cant_assign_implementation.<locals>.fooc                   S   s   d S r   r	   r	   r	   r	   r
   r   f   s    z:HookableTests.test_cant_assign_implementation.<locals>.barzAssigned implementation©r   r   r   r   r   r   r   r	   r	   r
   Útest_cant_assign_implementationb   s    
z-HookableTests.test_cant_assign_implementationc                 C   sZ   ddl m} dd„ }||ƒ}z|`W n& tk
r8   Y n tk
rJ   Y nX |  d¡ d S )Nr   r   c                   S   s   d S r   r	   r	   r	   r	   r
   r   t   s    z:HookableTests.test_cant_delete_implementation.<locals>.foozDeleted implementationr"   r   r	   r	   r
   Útest_cant_delete_implementationr   s    z-HookableTests.test_cant_delete_implementationc                    sL   ddl m} g ‰ ‡ fdd„}||ƒ}|dddd� |  ˆ d	d
difg¡ d S )Nr   r   c                     s   ˆ   | |f¡ d S r   )Úappend)ÚargsÚkw©Z_calledr	   r
   r   ƒ   s    z-HookableTests.test_ctor___call__.<locals>.fooÚoneÚtwoZbaz)r   )r)   r*   r   )r   r   ZassertEqualr   r	   r(   r
   Útest_ctor___call__€   s    z HookableTests.test_ctor___call__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r    r!   r#   r$   r+   r	   r	   r	   r
   r      s   r   c                   C   s   t  t  t¡f¡S r   )ÚunittestZ	TestSuiteZ	makeSuiter   r	   r	   r	   r
   Ú
test_suiteŠ   s    ÿr0   )Ú__doc__r/   ZTestCaser   r0   r	   r	   r	   r
   Ú<module>   s   w