mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Make goto work for pytest fixtures
This commit is contained in:
@@ -483,6 +483,10 @@ class _ActualTreeParamName(BaseTreeParamName):
|
|||||||
|
|
||||||
|
|
||||||
class AnonymousParamName(_ActualTreeParamName):
|
class AnonymousParamName(_ActualTreeParamName):
|
||||||
|
@plugin_manager.decorate(name='goto_anonymous_param')
|
||||||
|
def goto(self):
|
||||||
|
return super(AnonymousParamName, self).goto()
|
||||||
|
|
||||||
@plugin_manager.decorate(name='infer_anonymous_param')
|
@plugin_manager.decorate(name='infer_anonymous_param')
|
||||||
def infer(self):
|
def infer(self):
|
||||||
values = super(AnonymousParamName, self).infer()
|
values = super(AnonymousParamName, self).infer()
|
||||||
|
|||||||
@@ -31,16 +31,25 @@ def infer_anonymous_param(func):
|
|||||||
else:
|
else:
|
||||||
return function_context.get_return_values()
|
return function_context.get_return_values()
|
||||||
|
|
||||||
def wrapper(param):
|
def wrapper(param_name):
|
||||||
module = param.get_root_context()
|
module = param_name.get_root_context()
|
||||||
fixtures = _goto_pytest_fixture(module, param.string_name)
|
fixtures = _goto_pytest_fixture(module, param_name.string_name)
|
||||||
if fixtures:
|
if fixtures:
|
||||||
return ValueSet.from_sets(
|
return ValueSet.from_sets(
|
||||||
get_returns(value)
|
get_returns(value)
|
||||||
for fixture in fixtures
|
for fixture in fixtures
|
||||||
for value in fixture.infer()
|
for value in fixture.infer()
|
||||||
)
|
)
|
||||||
return func(param)
|
return func(param_name)
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def goto_anonymous_param(func):
|
||||||
|
def wrapper(param_name):
|
||||||
|
names = _goto_pytest_fixture(param_name.get_root_context(), param_name.string_name)
|
||||||
|
if names:
|
||||||
|
return names
|
||||||
|
return func(param_name)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user