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