summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBrant Knudson <bknudson@us.ibm.com>2013-07-31 12:01:49 -0500
committerBrant Knudson <bknudson@us.ibm.com>2013-07-31 12:01:49 -0500
commit19081b834991d263d84c761dcf422a8c9faf40a1 (patch)
treee6d7f7b3af886f54314181c9ef9a7a95c21adb0e /tests
parentf1ac78c8992432e5f6d5c29f24f202870cb14a97 (diff)
downloadkeystone-19081b834991d263d84c761dcf422a8c9faf40a1.tar.gz
keystone-19081b834991d263d84c761dcf422a8c9faf40a1.tar.xz
keystone-19081b834991d263d84c761dcf422a8c9faf40a1.zip
Clear out the dependency registry between tests
As part of the process during several tests setUp where the backends are reloaded, automatic dependency injection takes place. The REGISTRY is being updated with new providers and it's also looking up the required dependencies. Some of the providers for the requirements may not have been updated yet with the new provider object, so it loads an object that was created from a previous test run rather than the current one. This can cause tests to fail when one class gets a ref to the old one (it depends on the order that the tests are run). This change clears out the registry of providers before loading backends. It only affects testing. Part of fix for bug 1204605 Change-Id: Ib845493fa13531225e4be7e3b6cc315b9d19a0f4
Diffstat (limited to 'tests')
-rw-r--r--tests/test_injection.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_injection.py b/tests/test_injection.py
index 4b6fc8ba..08ccd7c7 100644
--- a/tests/test_injection.py
+++ b/tests/test_injection.py
@@ -165,3 +165,20 @@ class TestDependencyInjection(unittest.TestCase):
with self.assertRaises(dependency.UnresolvableDependencyException):
Consumer()
+
+ def test_reset(self):
+ # Can reset the registry of providers.
+
+ p_id = uuid.uuid4().hex
+
+ @dependency.provider(p_id)
+ class P(object):
+ pass
+
+ p_inst = P()
+
+ self.assertIs(dependency.REGISTRY[p_id], p_inst)
+
+ dependency.reset()
+
+ self.assertFalse(dependency.REGISTRY)