Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Commit

Permalink
readded teardown and put layers around doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Oct 31, 2014
1 parent 1877f17 commit 1cf1cf9
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions Products/PasswordResetTool/tests/test_doctests.py
Expand Up @@ -11,6 +11,7 @@
from Products.CMFPlone.tests.utils import MockMailHost
from plone.app import testing
from plone.testing import layered
from transaction import commit

OPTIONFLAGS = (doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE)
Expand All @@ -20,30 +21,34 @@ class MockMailFixture(testing.PloneSandboxLayer):
defaultBases = (testing.PLONE_FIXTURE,)

def setUpPloneSite(self, portal):
portal._original_MailHost = self.portal.MailHost
portal._original_MailHost = portal.MailHost
portal.MailHost = mailhost = MockMailHost('MailHost')
mailhost.smtp_host = 'localhost'
sm = getSiteManager(context=portal)
sm.unregisterUtility(provided=IMailHost)
sm.registerUtility(mailhost, provided=IMailHost)
portal.email_from_address = 'test@example.com'
commit()

def tearDownPloneSite(self, portal):
portal.MailHost = portal._original_MailHost
sm = getSiteManager(context=portal)
sm.unregisterUtility(provided=IMailHost)
sm.registerUtility(aq_base(portal._original_MailHost), provided=IMailHost)

# def beforeTearDown(self):
# self.portal.MailHost = self.portal._original_MailHost
# sm = getSiteManager(context=self.portal)
# sm.unregisterUtility(provided=IMailHost)
# sm.registerUtility(aq_base(self.portal._original_MailHost), provided=IMailHost)

MOCK_MAIL_FIXTURE = MockMailFixture()
MM_FUNCTIONAL_TESTING = testing.FunctionalTesting(
bases=(MOCK_MAIL_FIXTURE,), name='PloneTestCase:Functional')


def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('browser.txt',
optionflags=OPTIONFLAGS,
package='Products.PasswordResetTool.tests',
test_class=MockMailHostTestCase),
doctest.DocFileSuite('view.txt',
optionflags=OPTIONFLAGS,
package='Products.PasswordResetTool.tests',
test_class=MockMailHostTestCase),
))
layered(doctest.DocFileSuite('browser.txt',
optionflags=OPTIONFLAGS,
package='Products.PasswordResetTool.tests',),
layer=MM_FUNCTIONAL_TESTING),
layered(doctest.DocFileSuite('view.txt',
optionflags=OPTIONFLAGS,
package='Products.PasswordResetTool.tests',),
layer=MM_FUNCTIONAL_TESTING)))

0 comments on commit 1cf1cf9

Please sign in to comment.