
u«Ajb  ã               @   s:  d  Z  d d l Z d d l m Z d d l m Z m Z m Z m Z m	 Z	 d d l
 Z
 e r d d l m Z d d l m Z n
 e Z Z e j j d ƒ Z d	 d
 „  Z e d d d d d „ ƒ Z e
 j d d ƒ d d „  ƒ Z e
 j d d ƒ d d „  ƒ Z e
 j d d ƒ d d „  ƒ Z e
 j d d ƒ d d „  ƒ Z e
 j d d ƒ d d „  ƒ Z e
 j d d ƒ d d „  ƒ Z e
 j d d ƒ d d „  ƒ Z e
 j d d ƒ d d „  ƒ Z e
 j d d ƒ d  d! „  ƒ Z e
 j ƒ  d" d# „  ƒ Z e
 j d d ƒ d$ d% „  ƒ Z  e
 j ƒ  d& d' „  ƒ Z! e
 j ƒ  d( d) „  ƒ Z" d S)*z;Fixtures and testing utilities for :pypi:`pytest <pytest>`.é    N)Úcontextmanager)ÚTYPE_CHECKINGÚAnyÚMappingÚSequenceÚUnion)ÚCeleryé   )ÚWorkControllerÚ	NO_WORKERc             C   s   |  j  d d ƒ d S)z)Register additional pytest configuration.ÚmarkerszBcelery(**overrides): override celery configuration for a test caseN)Úaddinivalue_line)Úconfig© r   ú_/home/www/goberdata.com/tradingbinance/backend/.venv/Lib/site-packages/celery/contrib/pytest.pyÚpytest_configure   s    r   Fc          	   k   si   d d l  m } m } | s" i  n | } | d d d |  d | | � } | | d | ƒ�
 | VWd QRXd S)	z=Utility context used to setup Celery app for pytest fixtures.é   )ÚTestAppÚsetup_default_appÚset_as_currentFÚenable_loggingr   Úuse_trapN)Útesting.appr   r   )r   r   Ú
parametersr   r   r   Útest_appr   r   r   Ú_create_app    s    	r   ÚscopeÚsessionc               C   s   d S)z¤You can override this fixture to enable the app trap.

    The app trap raises an exception whenever something attempts
    to use the current or default apps.
    Fr   r   r   r   r   Úuse_celery_app_trap5   s    r   c          	   c   s{   |  j  j d ƒ } t | | r' | j n i  � } t d | d | d | | � �& } | sk | j ƒ  | j ƒ  | VWd QRXd S)z1Session Fixture: Return app for session fixtures.Úceleryr   r   r   N)ÚnodeÚget_closest_markerÚdictÚkwargsr   Úset_defaultÚset_current)ÚrequestÚcelery_configÚcelery_parametersÚcelery_enable_loggingr   Úmarkr   Úappr   r   r   Úcelery_session_app@   s    

r,   c       
   	   c   s€   d d l  m } t s| x | D] } | j j | ƒ q Wx | D] } | j | ƒ q> W| j | d | | �� }	 |	 VWd QRXd S)z?Session Fixture: Start worker that lives throughout test suite.r   )ÚworkerÚpoolN)Útestingr-   r   ÚloaderÚimport_task_moduleÚregister_taskÚstart_worker)
r&   r,   Úcelery_includesÚcelery_class_tasksÚcelery_worker_poolÚcelery_worker_parametersr-   ÚmoduleÚ
class_taskÚwr   r   r   Úcelery_session_workerT   s    r;   c               C   s   d S)z0You can override this fixture to enable logging.Fr   r   r   r   r   r)   l   s    r)   c               C   s   f  S)zÆYou can override this include modules when a worker start.

    You can have this return a list of module names to import,
    these can be task modules, modules registering signals, and so on.
    r   r   r   r   r   r4   s   s    r4   c               C   s   d S)z–You can override this fixture to set the worker pool.

    The "solo" pool is used by default, but you can set this to
    return e.g. "prefork".
    Úsolor   r   r   r   r   r6   ~   s    r6   c               C   s   i  S)z¨Redefine this fixture to configure the test Celery app.

    The config returned by your fixture will then be used
    to configure the :func:`celery_app` fixture.
    r   r   r   r   r   r'   ‰   s    r'   c               C   s   i  S)zÃRedefine this fixture to change the init parameters of test Celery app.

    The dict returned by your fixture will then be used
    as parameters when instantiating :class:`~celery.Celery`.
    r   r   r   r   r   r(   ”   s    r(   c               C   s   i  S)a"  Redefine this fixture to change the init parameters of Celery workers.

    This can be used e. g. to define queues the worker will consume tasks from.

    The dict returned by your fixture will then be used
    as parameters when instantiating :class:`~celery.worker.WorkController`.
    r   r   r   r   r   r7   Ÿ   s    
r7   c          	   c   sa   |  j  j d ƒ } t | | r' | j n i  � } t d | d | d | | � � } | VWd QRXd S)z/Fixture creating a Celery application instance.r   r   r   r   N)r    r!   r"   r#   r   )r&   r'   r(   r)   r   r*   r   r+   r   r   r   Ú
celery_app¬   s    r=   c               C   s   g  S)zARedefine this fixture to register tasks with the test Celery app.r   r   r   r   r   r5   ¼   s    r5   c          	   c   sb   d d l  m } t s^ x | D] } | j j | ƒ q W| j | d | | �� } | VWd QRXd S)zAFixture: Start worker in a thread, stop it when the test returns.r   )r-   r.   N)r/   r-   r   r0   r1   r3   )r&   r=   r4   r6   r7   r-   r8   r:   r   r   r   Úcelery_workerÂ   s    r>   c             C   s   |  j  ƒ  d S)z!Fixture that sets app as current.N)r%   )r=   r   r   r   Údepends_on_current_appÕ   s    r?   )#Ú__doc__ÚosÚ
contextlibr   Útypingr   r   r   r   r   Úpytestr   r   r-   r
   ÚobjectÚenvironÚgetr   r   r   Úfixturer   r,   r;   r)   r4   r6   r'   r(   r7   r=   r5   r>   r?   r   r   r   r   Ú<module>   s6   (

