Enable lazy translation in unit tests

Change-Id: Ia2aaaaae34f0f234b2493e7c724d7b874035bcfb
This commit is contained in:
Liang Chen 2014-02-22 18:18:03 +08:00
parent 4e5a19d4f6
commit 7081d0f5ac
2 changed files with 16 additions and 4 deletions

View File

@ -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

View File

@ -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):