diff options
author | Jason Madden <jamadden@gmail.com> | 2017-06-29 12:44:25 -0500 |
---|---|---|
committer | Jason Madden <jamadden@gmail.com> | 2017-06-30 11:01:09 -0500 |
commit | 712bb8e078de20e01311cfe57d8dccfbbdcbe9b3 (patch) | |
tree | 4cb7d4e9cc901fe144d168b77eea235a08932787 /src/zope/component/tests/test_globalregistry.py | |
parent | 43d7351318eb373d1f4f500b70e4e461048c16f4 (diff) | |
download | zope-component-issue29.tar.gz |
100% coverageissue29
Add change note and badge to readme.
Remove unused class and function.
Omit standalonetests.py entirely from coverage.
Another unused class.
Incorporate feedback in test__api.py
* Bring back _callFUT and make the queryAdapterInContext tests call it
* Change raise NotImplentedError into specific fails_if_called() calls.
Remove redundant argument now that all test in Test_adapts pass under all versions.
Remove NotImplementedError from test_globalregistry.py
Remove NotImplementedError from test_hookable.py
Remove NotImplementedError from test_registry.py
Remove NotImplementedError from test_security.py
Remove NotImplementedError from test_zcml.py
Remove NotImplementedError from test_factory.py
Document ZCML feature and devmode.
Really accept all arguments unless opted out.
Diffstat (limited to 'src/zope/component/tests/test_globalregistry.py')
-rw-r--r-- | src/zope/component/tests/test_globalregistry.py | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/zope/component/tests/test_globalregistry.py b/src/zope/component/tests/test_globalregistry.py index d55b4cb..52166d1 100644 --- a/src/zope/component/tests/test_globalregistry.py +++ b/src/zope/component/tests/test_globalregistry.py @@ -15,6 +15,8 @@ """ import unittest +from zope.component.tests import fails_if_called + class Test_getGlobalSiteManager(unittest.TestCase): def _callFUT(self): @@ -68,7 +70,12 @@ class Test_provideUtility(unittest.TestCase): foo = Foo() self._callFUT(foo) gsm = getGlobalSiteManager() - self.assertTrue(gsm.getUtility(IFoo, '') is foo) + self.assertIs(gsm.getUtility(IFoo, ''), foo) + + # We can clean it up using the fallback and it will be gone + from zope.component.testing import _PlacelessSetupFallback + _PlacelessSetupFallback().cleanUp() + self.assertIsNone(gsm.queryUtility(IFoo, '')) def test_named_w_provides(self): from zope.interface import Interface @@ -212,9 +219,8 @@ class Test_provideHandler(unittest.TestCase): @implementer(IFoo) class Foo(object): pass - @adapter(IFoo) - def _handler(context): - assert 0, "DON'T GO HERE" + _handler = adapter(IFoo)(fails_if_called(self)) + self._callFUT(_handler) gsm = getGlobalSiteManager() regs = list(gsm.registeredHandlers()) @@ -229,8 +235,7 @@ class Test_provideHandler(unittest.TestCase): from zope.component.globalregistry import getGlobalSiteManager class IFoo(Interface): pass - def _handler(context): - assert 0, "DON'T GO HERE" + _handler = fails_if_called(self) self._callFUT(_handler, (IFoo,)) gsm = getGlobalSiteManager() regs = list(gsm.registeredHandlers()) @@ -239,13 +244,3 @@ class Test_provideHandler(unittest.TestCase): self.assertEqual(list(hr.required), [IFoo]) self.assertEqual(hr.name, '') self.assertTrue(hr.factory is _handler) - - -def test_suite(): - return unittest.TestSuite(( - unittest.makeSuite(Test_getGlobalSiteManager), - unittest.makeSuite(Test_provideUtility), - unittest.makeSuite(Test_provideAdapter), - unittest.makeSuite(Test_provideSubscriptionAdapter), - unittest.makeSuite(Test_provideHandler), - )) |