Esempio 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"))
Esempio 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)
Esempio n. 3
0
 def test_get_unknown(self):
     """Retrieving unset dependencies raises exception."""
     with self.assertRaises(injection.DependencyException):
         unknown = injection.get("unknown-dependency")