fix translation tests now that Zope 2.12 has domain translation aliases

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33108 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 85861044
...@@ -52,6 +52,8 @@ except ImportError: ...@@ -52,6 +52,8 @@ except ImportError:
# zope.i18n utilities # zope.i18n utilities
import zope.interface import zope.interface
import zope.component import zope.component
import Acquisition
global_translation_service = None global_translation_service = None
from zope.i18n.interfaces import ITranslationDomain, \ from zope.i18n.interfaces import ITranslationDomain, \
...@@ -72,10 +74,25 @@ except ImportError: ...@@ -72,10 +74,25 @@ except ImportError:
global_translation_service = translation_service global_translation_service = translation_service
zope.component.provideUtility(DummyTranslationDomainFallback, zope.component.provideUtility(DummyTranslationDomainFallback,
provides=IFallbackTranslationDomainFactory) provides=IFallbackTranslationDomainFactory)
# disable translation for the 'ui' domain so it can use the fallback above.
# Save it on a portal attribute since we don't have access to the test
# class
sm = zope.component.getSiteManager()
portal = Acquisition.aq_parent(sm)
ui_domain = sm.getUtility(ITranslationDomain, name='ui')
# store in a list to avoid acquisition wrapping
portal._save_ui_domain = [ui_domain]
sm.unregisterUtility(provided=ITranslationDomain, name='ui')
def unregister_translation_domain_fallback(): def unregister_translation_domain_fallback():
from zope.component.globalregistry import base from zope.component.globalregistry import base
base.unregisterUtility(DummyTranslationDomainFallback) base.unregisterUtility(DummyTranslationDomainFallback)
sm = zope.component.getSiteManager()
portal = Acquisition.aq_parent(sm)
ui_domain = getattr(portal, '_save_ui_domain', [None]).pop()
if ui_domain is not None:
sm.registerUtility(ui_domain, ITranslationDomain, 'ui')
del portal._save_ui_domain
HTTP_OK = 200 HTTP_OK = 200
HTTP_UNAUTHORIZED = 401 HTTP_UNAUTHORIZED = 401
...@@ -106,13 +123,12 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -106,13 +123,12 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
self.portal = self.getPortal()
self.portal_id = self.portal.getId() self.portal_id = self.portal.getId()
self.auth = '%s:%s' % (self.manager_username, self.manager_password) self.auth = '%s:%s' % (self.manager_username, self.manager_password)
def beforeTearDown(self): def beforeTearDown(self):
unregister_translation_domain_fallback()
transaction.abort() transaction.abort()
unregister_translation_domain_fallback()
if 'test_folder' in self.portal.objectIds(): if 'test_folder' in self.portal.objectIds():
self.portal.manage_delObjects(['test_folder']) self.portal.manage_delObjects(['test_folder'])
self.portal.portal_selections.setSelectionFor('test_selection', None) self.portal.portal_selections.setSelectionFor('test_selection', None)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment