Quiet all locale warnings and dummy thread, too

Change-Id: I0c68b94ec234e470ce2d50da01d8ae1cd10fae58
Signed-off-by: Peter Portante <peter.portante@redhat.com>
This commit is contained in:
Peter Portante 2013-10-05 11:12:43 -04:00
parent 8255810e7d
commit 63370ea466

View File

@ -5,6 +5,7 @@ import os
import unittest
import string
import sys
import threading
try:
from subprocess import check_output
@ -27,12 +28,29 @@ except ImportError:
return output
os.environ['LC_ALL'] = 'eo'
os.environ['SWIFT_LOCALEDIR'] = os.path.dirname(__file__)
class TestTranslations(unittest.TestCase):
def setUp(self):
self.la = os.environ.get('LC_ALL')
self.sl = os.environ.get('SWIFT_LOCALEDIR')
os.environ['LC_ALL'] = 'eo'
os.environ['SWIFT_LOCALEDIR'] = os.path.dirname(__file__)
self.orig_stop = threading._DummyThread._Thread__stop
# See http://stackoverflow.com/questions/13193278/\
# understand-python-threading-bug
threading._DummyThread._Thread__stop = lambda x: 42
def tearDown(self):
if self.la is not None:
os.environ['LC_ALL'] = self.la
else:
del os.environ['LC_ALL']
if self.sl is not None:
os.environ['SWIFT_LOCALEDIR'] = self.sl
else:
del os.environ['SWIFT_LOCALEDIR']
threading._DummyThread._Thread__stop = self.orig_stop
def test_translations(self):
path = ':'.join(sys.path)
translated_message = check_output(['python', __file__, path])
@ -40,6 +58,8 @@ class TestTranslations(unittest.TestCase):
if __name__ == "__main__":
os.environ['LC_ALL'] = 'eo'
os.environ['SWIFT_LOCALEDIR'] = os.path.dirname(__file__)
sys.path = string.split(sys.argv[1], ':')
from swift import gettext_ as _
print _('test message')