[PATCH 1 of 2] tests: fix failures due to environment LANG settings (Issue #286)

Thomas De Schampheleire patrickdepinguin at gmail.com
Wed Jul 5 19:20:53 UTC 2017


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1499281697 -7200
#      Mi Jul 05 21:08:17 2017 +0200
# Node ID 03d04f1f39a2d90a6e3a76b5840eba8c7a84eff8
# Parent  ffb70a338ce1c708c9526461f3fca425fff4d841
tests: fix failures due to environment LANG settings (Issue #286)

When the environment in which the tests are run dictates a non-English
language (e.g. via LANG=de_DE.UTF-8), certain tests started to fail because
formencode validation messages where translated in that language.

A test failing this way is for example
test_create_in_group_without_needed_permissions in
kallithea/tests/functional/test_admin_repos.py .

This is a regression of commit 3b29103657df (i18n: remove explicit
formencode language setting), but in fact reverting it is not the right
solution as there is no problem except during test execution.

Instead, force the formencode language to 'empty' (meaning English) for test
execution only.

See also http://www.formencode.org/en/latest/i18n.html

diff --git a/kallithea/tests/conftest.py b/kallithea/tests/conftest.py
--- a/kallithea/tests/conftest.py
+++ b/kallithea/tests/conftest.py
@@ -4,6 +4,7 @@ import logging
 import pkg_resources
 import time
 
+import formencode
 from paste.deploy import loadwsgi
 from routes.util import URLGenerator
 import pytest
@@ -57,6 +58,8 @@ def pytest_configure():
 
     kallithea.tests.base.url = URLGenerator(RootController().mapper, {'HTTP_HOST': 'example.com'})
 
+    # set fixed language for form messages, regardless of environment settings
+    formencode.api.set_stdtranslation(languages=[])
 
 @pytest.fixture
 def create_test_user():


More information about the kallithea-general mailing list