
    +h                         d Z ddlZ ej                  e      Z ej                  d       Z ej                  d       Zg Zg Zd Z	d Z
d Zd Zd	 Zd
 Zy)a  
invent a quick version of pytest autouse fixtures as pytest's unacceptably slow
collection/high memory use in pytest 4.6.11, which is the highest version that
works in py2k.

by "too-slow" we mean the test suite can't even manage to be collected for a
single process in less than 70 seconds or so and memory use seems to be very
high as well.   for two or four workers the job just times out after ten
minutes.

so instead we have invented a very limited form of these fixtures, as our
current use of "autouse" fixtures are limited to those in fixtures.py.

assumptions for these fixtures:

1. we are only using "function" or "class" scope

2. the functions must be associated with a test class

3. the fixture functions cannot themselves use pytest fixtures

4. the fixture functions must use yield, not return

When py2k support is removed and we can stay on a modern pytest version, this
can all be removed.


    Nc                  4    t        j                  t              S Ncollectionsdefaultdictset     c/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/testing/plugin/reinvent_fixtures_py2k.py<lambda>r   "       K##C( r
   c                  4    t        j                  t              S r   r   r	   r
   r   r   r   %   r   r
   c                     |j                   dv sJ t        | j                     j                  | |j                   f       y )N)classfunction)scope_py2k_fixture_fn_names__name__add)fnfixtures     r   add_fixturer   ,   s5    ==11112;;'++R,?@r
   c                    | j                   j                   j                  }t        D ]  }t        |   D ]  \  }}t        ||d       }|s|j                  |u s%|j
                  D ]S  }||j                  v s|dk(  rt        |   |   j                  |       n |dk(  rt        |   |   j                  |        n    y )Nr   r   )
parentobjr   getattrim_func__mro____dict___py2k_class_fixturesr   _py2k_function_fixtures)item
test_classname
fixture_fnr   methsups          r   "scan_for_fixtures_to_use_for_classr(   1   s    ##''J& !7!= 
	J:tT2D
2%-- Cs||+ G+0<SAEEdK"j03J?DHHN 
	r
   c                    | j                   }|j                  |      }t        j                  |      }|rQ|j                  D ]A  }|j                  |d      D ]*  } ||      }t        |       t        j                  |       , C y y Nr	   )cls__new__r    getr   next_py2k_cls_fixture_stackappendrequestr+   selffixtures_for_this_classsup_r   iter_s          r   run_class_fixture_setupr7   B   s    
++C;;sD266s;KK 	6D-11$; 64U'..u5	6	6 r
   c                     t         r)t         j                  d      }	 t        |       t         r(y y # t        $ r Y w xY wN)r/   popr.   StopIterationr2   r6   s     r   run_class_fixture_teardownr>   R   s=    
!'++B/	K "
!  		   1 	==c                    | j                   }| j                  }t        j                  |      }|rZt	        |j
                        D ]A  }|j                  |d      D ]*  } ||      }t        |       t        j                  |       , C y y r*   )	r+   instancer!   r-   reversedr   r.   _py2k_fn_fixture_stackr0   r1   s          r   run_fn_fixture_setuprD   [   s    
++CD599#>S[[) 	5D-11$; 54U&--e4	5	5 r
   c                     t         r)t         j                  d      }	 t        |       t         r(y y # t        $ r Y w xY wr9   )rC   r;   r.   r<   r=   s     r   run_fn_fixture_teardownrF   j   s=    
 &**2.	K !
   		r?   )__doc__r   r   r   r   r    r!   r/   rC   r   r(   r7   r>   rD   rF   r	   r
   r   <module>rH      s   8  1005 .{..(  2+11(    A
"6 5r
   