diff --git a/heat/tests/__init__.py b/heat/tests/__init__.py index 2a4c3f68e..a71838bbe 100644 --- a/heat/tests/__init__.py +++ b/heat/tests/__init__.py @@ -13,5 +13,16 @@ # See http://code.google.com/p/python-nose/issues/detail?id=373 # The code below enables nosetests to work with i18n _() blocks -import __builtin__ -setattr(__builtin__, '_', lambda x: x) +from heat.openstack.common import gettextutils + + +def fake_translate_msgid(msgid, domain, desired_locale=None): + return msgid + +gettextutils.enable_lazy() +gettextutils.install('heat', lazy=True) + +#To ensure messages don't really get translated while running tests. +#As there are lots of places where matching is expected when comparing +#exception message(translated) with raw message. +gettextutils._translate_msgid = fake_translate_msgid diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index af93ab2dd..8f35c6946 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -16,6 +16,7 @@ import json import uuid import mock +import six from heat.common import exception import heat.db.api as db_api @@ -522,7 +523,7 @@ class ResourceTest(HeatTestCase): updater = scheduler.TaskRunner(res.update, utmpl) ex = self.assertRaises(resource.UpdateReplace, updater) self.assertEqual('The Resource test_resource requires replacement.', - str(ex)) + six.text_type(ex)) self.m.VerifyAll() def test_update_replace_without_resource_name(self): @@ -544,7 +545,7 @@ class ResourceTest(HeatTestCase): updater = scheduler.TaskRunner(res.update, utmpl) ex = self.assertRaises(resource.UpdateReplace, updater) self.assertEqual('The Resource Unknown requires replacement.', - str(ex)) + six.text_type(ex)) self.m.VerifyAll() def test_update_fail_missing_req_prop(self):