Merge "Enable lazy translation in unit tests"

This commit is contained in:
Jenkins 2014-05-27 10:32:12 +00:00 committed by Gerrit Code Review
commit f9f18a6220
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
from heat.db import api as db_api
@ -512,7 +513,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):
@ -534,7 +535,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):