Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail when LANG environment variable is set to German #3060

Closed
k-nut opened this issue May 26, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@k-nut
Copy link
Contributor

commented May 26, 2016

CKAN Version if known (or site URL)

2.6.0a

Please describe the expected behaviour

All the tests on master pass

Please describe the actual behaviour

Two tests in /ckan/tests/legacy/lib/test_navl.py are failing. Output:

..........FF
======================================================================
FAIL: ckan.tests.legacy.lib.test_navl.test_formencode_compat
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/knut/.virtualenvs/ckan/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/knut/viderum/ckan/ckan/tests/legacy/lib/test_navl.py", line 334, in test_formencode_compat
    assert errors == {'email': [u'An email address must contain a single @']}, errors
AssertionError: {'email': [u'Eine E-Mail-Adresse muss genau ein @-Zeichen enthalten']}

======================================================================
FAIL: ckan.tests.legacy.lib.test_navl.test_range_validator
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/knut/.virtualenvs/ckan/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/knut/viderum/ckan/ckan/tests/legacy/lib/test_navl.py", line 350, in test_range_validator
    assert errors == {'name': [u'Missing value'], 'email': [u'Please enter a number that is 10 or smaller']}, errors
AssertionError: {'email': [u'Bitte geben Sie eine Zahl ein, die kleiner oder gleich 10 ist'], 'name': [u'Missing value']}

When run with LANG set to en_US.UTF-8 the tests pass:

user@host:$ LANG="en_US.UTF-8" nosetests --ckan --with-pylons=test-core.ini ckan/tests/legacy/lib/test_navl.py
............
----------------------------------------------------------------------
Ran 12 tests in 0.005s

OK

What steps can be taken to reproduce the issue?

Run the tests with a non English LANG:

LANG="de_DE.UTF-8" nosetests --ckan --with-pylons=test-core.ini ckan/tests/legacy/lib/test_navl.py
@k-nut

This comment has been minimized.

Copy link
Contributor Author

commented May 26, 2016

Point 3 from this part of the documentation of formencode seems to be relevant here.

k-nut added a commit to k-nut/ckan that referenced this issue May 27, 2016

[ckan#3060] set ckan.locale_default as language for FormEncode
- If this is not done FormEncode takes the system LANG for its
  validation messages which might lead to unexpected behaviour.
- This also leads to the tests passing on machines where the LANG is
  set to something other then `en`
- More information can be found at
  http://www.formencode.org/en/latest/Validator.html#localization-of-error-messages-i18n

k-nut added a commit to k-nut/ckan that referenced this issue Jun 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.