
    f%                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZmZ d d	lmZ g d
Zd Zd Zd Zd Zd Zd Zd Zdeee      fdZ e       dd       Z G d de      Zy)    N)List)Path)search_ancestor)inference_state_method_cache)goto_importload_module_from_path)ParserTreeFilter)	NO_VALUESValueSet)infer_call_of_leaf))_pytestmonkeypatch)r   capture)r   logging)r   tmpdir)r   pytesterc                       fd}|S )Nc                     | j                         dk(  r#| j                  j                         dk(  rt        S  | |      S )Nfixturez_pytest.fixtures)
py__name__parent_contextr
   )value	argumentscallbacks     N/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/plugins/pytest.pywrapperzexecute.<locals>.wrapper   sA     *((3359KKy))     )r   r   s   ` r   executer      s    * Nr   c                      d  fd}|S )Nc                 .   | j                   j                  @| j                         }t        d |D              rt	        j
                  d |D              S |S | j                         }|j                         r|j                         S |j                         S )Nc              3   Z   K   | ]#  }|j                   j                  d       dk(   % yw)Tinclude_module_names)typing	GeneratorN)nameget_qualified_names.0vs     r   	<genexpr>z=infer_anonymous_param.<locals>.get_returns.<locals>.<genexpr>%   s2      $ 66--4-H-. $   )+c              3   Z   K   | ]#  }|j                  d       j                          % yw)__next__N)py__getattribute__execute_annotationr)   s     r   r,   z=infer_anonymous_param.<locals>.get_returns.<locals>.<genexpr>(   s,      * ((4GGI*r-   )
	tree_node
annotationexecute_with_valuesanyr   	from_sets
as_contextis_generatormerge_yield_valuesget_return_values)r   resultfunction_contexts      r   get_returnsz*infer_anonymous_param.<locals>.get_returns"   s    ??%%1..0F $"$ $  )) *#*   M
 !++-((*#6688#5577r   c                     | j                   r |       S t        |       \  }}|rH| j                         }t        || j                  |      }|rt        j                  fd|D              S  |       S )Nskip_own_modulec              3   X   K   | ]!  }|j                         D ]  } |        # y wN)infer)r*   r   r   r=   s      r   r,   z9infer_anonymous_param.<locals>.wrapper.<locals>.<genexpr>G   s9      *!(*   &*&*s   '*)annotation_node _is_a_pytest_param_and_inheritedget_root_context_goto_pytest_fixturestring_namer   r6   )
param_nameis_pytest_paramparam_name_is_function_namemodulefixturesfuncr=   s        r   r   z&infer_anonymous_param.<locals>.wrapper7   s    %%
##,Z8 	54002F+&& !<H )) *#+*  
 Jr   r   )rN   r   r=   s   ` @r   infer_anonymous_paramrO   !   s    8* , Nr   c                       fd}|S )Nc                     t        |       \  }}|r*t        | j                         | j                  |      }|r|S  |       S Nr?   )rE   rG   rF   rH   )rI   rJ   rK   namesrN   s       r   r   z%goto_anonymous_param.<locals>.wrapperQ   sO    ,Z8 	54(++-&& ;E
 Jr   r   rN   r   s   ` r   goto_anonymous_paramrU   P   s      Nr   c                       fd}|S )Nc                     | j                         }t        ||      r2g }t        |      D ]  }|t        |      j	                         z  }  |r|S  | ||      S rB   )rF   _is_pytest_func_iter_pytest_modulesFixtureFiltervalues)context	func_namedecorator_nodesmodule_contextrS   rN   s        r   r   z%complete_param_names.<locals>.wrappera   se     1139o6E"6~"F @~6==??@GY88r   r   rT   s   ` r   complete_param_namesr`   `   s    9 Nr   c                 h    t        | |      D ]"  } t        |       j                  |      }|s |c S  y rR   )rY   rZ   get)r_   r'   r@   rS   s       r   rG   rG   m   s5    .~_ n-11$7Lr   c                     t        | j                  d      }|y|j                         }t        |j                  j
                  |      |j                  j
                  | j                  k(  fS )z
    Pytest params are either in a `test_*` function or have a pytest fixture
    with the decorator @pytest.fixture.

    This is a heuristic and will work in most cases.
    funcdef)FF)r   	tree_nameget_decoratorsrX   r'   r   rH   )rI   rd   
