From 63370ea466fb1ae4eb8f29ef5318c50a5a0356ae Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Sat, 5 Oct 2013 11:12:43 -0400 Subject: [PATCH] Quiet all locale warnings and dummy thread, too Change-Id: I0c68b94ec234e470ce2d50da01d8ae1cd10fae58 Signed-off-by: Peter Portante --- test/unit/locale/test_locale.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/test/unit/locale/test_locale.py b/test/unit/locale/test_locale.py index e77f7e6da3..38cc6e676f 100644 --- a/test/unit/locale/test_locale.py +++ b/test/unit/locale/test_locale.py @@ -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')