Permalink
Browse files

call fix_registry so that queryAdapterOrSelf is available

fixes #3416
  • Loading branch information...
mmerickel committed Nov 6, 2018
1 parent 229137d commit 4b9da6af118b4566da4b9a36eb41a047cd587a76
Showing with 15 additions and 0 deletions.
  1. +1 −0 src/pyramid/testing.py
  2. +14 −0 tests/test_testing.py
@@ -509,6 +509,7 @@ def setUp(
)
if settings is None:
settings = {}
config._fix_registry()
if getattr(registry, 'settings', None) is None:
config._set_settings(settings)
if hasattr(registry, 'registerUtility'):
@@ -434,6 +434,20 @@ def test_it_with_settings_passed_implicit_registry(self):
config = self._callFUT(hook_zca=False, settings=dict(a=1))
self.assertEqual(config.registry.settings['a'], 1)
def test_it_with_unpatched_registry(self):
from zope.interface.registry import Components
class DummyRegistry(Components, dict):
pass
dummy_registry = DummyRegistry()
config = self._callFUT(
registry=dummy_registry, hook_zca=False, settings=dict(a=1)
)
self.assertEqual(config.registry.settings['a'], 1)
dummy = DummyEvent()
self.assertIs(dummy_registry.queryAdapterOrSelf(dummy, IDummy), dummy)
class Test_cleanUp(Test_setUp):
def _callFUT(self, *arg, **kw):

0 comments on commit 4b9da6a

Please sign in to comment.