Exemplo n.º 1
0
 def test_select_fallback(self):
     """If a named alternative is selected, but not set, the manager falls
     back to the last alternative set."""
     
     injection.select("dependency", "named-alternative")
     
     injection.set("dependency", object())
     injection.set("dependency", object())
     
     self.assertIsNotNone(injection.get("dependency"))
Exemplo n.º 2
0
 def test_select_unset(self):
     """Selecting unset dependencies by name."""
     injection.select("unset-dependency", "named-alternative")
     
     value = object()
     
     injection.set("unset-dependency", value, name = "named-alternative")
     injection.set("unset-dependency", object())
     
     self.assertIs(injection.get("unset-dependency"), value)