decoratorss      r   rE   rE   t   sb     j22I>G'')J7<<--z:j4445 5r   c                 L    | j                  d      xs t        d |D              S )Ntestc              3   @   K   | ]  }d |j                         v   yw)r   N)get_code)r*   ns     r   r,   z"_is_pytest_func.<locals>.<genexpr>   s     BQyAJJL(Bs   )
startswithr5   )r]   r^   s     r   rX   rX      s*    ' CB/BBCr   returnc                  n   t         j                  dk\  rddlm}  t         j                  dk\  r
 | d      }n |        j	                  dd      }t         j                  dk\  r)|D cg c]  }|j
                  j                  d	       c}S |D cg c]'  }|j                  j                  |j                        ) }}|D cg c]%  }|s|j                  d
      j                  d	      ' c}S ddlm}  |d      D cg c]  }|j                  j                  d	       c}S c c}w c c}w c c}w c c}w )z
    Finds pytest plugin modules hooked by setuptools entry points

    See https://docs.pytest.org/en/stable/how-to/writing_plugins.html#setuptools-entry-points
    )      r   )entry_points)rp   
   pytest11)groupr   )rp   	   .rL   )iter_entry_points)sysversion_infoimportlib.metadatarr   rb   rL   splitpatternmatchr   ru   pkg_resourcesrx   module_name)rr   pytest_entry_pointsepmatchesxrx   s         r   _find_pytest_plugin_modulesr      s    6!3w&".Z"@".."4"4Z"Dv%3FGRBIIOOC(GG . 

  *G  ;BGQQAGGH%++C0GG 	44EJ4WXb$$S)XX H H Ys   %"D#,D( D-"D->"D2c              #     K   |s|  | j                         j                  }||j                         | j                  j	                         }d }t        fd|D              rj                  d      }t        |j                        | j                         k7  r)	 t        | j                  |      }|j                          j                         |j                  |j                  k(  rn}t        fd|D              rt        t               z   D ]4  }| j                  j                  |      D ]  }|j                           6 y # t        $ r Y w xY ww)Nc              3   T   K   | ]  }j                   j                  |       ! y wrB   )pathrm   )r*   pfolders     r   r,   z'_iter_pytest_modules.<locals>.<genexpr>   s      >&++((+>s   %(zconftest.py)	get_valuefile_ioget_parent_folderinference_stateget_sys_pathr5   get_file_ior   r   
py__file__r   r7   FileNotFoundError_PYTEST_FIXTURE_MODULESr   import_module)	r_   r@   r   sys_pathlast_foldermrS   module_valuer   s	           @r   rY   rY      sK    &&(00G**,!11>>@ >X>>((7GGLL!^%>%>%@@-n.L.LgVA,,.( --/F &6;;+:J:J+J K >X>> )+F+HH ,*::HHO 	,L))++	,, ) s2   BE!(E AE!	A	E!	EE!EE!c                   $     e Zd Z fdZd Z xZS )rZ   c              #      K   t            |      D ]l  }|j                  j                  dk(  r0t	         j
                  |      }t         fd|D              sG| L j                   j
                  |      si| n y w)Nimport_fromc              3      K   | ]6  }|j                   r(j                  |j                  |j                          8 y wrB   )re   _is_fixturer   )r*   inameselfs     r   r,   z(FixtureFilter._filter.<locals>.<genexpr>   s7       $$U%9%95??Ks   <?)super_filterparenttyper   r   r5   r   )r   rS   r'   imported_names	__class__s   `   r   r   zFixtureFilter._filter   sz     GOE* 	D{{=0!,T-@-@$!G !/  J!!$"5"5t<
	s   AB!B=Bc                 >   |j                   }|j                  dk7  ry|j                   }|j                  dk7  ry|j                  d   }|j                  dk(  r|j                  }n|g}|D ]  }|j                  d   }d|j                         v s%|j                  dk(  rE|j                  d	   }|j	                         }	|	d
k(  rt        ||	d      }
n#|j                  |      }
n|j                  |      }
|
D ]$  }|j                  j                  d      dk(  s#  y  y)Nrd   F	decoratedr   rg      r   	atom_expr)T)cut_own_trailerr#   )r   rM   r   )	r   r   childrenrk   get_last_leafr   
infer_noder'   r(   )r   r\   r'   rd   r   rg   	decoratordotted_namelast_trailer	last_leafr[   r   s               r   r   zFixtureFilter._is_fixture   s.   ++<<9$NN	>>[(''*
??l*#,,J$J# 	$I#,,Q/KK0022##{2 $/#7#7#;L , : : <I C'!3#Y" ")!3!3K!@$//<F# $Ezz5545PAB#$#	$* r   )__name__
__module____qualname__r   r   __classcell__)r   s   @r   rZ   rZ      s     "r   rZ   )F)ry   r%   r   pathlibr   
parso.treer   jedi.inference.cacher   jedi.inference.importsr   r   jedi.inference.filtersr	   jedi.inference.base_valuer
   r   jedi.inference.helpersr   r   r   rO   rU   r`   rG   rE   rX   strr   rY   rZ   r   r   r   <module>r      s    
   & = E 3 9 5 	,^ 
5C
YT$s)_ Y< ,  ,@3$ 3r   