o
    8ck                     @   s0   d dl Z dd Zdd ZdddZdd
dZdS )    Nc                     s`   ddl m} t  | D ]} | qt  |j fdd| D ddt   d dS )	a  A facade around @testing.combinations() oriented towards boolean
    keyword-based arguments.

    Basically generates a nice looking identifier based on the keywords
    and also sets up the argument names.

    E.g.::

        @testing.flag_combinations(
            dict(lazy=False, passive=False),
            dict(lazy=True, passive=False),
            dict(lazy=False, passive=True),
            dict(lazy=False, passive=True, raiseload=True),
        )


    would result in::

        @testing.combinations(
            ('', False, False, False),
            ('lazy', True, False, False),
            ('lazy_passive', True, True, False),
            ('lazy_passive', True, True, True),
            id_='iaaa',
            argnames='lazy,passive,raiseload'
        )

    r   configc                    s<   g | ] d   fddD ft fddD  qS )_c                 3   s     | ]}  |d r|V  qdS FNget.0kd J/var/www/html/gps/gps/lib/python3.10/site-packages/alembic/testing/util.py	<genexpr>3   s    z/flag_combinations.<locals>.<listcomp>.<genexpr>c                 3   s    | ]	}  |d V  qdS r   r   r   r   r   r   r   4   s    )jointuple)r	   keysr   r   
<listcomp>2   s    z%flag_combinations.<locals>.<listcomp>ia,)id_argnames)sqlalchemy.testingr   setupdatesortedcombinationslenr   )r   r   r   r   r   r   flag_combinations   s   
r    c                 K   s(   t | j}|| t| j|}| S )zGiven a no-arg lambda and a namespace, return a new lambda that
    has all the values filled in.

    This is used so that we can have module-level fixtures that
    refer to instance-level variables using lambdas.

    )dict__globals__r   typesFunctionType__code__)__fnkwglbnew_fnr   r   r   resolve_lambda<   s   
	
r*   functionc                    s,   ddl m  ddlm  fdd}|S )z&Provide MetaData for a pytest fixture.r   r      )fixture_functionsc                    s    fdd}j d|S )Nc              	   3   sZ    ddl m} |  }| _z| |}| j |V  W | j d S | j w )Nr   )schema)
sqlalchemyr.   MetaDatametadata
create_alldbdrop_all)selfr.   r1   result)r   fnr   r   run_ddlR   s   
z3metadata_fixture.<locals>.decorate.<locals>.run_ddl)scope)fixture)r7   r8   r   ddlr-   )r7   r   decorateQ   s   z"metadata_fixture.<locals>.decorate)r   r    r-   )r<   r=   r   r;   r   metadata_fixtureK   s   r?   Fc                 C   sN   ddl m} ddlm} |st|jjdd}|rd|ini }|| |fi |S )Nr   r   )testing_enginefuture_engineFfuture)r   r   sqlalchemy.testing.enginesr@   getattr_currentoptions)urlrF   rB   r   r@   r'   r   r   r   r@   d   s   r@   )r+   )NNF)r#   r    r*   r?   r@   r   r   r   r   <module>   s
   1
