def test_adapter_reinitialize(self): global testAdapter @config.adapter(IContext) @config.adapter(IContext2) @interface.implementer(IAdapter) def testAdapter(context): # pragma: no cover pass self._init_memphis() # reinstall config.cleanUp() sm = config.registry sm.__init__('base') self._init_memphis(newReg=config.registry) adapters = sm.adapters.lookupAll((IContext,), IAdapter) self.assertTrue(len(adapters) == 1) self.assertTrue(adapters[0][1] is testAdapter) adapters = sm.adapters.lookupAll((IContext2,), IAdapter) self.assertTrue(len(adapters) == 1) self.assertTrue(adapters[0][1] is testAdapter)
def tearDown(self): config.cleanUp(self.__class__.__module__) global TestClass, testAdapter, testHandler try: del TestClass except: pass try: del testAdapter except: pass try: del testHandler except: pass
def test_renderer_tmpl_with_layout(self): class Layout(view.Layout): def render(self, content): return "<html>%s</html>" % content view.registerLayout("test", klass=Layout) self._init_memphis() def viewFactory(context, request): return None, {} # renderer layout is different r = Renderer(view.template("templates/test.pt"), "") res = r(Context(), self.request, viewFactory) self.assertEqual(res.body, "<div>My pagelet</div>\n") # layout is 'test' config.cleanUp() r = Renderer(view.template("templates/test.pt"), "test") res = r(Context(), self.request, viewFactory) self.assertEqual(res.body, "<html><div>My pagelet</div>\n</html>")
def test_subscriber_reinitialize(self): global testSubscriber events = [] @config.subscriber(IContext) def testSubscriber(*args): events.append(args) self._init_memphis() # reinstall config.cleanUp() sm = config.registry sm.__init__('base') self._init_memphis() sm = config.registry sm.subscribers((Context(IContext),), None) self.assertTrue(len(events) == 1)
def test_adapts_reinitialize(self): global TestClass class TestClass(object): config.adapter(IContext) interface.implements(IAdapter) self._init_memphis() # reinstall config.cleanUp() sm = config.registry sm.__init__('base') adapters = sm.adapters.lookupAll((IContext,), IAdapter) self.assertTrue(len(adapters) == 0) self._init_memphis() sm = config.registry adapters = sm.adapters.lookupAll((IContext,), IAdapter) self.assertTrue(len(adapters) == 1) self.assertTrue(adapters[0][1] is TestClass)
def tearDown(self): self.stdout = self._stdout shutil.rmtree(self.dir) config.cleanUp()
def setUp(self): config.cleanUp() BaseTesting.setUp(self) self.dir = tempfile.mkdtemp()
def tearDown(self): config.cleanUp(self.__class__.__module__)
def tearDown(self): config.cleanUp()
def tearDown(self): config.cleanUp(self.__class__.__module__) sm = self.p_config sm.__init__('base') testing.tearDown()