B
    `	                 @   s8   d dl mZ d dlmZ dddZdddZd	d
 ZdS )    )fixture)mockFNc                s   t |d fdd}|S )zReturns a pytest fixture that mocks a module's method or a class's
    class method.  "module" is a module or a class, but method is a string.
    )autousec                s(   t jt  d}|  | |S )N)specnamewraps)r   Mockgetattrsetattr)monkeypatchmocked)methodmoduler    ]/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/pgwui_develop/testing.pyfix!   s    zmake_mock_fixture.<locals>.fix)r   )r   r   r   r   r   r   )r   r   r   r   make_mock_fixture   s    r   c                s   t |d fdd}|S )zReturns a pytest fixture that magic mocks a module's method or a
    class's class method.  "module" is a module or a class, but method
    is a string.
    )r   c                s@    rt jtdd}nt jtd}| | |S )NT)spec_set)r   r   )r   Zcreate_autospecr	   Z	MagicMockr
   )r   r   )autospecr   r   r   r   r   /   s    z#make_magicmock_fixture.<locals>.fix)r   )r   r   r   r   r   r   )r   r   r   r   make_magicmock_fixture*   s    
r   c                s   t  fdd}|S )a  Returns a pytest fixture that mocks an instance method of a class.
    "method" is a string.

    The fixture is called by the test function with the class instance
    that's to be monkeypatched and the mock is returned for the
    test function to configure/etc.
    c                s    fdd}|S )Nc                s&   t jt|   d}|  | |S )N)r   r   )r   r   r	   r
   )clsr   )r   r   r   r   runF   s    z6instance_method_mock_fixture.<locals>.fix.<locals>.runr   )r   r   )r   )r   r   r   D   s    z)instance_method_mock_fixture.<locals>.fix)r   )r   r   r   )r   r   instance_method_mock_fixture<   s    r   )FN)FF)Zpytestr   Zunittestr   r   r   r   r   r   r   r   <module>   s   

