From c7e65db27da59ddf221d1720362434581ef30311 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Fri, 4 Oct 2013 23:18:07 -0600 Subject: [PATCH] Make test_translations test our tree In order to run the correct classes, Python test framework adjusts sys.path. However, these changes are not propagated to subprocesses. Therefore, the test actually tries to test installed Swift, not the one in which it is running. The usual suggestion is to run "python setup.py develop" before testing, but it's annoying and error-prone. If you forget it, you may test the code in /usr very easily, and never know. Let's just pass the correct path to subprocess. Much safer. Change-Id: Ic71314e8462cf6e0579d704ffe9fbbfac7e6ba24 --- test/unit/locale/test_locale.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/unit/locale/test_locale.py b/test/unit/locale/test_locale.py index 75ff5e5f15..e77f7e6da3 100644 --- a/test/unit/locale/test_locale.py +++ b/test/unit/locale/test_locale.py @@ -3,6 +3,8 @@ import os import unittest +import string +import sys try: from subprocess import check_output @@ -27,15 +29,17 @@ except ImportError: os.environ['LC_ALL'] = 'eo' os.environ['SWIFT_LOCALEDIR'] = os.path.dirname(__file__) -from swift import gettext_ as _ class TestTranslations(unittest.TestCase): def test_translations(self): - translated_message = check_output(['python', __file__]) + path = ':'.join(sys.path) + translated_message = check_output(['python', __file__, path]) self.assertEquals(translated_message, 'testo mesaĝon\n') if __name__ == "__main__": + sys.path = string.split(sys.argv[1], ':') + from swift import gettext_ as _ print _('test message')