File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -229,3 +229,18 @@ def my_enum_recipe() -> MyEnum:
229229
230230 value = get_instance (MyEnum )
231231 assert isinstance (value , MyEnum )
232+
233+ async def test_injectable_with_circular_dependency_raise_recursion_error (self ):
234+ class A : ...
235+
236+ @injectable
237+ @dataclass
238+ class B :
239+ a : A
240+
241+ @injectable
242+ async def a_factory (_b : B ) -> A :
243+ return A ()
244+
245+ with pytest .raises (RecursionError ):
246+ await aget_instance (A )
Original file line number Diff line number Diff line change @@ -183,3 +183,18 @@ class C(B): ...
183183
184184 a = get_instance (A )
185185 assert isinstance (a , C )
186+
187+ async def test_singleton_with_circular_dependency_raise_recursion_error (self ):
188+ class A : ...
189+
190+ @singleton
191+ @dataclass
192+ class B :
193+ a : A
194+
195+ @singleton
196+ async def a_factory (_b : B ) -> A :
197+ return A ()
198+
199+ with pytest .raises (RecursionError ):
200+ await aget_instance (A )
You can’t perform that action at this time.
0 commit comments