
    Mhc(                        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d Z G d de          ZdS )    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                     |                                  dk    r$| j                                         dk    rt          S  | |          S )Nfixturez_pytest.fixtures)
py__name__parent_contextr
   )value	argumentscallbacks     S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jedi/plugins/pytest.pywrapperzexecute.<locals>.wrapper   sO     **(33559KKKxy)))     )r   r   s   ` r   executer      s#    * * * * * Nr   c                      d  fd}|S )Nc                 T   | j         j        M|                                 }t          d |D                       rt	          j        d |D                       S |S |                                 }|                                r|                                S |	                                S )Nc              3   T   K   | ]#}|j                             d           dk    V  $dS )Tinclude_module_names)typing	GeneratorN)nameget_qualified_names.0vs     r   	<genexpr>z=infer_anonymous_param.<locals>.get_returns.<locals>.<genexpr>%   sQ       $ $ 6--4-HH-. $ $ $ $ $ $r   c              3   d   K   | ]+}|                     d                                           V  ,dS )__next__N)py__getattribute__execute_annotationr)   s     r   r,   z=infer_anonymous_param.<locals>.get_returns.<locals>.<genexpr>(   sP       * * ((44GGI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..00F $ $"$ $ $ $ $   ) * *#* * *    M
 !++--((** 	8#66888#55777r   c                     | j         r |           S t          |           \  }}|rM|                                 }t          || j        |          }|r t          j        fd|D                       S  |           S )Nskip_own_modulec              3   \   K   | ]&}|                                 D ]} |          V  'd S N)infer)r*   r   r   r<   s      r   r,   z9infer_anonymous_param.<locals>.wrapper.<locals>.<genexpr>G   s`       * *!(* *   K&&* * * * * * *r   )annotation_node _is_a_pytest_param_and_inheritedget_root_context_goto_pytest_fixturestring_namer   r5   )
param_nameis_pytest_paramparam_name_is_function_namemodulefixturesfuncr<   s        r   r   z&infer_anonymous_param.<locals>.wrapper7   s    % 	$4
###,Z88 	54 	0022F+& !<  H  ) * * * *#+* * *   
 tJr   r   )rM   r   r<   s   ` @r   infer_anonymous_paramrN   !   s8    8 8 8*           , Nr   c                       fd}|S )Nc                     t          |           \  }}|r-t          |                                 | j        |          }|r|S  |           S Nr>   )rD   rF   rE   rG   )rH   rI   rJ   namesrM   s       r   r   z%goto_anonymous_param.<locals>.wrapperQ   sk    ,Z88 	54 	(++--& ;  E
  tJr   r   rM   r   s   ` r   goto_anonymous_paramrT   P   s#              Nr   c                       fd}|S )Nc                     |                                  }t          ||          r<g }t          |          D ]&}|t          |                                          z  }'|r|S  | ||          S rA   )rE   _is_pytest_func_iter_pytest_modulesFixtureFiltervalues)context	func_namedecorator_nodesmodule_contextrR   rM   s        r   r   z%complete_param_names.<locals>.wrappera   s     11339o66 	E"6~"F"F @ @~66==??? tGY888r   r   rS   s   ` r   complete_param_namesr_   `   s#    9 9 9 9 9 Nr   c                 ~    t          | |          D ]*} t          |                               |          }|r|c S +d S rQ   )rX   rY   get)r^   r'   r?   rR   s       r   rF   rF   m   sY    .~___  n--11$77 	LLL	 r   c                     t          | j        d          }|dS |                                }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.
    funcdefN)FF)r   	tree_nameget_decoratorsrW   r'   r   rG   )rH   rc   
decoratorss      r   rD   rD   t   s]     j2I>>G|''))J7<-z::j445 5r   c                 ^    |                      d          pt          d |D                       S )Ntestc              3   B   K   | ]}d |                                 v V  dS )r   N)get_code)r*   ns     r   r,   z"_is_pytest_func.<locals>.<genexpr>   s/      BBQyAJJLL(BBBBBBr   )
startswithr4   )r\   r]   s     r   rW   rW      s9    '' CBB/BBBBBCr   returnc                  D   t           j        dk    ruddlm}  t           j        dk    r | d          }n |                                 dd          }t           j        dk    rd	 |D             S d
 |D             }d |D             S ddlm} d  |d          D             S )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)ro   
   pytest11)groupr   )ro   	   c                 B    g | ]}|j                             d           S .)rK   splitr*   eps     r   
