U
    ,W                     @   s2   d Z ddlZG dd dejZdd Zdd ZdS )	zTests for z.c.factory
    Nc                   @   sf   e Zd Zdd Zd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 )FactoryTestsc                 C   s   ddl m} |S )Nr   )Factory)Zzope.component.factoryr   )selfr    r   C/usr/lib/python3/dist-packages/zope/component/tests/test_factory.py_getTargetClass   s    zFactoryTests._getTargetClassNc                 O   s    |d krt }|  |f||S N)_test_callabler   )r   callableargskwr   r   r   _makeOne   s    zFactoryTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   )verifyClassIFactory)zope.interface.verifyr   zope.component.interfacesr   r   )r   r   r   r   r   r   test_class_conforms_to_IFactory   s    z,FactoryTests.test_class_conforms_to_IFactoryc                 C   s*   ddl m} ddlm} |||   d S )Nr   )verifyObjectr   )r   r   r   r   r   )r   r   r   r   r   r   "test_instance_conforms_to_IFactory#   s    z/FactoryTests.test_instance_conforms_to_IFactoryc                 C   sD   |   }| |jt | |jd | |jd | |jd  d S )N )r   assertEqual	_callabler	   titledescriptionZ_interfacesr   factoryr   r   r   test_ctor_defaults(   s
    zFactoryTests.test_ctor_defaultsc                 C   s.   |  tdd}| |jd | |jd d S )NZTITLEZDESCRIPTION)r   r	   r   r   r   r   r   r   r   test_ctor_expclit/   s    zFactoryTests.test_ctor_expclitc                    s6   g   fdd}|  |}|  |  di fg d S )Nc                     s     | |f d S r   appendr   r   Z_calledr   r   r   6   s    z5FactoryTests.test___call___no_args.<locals>._callabler   r   r   r   r   r   r   r"   r   test___call___no_args4   s
    
z"FactoryTests.test___call___no_argsc                    s:   g   fdd}|  |}|dd |  di fg d S )Nc                     s     | |f d S r   r   r!   r"   r   r   r   >   s    z=FactoryTests.test___call___positional_args.<locals>._callableonetwo)r&   r'   r#   r$   r   r"   r   test___call___positional_args<   s
    

z*FactoryTests.test___call___positional_argsc                    s>   g   fdd}|  |}|dd |  dddifg d S )Nc                     s     | |f d S r   r   r!   r"   r   r   r   F   s    z:FactoryTests.test___call___keyword_args.<locals>._callableZbar)foor   r)   r#   r$   r   r"   r   test___call___keyword_argsD   s
    

z'FactoryTests.test___call___keyword_argsc           	      C   s   ddl m} ddl m} G dd d|}G dd d|}G dd	 d	|}||d
d }| j|||fd}| }| |jd | t|||g d S )Nr   	Interfaceimplementerc                   @   s   e Zd ZdS )z6FactoryTests.test_getInterfaces_explicit.<locals>.IFooN__name__
__module____qualname__r   r   r   r   IFooO   s   r3   c                   @   s   e Zd ZdS )z6FactoryTests.test_getInterfaces_explicit.<locals>.IBarNr/   r   r   r   r   IBarQ   s   r4   c                   @   s   e Zd ZdS )z6FactoryTests.test_getInterfaces_explicit.<locals>.IBazNr/   r   r   r   r   IBazS   s   r5   c                   S   s   d S r   r   r   r   r   r   r   U   s    z;FactoryTests.test_getInterfaces_explicit.<locals>._callable)Z
interfacesr   )zope.interfacer,   r.   r   getInterfacesr   r0   list)	r   r,   r.   r3   r4   r5   r   r   specr   r   r   test_getInterfaces_explicitL   s    
z(FactoryTests.test_getInterfaces_explicitc                 C   s`   ddl m} ddl m} G dd d|}||dd }| |}| }| t||g d S )Nr   r+   r-   c                   @   s   e Zd ZdS )z6FactoryTests.test_getInterfaces_implicit.<locals>.IBazNr/   r   r   r   r   r5   `   s   r5   c                   S   s   d S r   r   r   r   r   r   r   b   s    z;FactoryTests.test_getInterfaces_implicit.<locals>._callable)r6   r,   r.   r   r7   r   r8   )r   r,   r.   r5   r   r   r9   r   r   r   test_getInterfaces_implicit]   s    

z(FactoryTests.test_getInterfaces_implicit)N)r0   r1   r2   r   r   r   r   r   r   r%   r(   r*   r:   r;   r   r   r   r   r      s   
r   c                  O   s   d S r   r   r!   r   r   r   r	   i   s    r	   c                   C   s   t t tfS r   )unittestZ	TestSuiteZ	makeSuiter   r   r   r   r   
test_suitel   s    r=   )__doc__r<   ZTestCaser   r	   r=   r   r   r   r   <module>   s   V