1. import os
    
  2. 
    
  3. from django.contrib.contenttypes.models import ContentType
    
  4. from django.test import TestCase, override_settings
    
  5. from django.utils import translation
    
  6. 
    
  7. 
    
  8. @override_settings(
    
  9.     USE_I18N=True,
    
  10.     LOCALE_PATHS=[
    
  11.         os.path.join(os.path.dirname(__file__), "locale"),
    
  12.     ],
    
  13.     LANGUAGE_CODE="en",
    
  14.     LANGUAGES=[
    
  15.         ("en", "English"),
    
  16.         ("fr", "French"),
    
  17.     ],
    
  18. )
    
  19. class ContentTypeTests(TestCase):
    
  20.     def test_verbose_name(self):
    
  21.         company_type = ContentType.objects.get(app_label="i18n", model="company")
    
  22.         with translation.override("en"):
    
  23.             self.assertEqual(str(company_type), "i18n | Company")
    
  24.         with translation.override("fr"):
    
  25.             self.assertEqual(str(company_type), "i18n | Société")