mirror of
https://github.com/davidhalter/jedi.git
synced 2026-10-13 18:18:55 +08:00
Recognize asynchronous pytest fixtures
This commit is contained in:
1 parent
2e3e905707
commit
d8efff8e30
4 files changed
+46
-1
No files matched your search
@@ -71,6 +71,8 @@ Code Contributors
|
|||||||
- Dhanraj E (@Dhanu-dynamic) <dhanraj@labs.digiscrypt.com>
|
- Dhanraj E (@Dhanu-dynamic) <dhanraj@labs.digiscrypt.com>
|
||||||
- Charan Rathore (@charan-rathore)
|
- Charan Rathore (@charan-rathore)
|
||||||
|
|
||||||
|
- Abdullah Ahmed (@abdull-ah-med) (with OpenAI Codex assistance)
|
||||||
|
|
||||||
And a few more "anonymous" contributors.
|
And a few more "anonymous" contributors.
|
||||||
|
|
||||||
Note: (@user) means a github user name.
|
Note: (@user) means a github user name.
|
||||||
@@ -6,6 +6,7 @@ Changelog
|
|||||||
Unreleased
|
Unreleased
|
||||||
++++++++++
|
++++++++++
|
||||||
|
|
||||||
|
- Complete, infer and navigate to asynchronous pytest fixtures
|
||||||
- Avoid changing the global recursion limit
|
- Avoid changing the global recursion limit
|
||||||
|
|
||||||
0.20.0 (2026-05-02)
|
0.20.0 (2026-05-02)
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ def execute(callback):
|
|||||||
|
|
||||||
def infer_anonymous_param(func):
|
def infer_anonymous_param(func):
|
||||||
def get_returns(value):
|
def get_returns(value):
|
||||||
if value.tree_node.annotation is not None:
|
# Async fixtures provide the awaited value, rather than a coroutine.
|
||||||
|
if (value.tree_node.annotation is not None
|
||||||
|
and value.tree_node.parent.type != 'async_funcdef'):
|
||||||
result = value.execute_with_values()
|
result = value.execute_with_values()
|
||||||
if any(v.name.get_qualified_names(include_module_names=True)
|
if any(v.name.get_qualified_names(include_module_names=True)
|
||||||
== ('typing', 'Generator')
|
== ('typing', 'Generator')
|
||||||
@@ -223,6 +225,8 @@ class FixtureFilter(ParserTreeFilter):
|
|||||||
if funcdef.type != "funcdef":
|
if funcdef.type != "funcdef":
|
||||||
return False
|
return False
|
||||||
decorated = funcdef.parent
|
decorated = funcdef.parent
|
||||||
|
if decorated.type == "async_funcdef":
|
||||||
|
decorated = decorated.parent
|
||||||
if decorated.type != "decorated":
|
if decorated.type != "decorated":
|
||||||
return False
|
return False
|
||||||
decorators = decorated.children[0]
|
decorators = decorated.children[0]
|
||||||
|
|||||||
@@ -208,3 +208,41 @@ def bla(admin_u
|
|||||||
def bla(admin_user):
|
def bla(admin_user):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# asynchronous fixtures
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
async def async_fixture():
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='module')
|
||||||
|
async def async_annotated_fixture() -> str:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
async def async_yield_fixture():
|
||||||
|
yield 1.0
|
||||||
|
|
||||||
|
|
||||||
|
#? ['async_fixture']
|
||||||
|
def test_async_fixture_completion(async_fixt
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_async_fixture_inference(async_fixture, async_annotated_fixture, async_yield_fixture):
|
||||||
|
#? int()
|
||||||
|
async_fixture
|
||||||
|
#? str()
|
||||||
|
async_annotated_fixture
|
||||||
|
#? float()
|
||||||
|
async_yield_fixture
|
||||||
|
|
||||||
|
|
||||||
|
#! 30 ['def async_fixture']
|
||||||
|
def test_async_fixture_goto(async_fixture):
|
||||||
|
pass
|
||||||
Reference in new issue
Block a user