diff --git a/test/unit/test_module_loading.py b/test/unit/test_module_loading.py index 4e09876..6bc5e18 100644 --- a/test/unit/test_module_loading.py +++ b/test/unit/test_module_loading.py @@ -6,6 +6,7 @@ from test.unit.services.with_annotations.env import EnvService from test.unit.services.with_annotations.services import IFoo +import wireup from wireup import DependencyContainer, ParameterBag, initialize_container, register_all_in_module, warmup_container @@ -38,3 +39,13 @@ def test_loads_module_is_file(self): self.assertEqual("foo", container.get(services.IFoo).get_foo()) self.assertEqual(4, container.get(RandomService, qualifier="foo").get_random()) self.assertEqual(5, container.get(TrulyRandomService, qualifier="foo").get_truly_random()) + + def test_initialize_is_idempotent_recreates_container(self): + id_start = id(wireup.container) + initialize_container(service_modules=[services]) + id1 = id(wireup.container) + initialize_container(service_modules=[services]) + id2 = id(wireup.container) + + self.assertNotEqual(id_start, id1) + self.assertNotEqual(id1, id2)