U
    ,W                     @   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	   D/usr/lib/python3/dist-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