Skip to content

Commit

Permalink
fix: correct yield overriding (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik authored Dec 22, 2023
1 parent e783f1a commit 458e8f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fast_depends/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""FastDepends - extracted and cleared from HTTP domain FastAPI Dependency Injection System"""

__version__ = "2.2.6"
__version__ = "2.2.7"
4 changes: 2 additions & 2 deletions fast_depends/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def solve(
if self.is_generator and nested:
response = solve_generator_sync(
*final_args,
call=self.call,
call=call,
stack=stack,
**final_kwargs,
)
Expand Down Expand Up @@ -418,7 +418,7 @@ async def asolve(
if self.is_generator and nested:
response = await solve_generator_async(
*final_args,
call=self.call,
call=call,
stack=stack,
**final_kwargs,
)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ def func(d=Depends(base_dep)):
assert func() == 1


def test_override_context_with_yield(provider):
def base_dep():
yield 1

def override_dep():
yield 2

@inject
def func(d=Depends(base_dep)):
return d

with provider.scope(base_dep, override_dep):
assert func() == 2

assert func() == 1


def test_sync_by_async_override(provider):
def base_dep(): # pragma: no cover
return 1
Expand Down

0 comments on commit 458e8f1

Please sign in to comment.