MCPcopy
hub / github.com/django/django / test_safe_status

Method test_safe_status

tests/i18n/tests.py:417–433  ·  view source on GitHub ↗

Translating a string requiring no auto-escaping with gettext or pgettext shouldn't change the "safe" status.

(self)

Source from the content-addressed store, hash-verified

415
416 @override_settings(LOCALE_PATHS=extended_locale_paths)
417 def test_safe_status(self):
418 """
419 Translating a string requiring no auto-escaping with gettext or
420 pgettext shouldn't change the "safe" status.
421 """
422 trans_real._active = Local()
423 trans_real._translations = {}
424 s1 = mark_safe("Password")
425 s2 = mark_safe("May")
426 with translation.override("de", deactivate=True):
427 self.assertIs(type(gettext(s1)), SafeString)
428 self.assertIs(type(pgettext("month name", s2)), SafeString)
429 self.assertEqual("aPassword", SafeString("a") + s1)
430 self.assertEqual("Passworda", s1 + SafeString("a"))
431 self.assertEqual("Passworda", s1 + mark_safe("a"))
432 self.assertEqual("aPassword", mark_safe("a") + s1)
433 self.assertEqual("as", mark_safe("a") + mark_safe("s"))
434
435 def test_maclines(self):
436 """

Callers

nothing calls this directly

Calls 4

mark_safeFunction · 0.90
gettextFunction · 0.90
pgettextFunction · 0.90
SafeStringClass · 0.90

Tested by

no test coverage detected