Merge "Enable lazy translation in unit tests"
This commit is contained in:
commit
f9f18a6220
@ -13,5 +13,16 @@
|
|||||||
|
|
||||||
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
||||||
# The code below enables nosetests to work with i18n _() blocks
|
# The code below enables nosetests to work with i18n _() blocks
|
||||||
import __builtin__
|
from heat.openstack.common import gettextutils
|
||||||
setattr(__builtin__, '_', lambda x: x)
|
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -16,6 +16,7 @@ import json
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
import six
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.db import api as db_api
|
from heat.db import api as db_api
|
||||||
@ -512,7 +513,7 @@ class ResourceTest(HeatTestCase):
|
|||||||
updater = scheduler.TaskRunner(res.update, utmpl)
|
updater = scheduler.TaskRunner(res.update, utmpl)
|
||||||
ex = self.assertRaises(resource.UpdateReplace, updater)
|
ex = self.assertRaises(resource.UpdateReplace, updater)
|
||||||
self.assertEqual('The Resource test_resource requires replacement.',
|
self.assertEqual('The Resource test_resource requires replacement.',
|
||||||
str(ex))
|
six.text_type(ex))
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_update_replace_without_resource_name(self):
|
def test_update_replace_without_resource_name(self):
|
||||||
@ -534,7 +535,7 @@ class ResourceTest(HeatTestCase):
|
|||||||
updater = scheduler.TaskRunner(res.update, utmpl)
|
updater = scheduler.TaskRunner(res.update, utmpl)
|
||||||
ex = self.assertRaises(resource.UpdateReplace, updater)
|
ex = self.assertRaises(resource.UpdateReplace, updater)
|
||||||
self.assertEqual('The Resource Unknown requires replacement.',
|
self.assertEqual('The Resource Unknown requires replacement.',
|
||||||
str(ex))
|
six.text_type(ex))
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_update_fail_missing_req_prop(self):
|
def test_update_fail_missing_req_prop(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user