diff test/test_liveserver.py @ 6650:5be4f9104cf7

Make i18n tests work These use installed roundup locales but should use the checked-out locales. Also revert monkey patches in i18n after the test.
author Ralf Schlatterbeck <rsc@runtux.com>
date Mon, 02 May 2022 13:46:58 +0200
parents 53c9b62494e6
children da6c9050a79e
line wrap: on
line diff
--- a/test/test_liveserver.py	Thu Apr 28 19:21:08 2022 -0400
+++ b/test/test_liveserver.py	Mon May 02 13:46:58 2022 +0200
@@ -1,5 +1,6 @@
 import shutil, errno, pytest, json, gzip, os, re
 
+from roundup import i18n
 from roundup.anypy.strings import b2s
 from roundup.cgi.wsgi_handler import RequestDispatcher
 from .wsgi_liveserver import LiveServerTestCase
@@ -40,7 +41,7 @@
 class SimpleTest(LiveServerTestCase):
     # have chicken and egg issue here. Need to encode the base_url
     # in the config file but we don't know it until after
-    # the server is started nd has read the config.ini.
+    # the server is started and has read the config.ini.
     # so only allow one port number
     port_range = (9001, 9001)  # default is (8080, 8090)
 
@@ -49,7 +50,7 @@
     
     @classmethod
     def setup_class(cls):
-        '''All test in this class use the same roundup instance.
+        '''All tests in this class use the same roundup instance.
            This instance persists across all tests.
            Create the tracker dir here so that it is ready for the
            create_app() method to be called.
@@ -75,6 +76,13 @@
 
         cls.db.commit()
         cls.db.close()
+        
+        # Force locale config to find locales in checkout not in
+        # installed directories
+        cls.backup_domain = i18n.DOMAIN
+        cls.backup_locale_dirs = i18n.LOCALE_DIRS
+        i18n.LOCALE_DIRS = ['locale']
+        i18n.DOMAIN = ''
 
     @classmethod
     def teardown_class(cls):
@@ -87,6 +95,8 @@
             shutil.rmtree(cls.dirname)
         except OSError as error:
             if error.errno not in (errno.ENOENT, errno.ESRCH): raise
+        i18n.LOCALE_DIRS = cls.backup_locale_dirs
+        i18n.DOMAIN = cls.backup_domain
 
     def create_app(self):
         '''The wsgi app to start'''

Roundup Issue Tracker: http://roundup-tracker.org/