summaryrefslogtreecommitdiff
path: root/src/zope/interface/tests
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2017-06-08 14:26:23 -0500
committerJason Madden <jamadden@gmail.com>2017-06-12 09:07:16 -0500
commit759af9e08d3e7918f7c8613762e8f777190d912b (patch)
tree8a2f4ddda5dcc099c2873309533401528e8ba54b /src/zope/interface/tests
parentaee89255b1b1b12264bdb2570c7f36f27566b68d (diff)
downloadzope-interface-issue85.tar.gz
Partially revert #84 in order to fix #85issue85
But add testing to be sure it doesn't break again, and extra suspenders to ensure the issues that #84 was trying to deal with doesn't show up either.
Diffstat (limited to 'src/zope/interface/tests')
-rw-r--r--src/zope/interface/tests/test_registry.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/zope/interface/tests/test_registry.py b/src/zope/interface/tests/test_registry.py
index 3e71aff..00aea76 100644
--- a/src/zope/interface/tests/test_registry.py
+++ b/src/zope/interface/tests/test_registry.py
@@ -577,7 +577,12 @@ class ComponentsTests(unittest.TestCase):
# zope.component.testing does this
comp.__init__('base')
+
+ # And let's go ahead and destroy the cache at random times too
+ from zope.interface.registry import _UtilityRegistrations
+ _UtilityRegistrations.clear_cache()
comp.registerUtility(_to_reg, ifoo, _name2, _info)
+ _UtilityRegistrations.clear_cache()
_monkey, _events = self._wrapEvents()
with _monkey:
@@ -2645,12 +2650,21 @@ class PersistentComponents(Components):
self.adapters = PersistentAdapterRegistry()
self.utilities = PersistentAdapterRegistry()
+class PersistentDictComponents(PersistentComponents, dict):
+ # Like Pyramid's Registry, we subclass Components and dict
+ pass
class TestPersistentComponents(unittest.TestCase):
+ def _makeOne(self):
+ return PersistentComponents('test')
+
+ def _check_equality_after_pickle(self, made):
+ pass
+
def test_pickles_empty(self):
import pickle
- comp = PersistentComponents('test')
+ comp = self._makeOne()
pickle.dumps(comp)
comp2 = pickle.loads(pickle.dumps(comp))
@@ -2658,7 +2672,7 @@ class TestPersistentComponents(unittest.TestCase):
def test_pickles_with_utility_registration(self):
import pickle
- comp = PersistentComponents('test')
+ comp = self._makeOne()
comp.registerUtility(
object(),
Interface)
@@ -2666,7 +2680,19 @@ class TestPersistentComponents(unittest.TestCase):
comp2 = pickle.loads(pickle.dumps(comp))
self.assertEqual(comp2.__name__, 'test')
- self.assertNotNone(comp2.getUtility(Interface))
+ self.assertIsNotNone(comp2.getUtility(Interface))
+ self._check_equality_after_pickle(comp2)
+
+class TestPersistentDictComponents(TestPersistentComponents):
+
+ def _makeOne(self):
+ comp = PersistentDictComponents('test')
+ comp['key'] = 42
+ return comp
+
+ def _check_equality_after_pickle(self, made):
+ self.assertIn('key', made)
+ self.assertEqual(made['key'], 42)
class _Monkey(object):