Esempio n. 1
0
    def tearDown(self):
        from zope.component.testing import tearDown

        from AccessControl.security import clearSecurityInfo
        clearSecurityInfo(Dummy1)
        clearSecurityInfo(Dummy2)
        tearDown()
Esempio n. 2
0
 def tearDown(self):
     try:
         from zope.component.testing import tearDown
     except ImportError:
         pass
     else:
         tearDown()
Esempio n. 3
0
 def tearDown(cls):
     testing.tearDown()
     app = ZopeTestCase.app()
     schema.metadata.drop_all()
     app.manage_delObjects(SANDBOX_ID)
     transaction.commit()
     ZopeTestCase.close(app)
 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)
Esempio n. 6
0
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)()
Esempio n. 7
0
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()
Esempio n. 9
0
 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()
Esempio n. 11
0
 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()
Esempio n. 12
0
    def tearDown(self):
        from zope.security.tests.exampleclass import ExampleClass
        try:
            del ExampleClass.__implements__
        except AttributeError:
            pass

        from zope.component.testing import tearDown
        tearDown()
Esempio n. 13
0
 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):

        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 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)
Esempio n. 16
0
    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()
Esempio n. 17
0
 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()
Esempio n. 18
0
 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()
Esempio n. 19
0
    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()
Esempio n. 20
0
    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)
Esempio n. 21
0
    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()
Esempio n. 23
0
def configurationTearDown(test):
    tearDown()
Esempio n. 24
0
 def tearDown(self):
     testing.tearDown(self)
Esempio n. 25
0
 def tearDown(self):
     placelesssetup.tearDown(self)
Esempio n. 26
0
def tearDown():
    testing.tearDown()
Esempio n. 27
0
def configurationTearDown(test):
    tearDown()
Esempio n. 28
0
 def tearDown(self):
     from zope.component.testing import tearDown
     tearDown()
Esempio n. 29
0
 def tearDown(cls):
     tearDown()
Esempio n. 30
0
def tearDown(test):
    testing.tearDown(test)
    if zope.event.subscribers:
        zope.event.subscribers.pop()
Esempio n. 31
0
def tearDown(test):
    testing.tearDown(test)
Esempio n. 32
0
def tearDown(test):
    module.tearDown(test)
    testing.tearDown(test)
def reset():
    tearDown()
    setUpAuth()
Esempio n. 34
0
def tearDown(test):
    testing.tearDown(test)
    setup.tearDownTestAsModule(test)
Esempio n. 35
0
 def tearDown(self):
     from zope.component.testing import tearDown
     tearDown()
Esempio n. 36
0
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()
Esempio n. 38
0
def tearDown():
    testing.tearDown()
Esempio n. 39
0
 def tearDown(self):
     # unregister adapters registered in tests
     from zope.component.testing import tearDown
     tearDown()
Esempio n. 40
0
 def tearDown(self):
     tearDown()
def reset():
    tearDown()
    setUpAuth()
Esempio n. 42
0
def placefulTearDown():
    resetHooks()
    setSite()
    testing.tearDown()
Esempio n. 43
0
 def tearDown(self):
     super(AttributionTests, self).tearDown()
     tearDown(self)
     placefulTearDown()
Esempio n. 44
0
 def tearDown(self):
     resetHooks()
     setSite()
     testing.tearDown()
Esempio n. 45
0
def tearDown(test):
    placelesssetup.tearDown()
Esempio n. 46
0
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)
Esempio n. 48
0
 def tearDown(self):
     # unregister adapters registered in tests
     from zope.component.testing import tearDown
     tearDown()
Esempio n. 49
0
def tearDown(test):
    testing.tearDown(test)
    if zope.event.subscribers:
        zope.event.subscribers.pop()
Esempio n. 50
0
 def tearDown(self):
     resetHooks()
     setSite()
     testing.tearDown()
Esempio n. 51
0
 def tearDown(self):
     super(SearchTests, self).tearDown()
     tearDown(self)
     placefulTearDown()
def vocabTearDown(self):
    tearDown()
    hooks.resetHooks()
    hooks.setSite()
Esempio n. 53
0
 def tearDown(self):
     from zope.security.tests import module
     module.test_class = None
     from zope.component.testing import tearDown
     tearDown()
Esempio n. 54
0
 def tearDown(self):
     from zope.component.testing import tearDown
     from zope2 import sessioncookie
     sessioncookie.ZopeCookieSession = None
     tearDown()
Esempio n. 55
0
 def tearDown(self):
     del perms[:]
     from zope.component.testing import tearDown
     tearDown()
Esempio n. 56
0
 def tearDown(self):
     clearSite()
     tearDown()
Esempio n. 57
0
 def tearDown(self):
     tearDown(self)
Esempio n. 58
0
    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()