Browse Source

Remove the compiled translations for testing

sh4nks 10 years ago
parent
commit
3912afaf9e
1 changed files with 15 additions and 0 deletions
  1. 15 0
      tests/unit/utils/test_translations.py

+ 15 - 0
tests/unit/utils/test_translations.py

@@ -6,9 +6,21 @@ from flaskbb.utils.translations import FlaskBBDomain
 from flaskbb.extensions import plugin_manager
 
 
+def _remove_compiled_translations():
+    translations_folder = os.path.join(current_app.root_path, "translations")
+
+    # walks through the translations folder and deletes all files
+    # ending with .mo
+    for root, dirs, files in os.walk(translations_folder):
+        for name in files:
+            if name.endswith(".mo"):
+                os.unlink(os.path.join(root, name))
+
+
 def _compile_translations():
     PLUGINS_FOLDER = os.path.join(current_app.root_path, "plugins")
     translations_folder = os.path.join(current_app.root_path, "translations")
+
     subprocess.call(["pybabel", "compile", "-d", translations_folder])
 
     for plugin in plugin_manager.all_plugins:
@@ -23,6 +35,9 @@ def test_flaskbbdomain_translations(default_settings):
     with current_app.test_request_context():
         assert domain.get_translations_cache() == {}
 
+        # just to be on the safe side that there are really no compiled
+        # translations available
+        _remove_compiled_translations()
         # no compiled translations are available
         assert isinstance(domain.get_translations(), NullTranslations)