<listcomp>z/_find_pytest_plugin_modules.<locals>.<listcomp>   s&    GGGRBIOOC((GGGr   c                 L    g | ]!}|j                             |j                  "S r   )patternmatchr   rz   s     r   r|   z/_find_pytest_plugin_modules.<locals>.<listcomp>   s:        
  **  r   c                 b    g | ],}||                     d                               d          -S )rK   rx   )rt   ry   )r*   xs     r   r|   z/_find_pytest_plugin_modules.<locals>.<listcomp>   s7    GGGQQGAGGH%%++C00GGGr   )iter_entry_pointsc                 B    g | ]}|j                             d           S rw   )module_namery   rz   s     r   r|   z/_find_pytest_plugin_modules.<locals>.<listcomp>   s(    XXXb$$S))XXXr   )sysversion_infoimportlib.metadatarq   ra   pkg_resourcesr   )rq   pytest_entry_pointsmatchesr   s       r   _find_pytest_plugin_modulesr      s     6!!333333w&&".,Z"@"@"@".,.."4"4Z"D"Dv%%GG3FGGGG -  G HG'GGGG 	433333XX4E4EJ4W4W4WXXXXr   Fc              #     K   |s| V  |                                  j        }|m|                                | j                                        }d }t          fd|D                       r"                    d          }t          |j                  | 	                                k    r	 t          | j        |          }|                                }|V  |j                                                            d          }|r1|                    |d                   }t!          | |          E d {V  n# t"          $ r Y nw xY w                                |j        |j        k    rn}t          fd|D                       "t$          t'                      z   D ]5}	| j                            |	          D ]}
|
                                V  6d S )Nc              3   L   K   | ]}j                             |          V  d S rA   )pathrl   )r*   pfolders     r   r,   z'_iter_pytest_modules.<locals>.<genexpr>   s3      >>&+((++>>>>>>r   zconftest.pypytest_pluginsr   )	get_valuefile_ioget_parent_folderinference_stateget_sys_pathr4   get_file_ior   r   
py__file__r   r6   r1   get_used_namesra   create_name_load_pytest_pluginsFileNotFoundError_PYTEST_FIXTURE_MODULESr   import_module)r^   r?   r   sys_pathlast_foldermconftest_moduleplugins_listr'   rR   module_valuer   s              @r   rX   rX      s-      &&((0G**,,!1>>@@ >>>>X>>>>> 	!((77GGL!!^%>%>%@%@@@
-n.LgVVA&'llnnO))))#$;#=#=#?#?#C#CDT#U#UL# N.::<?KK#7#M#MMMMMMMM(   D--//F &6;+:J+J+J K' >>>>X>>>>> 	!* )+F+H+HH , ,*:HHOO 	, 	,L))++++++	,, ,s   1BD> >
E
Ec              #   J  K   ddl m} |                                D ]}|                                D ]n}|                                D ]W} ||          }|rH|                    d          }| j                            |          D ]}|                                V  Xod S )Nr   )get_str_or_nonerx   )jedi.inference.helpersr   rB   
py__iter__ry   r   r   r6   )	r^   r'   r   inferred	seq_valuer   fq_namerR   r   s	            r   r   r      s      666666JJLL 8 8!,,.. 	8 	8I"** 8 8)/%00 8#MM#..E(6(F(T(TUZ([([ 8 8*557777778	88 8r   c                   $     e Zd Z fdZd Z xZS )rY   c              #      K   t                                          |          D ]f}|j        j        dk    r5t	           j        |          }t           fd|D                       r|V  G                      j        |          r|V  gd S )Nimport_fromc              3   f   K   | ]+}|j         	                    |j        |j                   V  ,d S rA   )rd   _is_fixturer   )r*   inameselfs     r   r,   z(FixtureFilter._filter.<locals>.<genexpr>   sT        	$$U%95?KK     r   )super_filterparenttyper   r   r4   r   )r   rR   r'   imported_names	__class__s   `   r   r   zFixtureFilter._filter   s      GGOOE** 	 	D{=00!,T-@$!G!G    !/      JJJ!!$"5t<< 


	 	r   c                    |j         }|j        dk    rdS |j         }|j        dk    rdS |j        d         }|j        dk    r|j        }n|g}|D ]}|j        d         }d|                                v r|j        dk    rP|j        d	         }|                                }	|	d
k    rt          ||	d          }
n+|                    |          }
n|                    |          }
|
D ]%}|j                            d          dk    r  dS &dS )Nrc   F	decoratedr   rf      r   	atom_expr)T)cut_own_trailerr#   )r   rL   r   )	r   r   childrenrj   get_last_leafr   
infer_noder'   r(   )r   r[   r'   rc   r   rf   	decoratordotted_namelast_trailer	last_leafrZ   r   s               r   r   zFixtureFilter._is_fixture   s]   +<9$$5N	>[((5'*
?l**#,JJ$J# 	$ 	$I#,Q/KK002222#{22 $/#7#;L , : : < <I C''!3#Y" " " ")!3!3K!@!@$//<<F# $ $Ez5545PPAB B#tttB ur   )__name__
__module____qualname__r   r   __classcell__)r   s   @r   rY   rY      sG             " " " " " " "r   rY   )F) r   r%   r   pathlibr   
parso.treer   jedi.inference.cacher   jedi.inference.importsr   r   jedi.inference.filtersr	   jedi.inference.base_valuer
   r   r   r   r   r   rN   rT   r_   rF   rD   rW   strr   rX   r   rY   r   r   r   <module>r      s   



             & & & & & & = = = = = = E E E E E E E E 3 3 3 3 3 3 9 9 9 9 9 9 9 9 5 5 5 5 5 5   	 	 	, , ,^   
 
 
  5 5 5C C C
YT$s)_ Y Y Y Y< #, #, #,  #,L
8 
8 
83 3 3 3 3$ 3 3 3 3 3r   