Skip to content

Commit

Permalink
Fix tests to run with Products.GenericSetup >= 1.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Feb 6, 2018
1 parent d4f445c commit 8ee2741
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
4.1 (unreleased)
----------------

- Fix tests to run with `Products.GenericSetup >= 1.10`.

4.0 (2017-09-14)
----------------
Expand Down
25 changes: 17 additions & 8 deletions src/Products/MailHost/tests/test_exportimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import unittest

import zope.component

try:
from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.testing import ExportImportZCMLLayer
Expand All @@ -39,14 +41,13 @@ class ExportImportZCMLLayer: pass
"""


unittest.skipUnless(HAVE_GS, 'Products.GenericSetup not available.')
@unittest.skipUnless(HAVE_GS, 'Products.GenericSetup not available.')
class MailHostXMLAdapterTests(BodyAdapterTestCase, unittest.TestCase):

layer = ExportImportZCMLLayer

def _getTargetClass(self):
from Products.GenericSetup.MailHost.exportimport \
import MailHostXMLAdapter
from Products.MailHost.exportimport import MailHostXMLAdapter

return MailHostXMLAdapter

Expand All @@ -69,9 +70,14 @@ def setUp(self):

self._obj = MailHost('foo_mailhost')
self._BODY = _MAILHOST_BODY
zope.component.provideAdapter(self._getTargetClass())

def tearDown(self):
gsm = zope.component.getGlobalSiteManager()
self.assertTrue(gsm.unregisterAdapter(self._getTargetClass()))


unittest.skipUnless(HAVE_GS, 'Products.GenericSetup not available.')
@unittest.skipUnless(HAVE_GS, 'Products.GenericSetup not available.')
class MailHostXMLAdapterTestsWithoutQueue(MailHostXMLAdapterTests):

def _verifyImport(self, obj):
Expand All @@ -85,16 +91,16 @@ def setUp(self):
del mh.smtp_queue
del mh.smtp_queue_directory
self._BODY = _MAILHOST_BODY
zope.component.provideAdapter(self._getTargetClass())


unittest.skipUnless(HAVE_GS, 'Products.GenericSetup not available.')
@unittest.skipUnless(HAVE_GS, 'Products.GenericSetup not available.')
class MailHostXMLAdapterTestsWithQueue(BodyAdapterTestCase, unittest.TestCase):

layer = ExportImportZCMLLayer

def _getTargetClass(self):
from Products.GenericSetup.MailHost.exportimport \
import MailHostXMLAdapter
from Products.MailHost.exportimport import MailHostXMLAdapter

return MailHostXMLAdapter

Expand All @@ -113,9 +119,11 @@ def setUp(self):

self._obj = MailHost('foo_mailhost')
self._BODY = _MAILHOST_BODY_v2
zope.component.provideAdapter(self._getTargetClass())



unittest.skipUnless(HAVE_GS, 'Products.GenericSetup not available.')
@unittest.skipUnless(HAVE_GS, 'Products.GenericSetup not available.')
class MailHostXMLAdapterTestsWithNoneValue(MailHostXMLAdapterTests):

def _verifyImport(self, obj):
Expand All @@ -134,6 +142,7 @@ def setUp(self):
self._obj = MailHost('foo_mailhost')
self._obj.smtp_uid = None
self._BODY = _MAILHOST_BODY
zope.component.provideAdapter(self._getTargetClass())


def test_suite():
Expand Down

0 comments on commit 8ee2741

Please sign in to comment.