Utilities for localized Django projects
Project description
Data Processing
clean_unicode
utils.clean_unicode accepts an input string and returns normalized Unicode
UnicodeNormalizerMixin
Model mixin class which ensures that every text field has been processed with clean_unicode during model validation’s clean_fields step
Testing
TranslationSafeTestClient
Django TestClient subclass which resets the active translation after each request to avoid leaking translation state across tests, causing hard-to-debug side-effects like loading fixtures in the wrong language using django-modeltranslation.
Usage:
from django_i18n_utils.testclients import TranslationSafeTestClient class MyTestCase(TestCase): client_class = TranslationSafeTestClient def test_foo(self): # default language active self.client.get('/pt/myview') # Portuguese active when the view executes # default language active again
TranslationSafeTestCase
Django TestCase subclass which uses TranslationSafeTestClient to avoid test failures caused by previous tests leaving an unexpected locale active.
Usage:
from django_i18n_utils.testcases import TranslationSafeTestCase class MyTestCase(TranslationSafeTestCase): …
LocalizedTestCase
Django TestCase subclass which makes it easy to create per-language tests without duplication or for-loops:
class MyLocalizedTests(LocalizedTestCase): def test_homepage(self): …
will execute and display as if you had really created this:
class MyLocalizedTests(LocalizedTestCase): def test_homepage_en(self): … # test English def test_homepage_es(self): … # test Spanish
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-i18n-utils-1.6.0b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e46e7024cb88292a35a615fa646d933b504a64c1ed100ea1c296bc04a3ea70b |
|
MD5 | 801616a2ea5bcc353acea6ff763278d0 |
|
BLAKE2b-256 | 27990a9a018ebfd94b93932e9164b44aef6f97b7c89632eca8f06ec8fee3ddc6 |
Hashes for django_i18n_utils-1.6.0b0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cef5a86d0c0833915957bf0a9825fe584391cdea83cfcb875f2b5d8e933234c8 |
|
MD5 | 6936587e78410bc936692db565c5d4a2 |
|
BLAKE2b-256 | f97d36acc835b79a6cedac154eab7b35f80c65b76ca0d25e2183ca97de3d84ea |