Format: application/x-python-code
⬇ Download File (8.1 KB)
   1  o
   2  
   3  �hc(�@s�ddlZddlmZddlmZddlmZddlmZddl	m
   4  Z
   5  mZddlm
   6  Z
   7  ddlmZmZdd	lmZgd
   8  �Zdd�Zd
   9  d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdeeefdd�Ze�d#dd��Zdd �ZGd!d"�d"e
  10  �ZdS)$�N)�List)�Path)�search_ancestor)�inference_state_method_cache)�goto_import�load_module_from_path)�ParserTreeFilter)�	NO_VALUES�ValueSet)�infer_call_of_leaf))�_pytestZmonkeypatch)r�capture)r�logging)rZtmpdir)rZpytesterc��fdd�}|S)Ncs(|��dkr|j��dkrtS�||�S)N�fixturez_pytest.fixtures)Z
  11  py__name__�parent_contextr	)�value�	arguments��callback��Ic:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/plugins/pytest.py�wrappers
  12  zexecute.<locals>.wrapperr)rrrrr�executesrcsdd����fdd�}|S)NcSs^|jjdur|��}tdd�|D��rt�dd�|D��S|S|��}|��r+|��S|�	�S)Ncss"�|]}|jjdd�dkVqdS)T�Zinclude_module_names)�typing�	GeneratorN)�name�get_qualified_names��.0�vrrr�	<genexpr>%s���z=infer_anonymous_param.<locals>.get_returns.<locals>.<genexpr>css�|]
  13  }|�d���VqdS)�__next__N)Zpy__getattribute__Zexecute_annotationrrrrr"(s
  14  ��
  15  �)
  16  �	tree_node�
  17  annotationZexecute_with_values�anyr
  18  �	from_sets�
  19  as_contextZis_generatorZmerge_yield_valuesZget_return_values)r�resultZfunction_contextrrr�get_returns"s�
  20  �z*infer_anonymous_param.<locals>.get_returnscsZ|jr�|�St|�\}}|r)|��}t||j|d�}|r)t��fdd�|D��S�|�S)N��skip_own_modulec3s&�|]}|��D]}�|�VqqdS�N)�infer)r rr)r*rrr"Gs����z9infer_anonymous_param.<locals>.wrapper.<locals>.<genexpr>)Zannotation_node� _is_a_pytest_param_and_inherited�get_root_context�_goto_pytest_fixture�string_namer
  21  r')�
  22  param_name�is_pytest_param�param_name_is_function_name�module�fixtures��funcr*rrr7s ���z&infer_anonymous_param.<locals>.wrapperr�r9rrr8r�infer_anonymous_param!sr;cr)Ncs4t|�\}}|rt|��|j|d�}|r|S�|�S�Nr+)r/r1r0r2)r3r4r5�names�r9rrrQs��z%goto_anonymous_param.<locals>.wrapperrr:rr>r�goto_anonymous_paramPsr?cr)NcsH|��}t||�rg}t|�D]
  23  }|t|���7}q|r|S�|||�Sr-)r0�_is_pytest_func�_iter_pytest_modules�
  24  FixtureFilter�values)�context�	func_name�decorator_nodes�module_contextr=r>rrras
  25  z%complete_param_names.<locals>.wrapperrr:rr>r�complete_param_names`s	rHcCs0t||d�D]}t|��|�}|r|SqdSr<)rArB�get)rGrr,r=rrrr1ms��r1cCs<t|jd�}|durdS|��}t|jj|�|jj|jkfS)z�
  26      Pytest params are either in a `test_*` function or have a pytest fixture
  27      with the decorator @pytest.fixture.
  28  
  29      This is a heuristic and will work in most cases.
  30      �funcdefN)FF)r�	tree_nameZget_decoratorsr@rrr2)r3rJ�
  31  decoratorsrrrr/ts�r/cCs|�d�p
  32  tdd�|D��S)N�testcss�|]	}d|��vVqdS)rN)�get_code)r �nrrrr"���z"_is_pytest_func.<locals>.<genexpr>)�
  33  startswithr&)rErFrrrr@�s
  34  �r@�returncCs�tjdkr7ddlm}tjdkr|dd�}n|��dd�}tjdkr)d	d
  35  �|D�Sdd
  36  �|D�}dd
  37  �|D�Sdd
  38  lm}dd
  39  �|dd�D�S)z�
  40      Finds pytest plugin modules hooked by setuptools entry points
  41  
  42      See https://docs.pytest.org/en/stable/how-to/writing_plugins.html#setuptools-entry-points
  43      )��r)�entry_points)rS�
  44  Zpytest11)�groupr)rS�	cS�g|]}|j�d��qS��.)r6�split�r �eprrr�
  45  <listcomp>��z/_find_pytest_plugin_modules.<locals>.<listcomp>cSsg|]	}|j�|j��qSr)�pattern�matchrr]rrrr_�s��cSs g|]}|r|�d��d��qS)r6r[)rWr\)r �xrrrr_�s )�iter_entry_pointscSrYrZ)�module_namer\r]rrrr_�r`)�sys�version_info�importlib.metadatarUrI�
  46  pkg_resourcesrd)rUZpytest_entry_points�matchesrdrrr�_find_pytest_plugin_modules�s
  47  
  48  
  49  �rkFc#s2�|s|V|��j}|dur�|���|j��}d}t�fdd�|D��r���d�}t|j�|�	�krez(t
  50  |j|�}|��}|V|j�
  51  ��d�}|rZ|�|d�}t||�EdHWn	tydYnw����|durt�j|jkrtn
  52  �}t�fdd�|D��s%tt�D]}	|j�|	�D]}
  53  |
  54  ��Vq�q�dS)Nc3s�|]	}�j�|�VqdSr-)�pathrQ)r �p��folderrrr"�rPz'_iter_pytest_modules.<locals>.<genexpr>zconftest.pyZpytest_pluginsr)�	get_value�file_ioZget_parent_folder�inference_stateZget_sys_pathr&Zget_file_iorrlZ
  55  py__file__rr(r$Zget_used_namesrIZcreate_name�_load_pytest_plugins�FileNotFoundError�_PYTEST_FIXTURE_MODULESrk�
  56  import_module)rGr,rq�sys_pathZlast_folder�mZconftest_moduleZplugins_listrr=�module_valuerrnrrA�sB�
  57  
  58  
  59  �����rAc	csn�ddlm}|��D])}|��D]"}|��D]}||�}|r2|�d�}|j�|�D]}|��Vq*qqqdS)Nr)�get_str_or_noner[)�jedi.inference.helpersrzr.Z
  60  py__iter__r\rrrvr()	rGrrz�inferredZ	seq_valuerZfq_namer=ryrrrrs�s�
  61  ����rscs$eZdZ�fdd�Zdd�Z�ZS)rBc#sb�t��|�D]'}|jjdkr$t�j|�}t�fdd�|D��r#|Vq���j|�r.|VqdS)NZimport_fromc3s&�|]}|jr��|j|j�VqdSr-)rK�_is_fixturer)r Ziname��selfrrr"�s��
  62  �z(FixtureFilter._filter.<locals>.<genexpr>)�super�_filter�parent�typerrr&r})rr=rZimported_names��	__class__r~rr��s�����zFixtureFilter._filtercCs�|j}|jdkr
  63  dS|j}|jdkrdS|jd}|jdkr"|j}n|g}|D]D}|jd}d|��vrk|jdkrT|jd	}|��}	|	d
  64  krNt||	dd�}
  65  n|�|�}
  66  n|�|�}
  67  |
  68  D]}|jjdd
  69  �dkrjdSq[q'dS)NrJF�	decoratedrrL�rZ	atom_expr������)T)Zcut_own_trailerr)rr7r)	r�r��childrenrNZ
  70  get_last_leafrZ
  71  infer_noderr)rrDrrJr�rL�	decoratorZdotted_nameZlast_trailerZ	last_leafrCrrrrr}�s<
  72  
  73  
  74  
  75  
  76  
  77  
  78  �
  79  ���zFixtureFilter._is_fixture)�__name__�
  80  __module__�__qualname__r�r}�
  81  __classcell__rrr�rrB�srB)F) rfrr�pathlibrZ
  82  parso.treerZjedi.inference.cacherZjedi.inference.importsrrZjedi.inference.filtersrZjedi.inference.base_valuer	r
  83  r{rrurr;r?rHr1r/r@�strrkrArsrBrrrr�<module>s,	/
  84  &
  85