
    ii                       d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZmZ d dlZd dlmZ d dlmZ d dlmZ e
ed         eeej        ged         f         f         Z e	dee         	          Z ej        d
          Z ej        d          Zd"dZ G d d          Ze	 d#ddddd$d            Zeddddd%d            Z	 d#ddddd&d!ZdS )'    )annotationsN)AnyCallableLiteralTypeTypeVarUnioncastoverload)ParameterException)BaseFactory)is_safe_subclass)sessionpackagemoduleclassfunctionT)boundz([A-Z]+)([A-Z][a-z])z([a-z\d])([A-Z])namestrreturnc                    t          j        t          d|           } t          j        t          d|           } |                     dd          } |                                 S )zhFrom inflection.underscore.

    :param name: str: A name.

    :returns: Normalized fixture name.

    z\1_\2-_)resubsplit_pattern_1split_pattern_2replacelower)r   s    q/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/polyfactory/pytest_plugin.py_get_fixture_namer#       sK     6/8T22D6/8T22D<<S!!D::<<    c                  0    e Zd ZdZdZ	 	 	 dddZdddZdS )FactoryFixturez6Decorator that creates a pytest fixture from a factory)autouser   scoper   FNr(   Scoper'   boolr   
str | Noner   Nonec                0    || _         || _        || _        dS )zCreate a factory fixture decorator

        :param scope: Fixture scope
        :param autouse: Autouse the fixture
        :param name: Fixture name
        Nr(   r'   r   )selfr(   r'   r   s       r"   __init__zFactoryFixture.__init__3   s     
			r$      factorytype[T]depthintc                L   t          t                    sj         d}t          |          | j        pt          j                  }t          j        | j        || j	                  }dfd}t          j                    |         d         j        } ||          ||<   S )Nz is not a BaseFactory subclass.)r(   r   r'   r   r3   c                 $    t          d           S )zThe wrapped factoryzType[T])r
   )r2   s   r"   _factory_fixturez1FactoryFixture.__call__.<locals>._factory_fixtureO   s    	7+++r$   r   )r   r3   )r   r   __name__r   r   r#   pytestfixturer(   r'   inspectstack	f_globals)r/   r2   r4   msgfixture_namefixture_registerr8   caller_globalss    `      r"   __call__zFactoryFixture.__call__C   s    55 	*%FFFC$S)))yG$5g6F$G$G!>*L
 
 
	, 	, 	, 	, 	, 	, !/2<'7'78H'I'I|$r$   )r   FN)r(   r)   r'   r*   r   r+   r   r,   )r1   )r2   r3   r4   r5   r   r3   )r9   
__module____qualname____doc__	__slots__r0   rC    r$   r"   r&   r&   .   s\        @@,I "	           r$   r&   r   Fr.   r2   r,   r(   r)   r'   r*   r+   c                   d S NrH   r2   r(   r'   r   s       r"   register_fixturerL   Y   s	     Sr$   r3   c                   d S rJ   rH   rK   s       r"   rL   rL   c   s	     cr$   type[T] | Nonetype[T] | FactoryFixturec               H    t          |||          }| r || d          n|S )a  A decorator that allows registering model factories as fixtures.

    :param factory: An optional factory class to decorate.
    :param scope: Pytest scope.
    :param autouse: Auto use fixture.
    :param name: Fixture name.

    :returns: A fixture factory instance.
    r.      )r4   )r&   )r2   r(   r'   r   factory_fixtures        r"   rL   rL   m   s7      %5'MMMO07L??7!,,,,_Lr$   )r   r   r   r   rJ   )
r2   r,   r(   r)   r'   r*   r   r+   r   r&   )
r2   r3   r(   r)   r'   r*   r   r+   r   r3   )
r2   rN   r(   r)   r'   r*   r   r+   r   rO   )
__future__r   r<   r   typingr   r   r   r   r   r	   r
   r   r:   polyfactory.exceptionsr   polyfactory.factories.baser   polyfactory.utils.predicatesr   r   Configr)   r   compiler   r   r#   r&   rL   rH   r$   r"   <module>rZ      s5   " " " " " "  					 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  5 5 5 5 5 5 2 2 2 2 2 2 9 9 9 9 9 9?@c6=!7+^#__`b	 GC{3'((("*455"*011   ( ( ( ( ( ( ( (V 
      
 
      
 #M M M M M M M M Mr$   