o
    %Âifá  ã                   @  s@   d dl mZ d dlZd dlmZ ddlmZ G dd„ deƒZdS )é    )ÚannotationsN)ÚProduceré   )ÚLoadScopeSchedulingc                      s.   e Zd ZdZdd‡ fd	d
„Zddd„Z‡  ZS )ÚLoadGroupSchedulingzóImplement load scheduling across nodes, but grouping test by xdist_group mark.

    This class behaves very much like LoadScopeScheduling, but it groups tests by xdist_group mark
    instead of the module or class to which they belong to.
    NÚconfigúpytest.ConfigÚlogúProducer | NoneÚreturnÚNonec                   s0   t ƒ  ||¡ |d u rtdƒ| _d S |j| _d S )NÚloadgroupsched)ÚsuperÚ__init__r   r	   r   )Úselfr   r	   ©Ú	__class__© úR/var/www/html/corbot_env/lib/python3.10/site-packages/xdist/scheduler/loadgroup.pyr      s   zLoadGroupScheduling.__init__ÚnodeidÚstrc                 C  s&   |  d¡|  d¡kr| d¡d S |S )a  Determine the scope (grouping) of a nodeid.

        There are usually 3 cases for a nodeid::

            example/loadsuite/test/test_beta.py::test_beta0
            example/loadsuite/test/test_delta.py::Delta1::test_delta0
            example/loadsuite/epsilon/__init__.py::epsilon.epsilon

        #. Function in a test module.
        #. Method of a class in a test module.
        #. Doctest in a function in a package.

        With loadgroup, two cases are added::

            example/loadsuite/test/test_beta.py::test_beta0
            example/loadsuite/test/test_delta.py::Delta1::test_delta0
            example/loadsuite/epsilon/__init__.py::epsilon.epsilon
            example/loadsuite/test/test_gamma.py::test_beta0@gname
            example/loadsuite/test/test_delta.py::Gamma1::test_gamma0@gname

        This function will group tests with the scope determined by splitting the first ``@``
        from the right. That is, test will be grouped in a single work unit when they have
        same group name. In the above example, scopes will be::

            example/loadsuite/test/test_beta.py::test_beta0
            example/loadsuite/test/test_delta.py::Delta1::test_delta0
            example/loadsuite/epsilon/__init__.py::epsilon.epsilon
            gname
            gname
        ú@ú]éÿÿÿÿ)ÚrfindÚsplit)r   r   r   r   r   Ú_split_scope   s   z LoadGroupScheduling._split_scope)N)r   r   r	   r
   r   r   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   r   r   r   
   s    r   )Ú
__future__r   ÚpytestÚxdist.remoter   Ú	loadscoper   r   r   r   r   r   Ú<module>   s
    