[Zope-Checkins] SVN: Zope/trunk/src/App/tests/test_Extensions.py Finish coverage for App.Extensions.getBrain.
Tres Seaver
tseaver at palladion.com
Mon Apr 5 12:31:13 EDT 2010
Log message for revision 110493:
Finish coverage for App.Extensions.getBrain.
Changed:
U Zope/trunk/src/App/tests/test_Extensions.py
-=-
Modified: Zope/trunk/src/App/tests/test_Extensions.py
===================================================================
--- Zope/trunk/src/App/tests/test_Extensions.py 2010-04-05 16:20:11 UTC (rev 110492)
+++ Zope/trunk/src/App/tests/test_Extensions.py 2010-04-05 16:31:13 UTC (rev 110493)
@@ -338,6 +338,40 @@
self.assertEqual(cached['named'], 'NAMED')
+class Test_getBrain(_TempdirBase, unittest.TestCase):
+
+ def _callFUT(self, module, name, reload=0, modules=None):
+ from App.Extensions import getBrain
+ if modules is not None:
+ return getBrain(module, name, reload, modules)
+ return getBrain(module, name, reload)
+
+ def test_no_module_no_class_yields_NoBrains(self):
+ from App.Extensions import NoBrains
+ self.failUnless(self._callFUT('', '') is NoBrains)
+
+ def test_missing_name(self):
+ from App.Extensions import NoBrains
+ from zExceptions import NotFound
+ self.failUnless(self._callFUT('', '') is NoBrains)
+ MODULES = {'somemodule': {}}
+ self.assertRaises(NotFound,
+ self._callFUT, 'somemodule', 'name', modules=MODULES)
+
+ def test_not_a_class(self):
+ from App.Extensions import NoBrains
+ self.failUnless(self._callFUT('', '') is NoBrains)
+ MODULES = {'somemodule': {'name': object()}}
+ self.assertRaises(ValueError,
+ self._callFUT, 'somemodule', 'name', modules=MODULES)
+
+ def test_found_class(self):
+ from App.Extensions import NoBrains
+ self.failUnless(self._callFUT('', '') is NoBrains)
+ MODULES = {'somemodule': {'name': self.__class__}}
+ self.assertEqual(self._callFUT('somemodule', 'name', modules=MODULES),
+ self.__class__)
+
EXTENSION_PY = """\
named = 'NAMED'
"""
@@ -347,4 +381,5 @@
unittest.makeSuite(FuncCodeTests),
unittest.makeSuite(Test_getPath),
unittest.makeSuite(Test_getObject),
+ unittest.makeSuite(Test_getBrain),
))
More information about the Zope-Checkins
mailing list