Increased django.utils.translation.trans_null test coverage.

This commit is contained in:
Hasan Ramezani 2018-05-11 00:18:00 +04:30 committed by Tim Graham
parent ac59ec8f1a
commit 305dee7bf9
1 changed files with 15 additions and 0 deletions

View File

@ -297,6 +297,11 @@ class TranslationTests(SimpleTestCase):
with translation.override(None):
self.assertIs(get_language_bidi(), False)
def test_language_bidi_null(self):
self.assertIs(trans_null.get_language_bidi(), False)
with override_settings(LANGUAGE_CODE='he'):
self.assertIs(get_language_bidi(), True)
class TranslationThreadSafetyTests(SimpleTestCase):
@ -1649,6 +1654,9 @@ class CountrySpecificLanguageTests(SimpleTestCase):
self.assertFalse(check_for_language('tr-TR.UTF8'))
self.assertFalse(check_for_language('de-DE.utf-8'))
def test_check_for_language_null(self):
self.assertIs(trans_null.check_for_language('en'), True)
def test_get_language_from_request(self):
# issue 19919
r = self.rf.get('/')
@ -1662,6 +1670,13 @@ class CountrySpecificLanguageTests(SimpleTestCase):
lang = get_language_from_request(r)
self.assertEqual('bg', lang)
def test_get_language_from_request_null(self):
lang = trans_null.get_language_from_request(None)
self.assertEqual(lang, 'en')
with override_settings(LANGUAGE_CODE='de'):
lang = trans_null.get_language_from_request(None)
self.assertEqual(lang, 'de')
def test_specific_language_codes(self):
# issue 11915
r = self.rf.get('/')