File: //usr/local/lib/python3.9/site-packages/celery/contrib/__pycache__/pytest.cpython-39.pyc
a
X>hb � @ s� d Z ddlZddlmZ ddlmZmZmZmZm Z ddl
Z
erZddlmZ ddl
mZ ne ZZej�d�Zd d
� Zed*dd
��Ze
jdd�dd� �Ze
jdd�dd� �Ze
jdd�dd� �Ze
jdd�dd� �Ze
jdd�dd� �Ze
jdd�dd� �Ze
jdd�dd� �Ze
jdd�dd� �Ze
jdd�d d!� �Ze
�� d"d#� �Ze
jdd�d$d%� �Z e
�� d&d'� �Z!e
�� d(d)� �Z"dS )+z;Fixtures and testing utilities for :pypi:`pytest <pytest>`.� N)�contextmanager)�
TYPE_CHECKING�Any�Mapping�Sequence�Union)�Celery� )�WorkController� NO_WORKERc C s | � dd� dS )z)Register additional pytest configuration.�markerszBcelery(**overrides): override celery configuration for a test caseN)Zaddinivalue_line)�config� r �?/usr/local/lib/python3.9/site-packages/celery/contrib/pytest.py�pytest_configure s �r Fc k sh ddl m}m} |si n|}|f d| |d�|��}|||d�� |V W d � n1 sZ0 Y dS )z=Utility context used to setup Celery app for pytest fixtures.� )�TestApp�setup_default_appF)Zset_as_current�enable_loggingr
)�use_trapN)Ztesting.appr r )r r �
parametersr
r r Ztest_appr r r �_create_app s ��r �session)Zscopec C s dS )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 sz | j �d�}t|fi |r|jni ��}tf |||d�|���*}|sR|�� |�� |V W d � n1 sl0 Y dS )z1Session Fixture: Return app for session fixtures.�celery�r r r N)�node�get_closest_marker�dict�kwargsr �set_default�set_current��request�
celery_config�celery_parameters�celery_enable_loggingr �markr
Zappr r r �celery_session_app@ s ��r( c
c sz ddl m} tsv|D ]}|j�|� q|D ]}|�|� q*|j|fd|i|���} | V W d � n1 sl0 Y dS )z?Session Fixture: Start worker that lives throughout test suite.r ��worker�poolN)�testingr* r �loader�import_task_moduleZ
register_task�start_worker)
r# r( �celery_includes�celery_class_tasks�celery_worker_pool�celery_worker_parametersr* �moduleZ
class_task�wr r r �celery_session_workerT s
��r6 c C s dS )z0You can override this fixture to enable logging.Fr r r r r r&