示例#1
0
    def test_clean_error_display_with_one_token(self):
        form = TranslationForm({
            'msgid': "Something {important} to format.",
            'translation': "Rien a formater.",
            'fuzzy': False,
        })
        self.assertEqual(len(form.non_field_errors()), 1)

        error_message = form.non_field_errors()[0]
        self.assertIn(
            'There should be 1 formating token(s) in the source text and the translation.',
            error_message)
示例#2
0
 def test_clean_fail_with_missing_py3_indexed_format_token_in_source(self):
     form = TranslationForm({
         'msgid': "Nothing to format.",
         'translation': "Ri{1} a formater.",
         'fuzzy': False,
     })
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.non_field_errors()), 1)
示例#3
0
 def test_clean_fail_with_missing_template_variable_in_translation(self):
     form = TranslationForm({
         'msgid': "Something {{ important }} to format.",
         'translation': "Rien a formater.",
         'fuzzy': False,
     })
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.non_field_errors()), 1)
示例#4
0
 def test_clean_fail_with_missing_template_variable_in_source(self):
     form = TranslationForm({
         'msgid': "Nothing to format.",
         'translation': "Rien a formater {{ actuellement }}.",
         'fuzzy': False,
     })
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.non_field_errors()), 1)
示例#5
0
 def test_clean_fail_with_missing_py2_format_token_in_translation(self):
     form = TranslationForm({
         'msgid': "Something %(important)s to format.",
         'translation': "Rien a formater.",
         'fuzzy': False,
     })
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.non_field_errors()), 1)
示例#6
0
 def test_clean_fail_with_missing_py3_format_tokens_in_both_source_and_translation(
         self):
     form = TranslationForm({
         'msgid': "Nothing {important} to format.",
         'translation': "Rien {important} a formater {lol}.",
         'fuzzy': False,
     })
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.non_field_errors()), 1)