def tearDown(self): from zope.component.testing import tearDown from AccessControl.security import clearSecurityInfo clearSecurityInfo(Dummy1) clearSecurityInfo(Dummy2) tearDown()
def tearDown(self): try: from zope.component.testing import tearDown except ImportError: pass else: tearDown()
def tearDown(cls): testing.tearDown() app = ZopeTestCase.app() schema.metadata.drop_all() app.manage_delObjects(SANDBOX_ID) transaction.commit() ZopeTestCase.close(app)
def tearDown(cls): testing.tearDown() app = ZopeTestCase.app() schema.metadata.drop_all() app.manage_delObjects( SANDBOX_ID ) transaction.commit() ZopeTestCase.close(app)
def clearZCML(test=None): from zope.configuration.xmlconfig import XMLConfig import zope.component from zope.component.testing import setUp from zope.component.testing import tearDown tearDown() setUp() XMLConfig('meta.zcml', zope.component)()
def tearDown(self): from zope.security.tests import module module.test_class = None try: from zope.component.testing import tearDown except ImportError: pass else: tearDown()
def tearDown(cls): from pas.plugins.sqlalchemy.model import Base Session() Base.metadata.drop_all() testing.tearDown() app = ZopeTestCase.app() app.manage_delObjects(SANDBOX_ID) transaction.commit() ZopeTestCase.close(app)
def tearDown(self): from zope.security.tests.exampleclass import ExampleClass try: del ExampleClass.__implements__ except AttributeError: pass from zope.component.testing import tearDown tearDown()
def tearDown(self): noSecurityManager() SecurityManager.setSecurityPolicy(self.oldPolicy) del self.oldPolicy del self.policy del self.folder2 del self.folder1 self._cleanApp() componenttesting.tearDown() CopySupportTestBase.tearDown(self)
def testRequestLocale(self): eq = self.assertEqual unless = self.failUnless from zope.component import provideAdapter from zope.publisher.browser import BrowserLanguages from zope.publisher.interfaces.http import IHTTPRequest from zope.i18n.interfaces import IUserPreferredLanguages provideAdapter(BrowserLanguages, [IHTTPRequest], IUserPreferredLanguages) for httplang in ('it', 'it-ch', 'it-CH', 'IT', 'IT-CH', 'IT-ch'): req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': httplang}) locale = req.locale unless(ILocale.providedBy(locale)) parts = httplang.split('-') lang = parts.pop(0).lower() territory = variant = None if parts: territory = parts.pop(0).upper() if parts: variant = parts.pop(0).upper() eq(locale.id.language, lang) eq(locale.id.territory, territory) eq(locale.id.variant, variant) # Now test for non-existant locale fallback req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': 'xx'}) locale = req.locale unless(ILocale.providedBy(locale)) eq(locale.id.language, None) eq(locale.id.territory, None) eq(locale.id.variant, None) # If the first language is not available we should try others req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': 'xx,en;q=0.5'}) locale = req.locale unless(ILocale.providedBy(locale)) eq(locale.id.language, 'en') eq(locale.id.territory, None) eq(locale.id.variant, None) # Regression test: there was a bug where territory and variant were # not reset req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': 'xx-YY,en;q=0.5'}) locale = req.locale unless(ILocale.providedBy(locale)) eq(locale.id.language, 'en') eq(locale.id.territory, None) eq(locale.id.variant, None) from zope.component.testing import tearDown tearDown()
def tearDown(self): from zope.component.testing import tearDown import OFS.metaconfigure # restore registrations OFS.metaconfigure._meta_type_regs[:] = self._old_mt_regs OFS.metaconfigure._register_monkies[:] = self._old_monkies if self._old_metatypes is not _marker: import Products Products.meta_types = self._old_metatypes else: try: del Products.meta_types except AttributeError: pass tearDown()
def test_scrubHTML_with_adapter(self): from zope.component.testing import setUp from zope.component.testing import tearDown from zope.component import getSiteManager from zope.interface import implements from Products.CMFDefault.interfaces import IHTMLScrubber from Products.CMFDefault.utils import scrubHTML class _Scrubber: implements(IHTMLScrubber) def scrub(self, html): return html.upper() setUp() sm = getSiteManager() try: sm.registerUtility(_Scrubber(), IHTMLScrubber) self.assertEqual( scrubHTML('<a href="foo.html">bar</a>'), '<A HREF="FOO.HTML">BAR</A>' ) self.assertEqual( scrubHTML('<b>bar</b>'), '<B>BAR</B>' ) self.assertEqual( scrubHTML('<base href="" /><base>'), '<BASE HREF="" /><BASE>' ) self.assertEqual( scrubHTML('<blockquote>bar</blockquote>'), '<BLOCKQUOTE>BAR</BLOCKQUOTE>' ) self.assertEqual( scrubHTML('<body bgcolor="#ffffff">bar</body>'), '<BODY BGCOLOR="#FFFFFF">BAR</BODY>' ) self.assertEqual( scrubHTML('<br /><br>'), '<BR /><BR>' ) self.assertEqual( scrubHTML('<hr /><hr>'), '<HR /><HR>' ) self.assertEqual( scrubHTML('<img src="foo.png" /><img>'), '<IMG SRC="FOO.PNG" /><IMG>' ) self.assertEqual( scrubHTML( '<meta name="title" content="" /><meta>'), '<META NAME="TITLE" CONTENT="" /><META>' ) finally: tearDown()
def tearDown(cls): testing.tearDown() app = ZopeTestCase.app() # Remove the tables tests cls.execute('DROP TABLE %s' % TESTING_USERS_TABLE) cls.execute('DROP TABLE %s' % TESTING_ROLES_TABLE) # Remove our sandbox app.manage_delObjects(SANDBOX_ID) # Remove the testing sqlite database, if existing dbFile = 'sqlpasplugin-testing.db' dbDir = os.path.join(os.getenv('INSTANCE_HOME'), 'var', 'sqlite') dbPath = os.path.join(dbDir, dbFile) if os.path.exists(dbDir): os.remove(dbPath) transaction.commit() ZopeTestCase.close(app)
def test_scrubHTML_with_adapter(self): from zope.component.testing import setUp from zope.component.testing import tearDown from zope.component import getSiteManager from zope.interface import implements from Products.CMFDefault.interfaces import IHTMLScrubber from Products.CMFDefault.utils import scrubHTML class _Scrubber: implements(IHTMLScrubber) def scrub(self, html): return html.upper() setUp() sm = getSiteManager() try: sm.registerUtility(_Scrubber(), IHTMLScrubber) self.assertEqual(scrubHTML('<a href="foo.html">bar</a>'), '<A HREF="FOO.HTML">BAR</A>') self.assertEqual(scrubHTML('<b>bar</b>'), '<B>BAR</B>') self.assertEqual(scrubHTML('<base href="" /><base>'), '<BASE HREF="" /><BASE>') self.assertEqual(scrubHTML('<blockquote>bar</blockquote>'), '<BLOCKQUOTE>BAR</BLOCKQUOTE>') self.assertEqual(scrubHTML('<body bgcolor="#ffffff">bar</body>'), '<BODY BGCOLOR="#FFFFFF">BAR</BODY>') self.assertEqual(scrubHTML('<br /><br>'), '<BR /><BR>') self.assertEqual(scrubHTML('<hr /><hr>'), '<HR /><HR>') self.assertEqual(scrubHTML('<img src="foo.png" /><img>'), '<IMG SRC="FOO.PNG" /><IMG>') self.assertEqual( scrubHTML('<meta name="title" content="" /><meta>'), '<META NAME="TITLE" CONTENT="" /><META>') finally: tearDown()
def tearDown(self): testing.tearDown()
def configurationTearDown(test): tearDown()
def tearDown(self): testing.tearDown(self)
def tearDown(self): placelesssetup.tearDown(self)
def tearDown(): testing.tearDown()
def tearDown(self): from zope.component.testing import tearDown tearDown()
def tearDown(cls): tearDown()
def tearDown(test): testing.tearDown(test) if zope.event.subscribers: zope.event.subscribers.pop()
def tearDown(test): testing.tearDown(test)
def tearDown(test): module.tearDown(test) testing.tearDown(test)
def reset(): tearDown() setUpAuth()
def tearDown(test): testing.tearDown(test) setup.tearDownTestAsModule(test)
def tearDown(test): testing.tearDown(test) SMTPMailer.send = test.oldseld
def tearDown(self): from zope.component.testing import tearDown from zope2 import sessioncookie sessioncookie.ZopeCookieSession = None tearDown()
def tearDown(self): # unregister adapters registered in tests from zope.component.testing import tearDown tearDown()
def tearDown(self): tearDown()
def placefulTearDown(): resetHooks() setSite() testing.tearDown()
def tearDown(self): super(AttributionTests, self).tearDown() tearDown(self) placefulTearDown()
def tearDown(self): resetHooks() setSite() testing.tearDown()
def tearDown(test): placelesssetup.tearDown()
def tearDown(test): placelesssetup.tearDown() transaction.abort() schema.metadata.drop_all(checkfirst=True) orm.clear_mappers()
def tearDownConnection(test): test.globs['conn'].close() tearDown(test)
def tearDown(self): super(SearchTests, self).tearDown() tearDown(self) placefulTearDown()
def vocabTearDown(self): tearDown() hooks.resetHooks() hooks.setSite()
def tearDown(self): from zope.security.tests import module module.test_class = None from zope.component.testing import tearDown tearDown()
def tearDown(self): del perms[:] from zope.component.testing import tearDown tearDown()
def tearDown(self): clearSite() tearDown()
def tearDown(self): tearDown(self)
def testRequestLocale(self): eq = self.assertEqual unless = self.failUnless from zope.component import provideAdapter from zope.publisher.browser import BrowserLanguages from zope.publisher.interfaces.http import IHTTPRequest from zope.i18n.interfaces import IUserPreferredLanguages provideAdapter(BrowserLanguages, [IHTTPRequest], IUserPreferredLanguages) for httplang in ('it', 'it-ch', 'it-CH', 'IT', 'IT-CH', 'IT-ch'): req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': httplang}) locale = req.locale unless(ILocale.providedBy(locale)) parts = httplang.split('-') lang = parts.pop(0).lower() territory = variant = None if parts: territory = parts.pop(0).upper() if parts: variant = parts.pop(0).upper() eq(locale.id.language, lang) eq(locale.id.territory, territory) eq(locale.id.variant, variant) # Now test for non-existant locale fallback req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': 'xx'}) locale = req.locale unless(ILocale.providedBy(locale)) eq(locale.id.language, None) eq(locale.id.territory, None) eq(locale.id.variant, None) # If the first language is not available we should try others req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': 'xx,en;q=0.5'}) locale = req.locale unless(ILocale.providedBy(locale)) eq(locale.id.language, 'en') eq(locale.id.territory, None) eq(locale.id.variant, None) # Regression test: there was a bug where territory and variant were # not reset req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': 'xx-YY,en;q=0.5'}) locale = req.locale unless(ILocale.providedBy(locale)) eq(locale.id.language, 'en') eq(locale.id.territory, None) eq(locale.id.variant, None) # Now test for improper quality value, should ignore the header req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': 'en;q=xx'}) locale = req.locale unless(ILocale.providedBy(locale)) eq(locale.id.language, None) eq(locale.id.territory, None) eq(locale.id.variant, None) # Now test for very improper quality value, should ignore the header req = self._createRequest({'HTTP_ACCEPT_LANGUAGE': 'asdf;qwer'}) locale = req.locale unless(ILocale.providedBy(locale)) eq(locale.id.language, None) eq(locale.id.territory, None) eq(locale.id.variant, None) from zope.component.testing import tearDown tearDown()