File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -754,6 +754,25 @@ def configure(binder: Binder) -> None:
754754 assert first_list [2 ] is second_list [2 ]
755755
756756
757+ def test_multibind_list_scopes_applies_to_the_bound_items_in_the_multibound_list () -> None :
758+ SingletonPlugins = Annotated [Plugin , "singleton" ]
759+ OtherPlugins = Annotated [Plugin , "other" ]
760+
761+ def configure (binder : Binder ) -> None :
762+ binder .multibind (List [SingletonPlugins ], to = PluginA , scope = singleton )
763+ binder .multibind (List [OtherPlugins ], to = PluginA )
764+
765+ injector = Injector ([configure ])
766+ singletons_1 = injector .get (List [SingletonPlugins ])
767+ singletons_2 = injector .get (List [SingletonPlugins ])
768+ others_1 = injector .get (List [OtherPlugins ])
769+ others_2 = injector .get (List [OtherPlugins ])
770+
771+ assert singletons_1 [0 ] is singletons_2 [0 ]
772+ assert singletons_1 [0 ] is not others_1 [0 ]
773+ assert others_1 [0 ] is not others_2 [0 ]
774+
775+
757776def test_multibind_dict_scopes_applies_to_the_bound_items () -> None :
758777 def configure (binder : Binder ) -> None :
759778 binder .multibind (Dict [str , Plugin ], to = {'a' : PluginA }, scope = singleton )
You can’t perform that action at this time.
0 commit comments