Remove moxstubout usage

In newer versions of oslotest moxstubout is deprecated,
so get out in front of the curve and replace it with mock.

Change-Id: Ib7526bc5f7fc21cda9288e085216997519322010
Signed-off-by: Charles Short <zulcss@gmail.com>
This commit is contained in:
Charles Short 2018-05-18 08:32:08 -04:00
parent d50bb5c3bd
commit fe3e09af2a
1 changed files with 9 additions and 5 deletions

View File

@ -86,10 +86,12 @@ class GettextTest(test_base.BaseTestCase):
# test that here too
return ['zh', 'es', 'nl', 'fr', 'zh_Hant', 'zh_Hant_HK', 'fil']
self.stubs.Set(localedata,
'list' if hasattr(localedata, 'list')
else 'locale_identifiers',
_mock_locale_identifiers)
mock_patcher = mock.patch.object(localedata,
'list' if hasattr(localedata, 'list')
else 'locale_identifiers',
_mock_locale_identifiers)
mock_patcher.start()
self.addCleanup(mock_patcher.stop)
# Only the languages available for a specific translation domain
def _mock_gettext_find(domain, localedir=None, languages=None, all=0):
@ -101,7 +103,9 @@ class GettextTest(test_base.BaseTestCase):
return 'translation-file' if any(x in ['fr', 'zh_Hant']
for x in languages) else None
return None
self.stubs.Set(gettext, 'find', _mock_gettext_find)
mock_patcher = mock.patch.object(gettext, 'find', _mock_gettext_find)
mock_patcher.start()
self.addCleanup(mock_patcher.stop)
# Ensure that no domains are cached
_gettextutils._AVAILABLE_LANGUAGES = {}