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.5.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ed0c804898e9fb219f5461b47aa3d17e2f2cbfa4717b10eadc11599c86135a |
|
MD5 | 62c0fc62fe9996c1c9b0d6416e1d8d03 |
|
BLAKE2b-256 | 7048e28e5a108053f489cdfc5b87b76b577a229d5e4e8c230bdd15ec4de5b7c2 |