@@ -677,7 +677,8 @@ def test_raise_descriptive_error_for_incorrect_content_type(self):
677677 )
678678 with self .assertRaisesRegex (
679679 ValueError ,
680- "expected 'charset=' in Content-Type metadata in gettext.mo, got 'text/plain; charste=UTF-8'"
680+ "expected 'charset=' in Content-Type metadata in xx/LC_MESSAGES/gettext.mo, "
681+ "got 'text/plain; charste=UTF-8'"
681682 ):
682683 with open (MOFILE , 'rb' ) as fp :
683684 gettext .GNUTranslations (fp )
@@ -687,15 +688,36 @@ def test_raise_descriptive_error_for_incorrect_plural_forms(self):
687688 # below is msgfmt run on such a PO file:
688689 # msgid ""
689690 # msgstr ""
690- # "Content-Type: text/plain; charset=UTF-8\n"
691691 # "Plural-Forms: \n"
692692 fp .write (
693693 b'\xde \x12 \x04 \x95 \x00 \x00 \x00 \x00 \x01 \x00 \x00 \x00 \x1c \x00 \x00 \x00 $\x00 \x00 \x00 \x03 \x00 \x00 \x00 ,\x00 '
694- b'\x00 \x00 \x00 \x00 \x00 \x00 8\x00 \x00 \x00 7 \ x00\x00 \x00 9\x00 \x00 \x00 \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 '
695- b'\x00 \x00 \x00 \x00 Content-Type: text/plain; charset=UTF-8 \n Plural -Forms: \n \x00 '
694+ b'\x00 \x00 \x00 \x00 \x00 \x00 8\x00 \x00 \x00 \x0f \ x00\x00 \x00 9\x00 \x00 \x00 \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 '
695+ b'\x00 \x00 \x00 \x00 \x00 Plural -Forms: \n \x00 '
696696 )
697697 with self .assertRaisesRegex (
698- ValueError , "expected ';' and 'plural=' in Plural-Forms metadata in gettext.mo, got ''"
698+ ValueError ,
699+ "expected ';' and 'plural=' in Plural-Forms metadata in xx/LC_MESSAGES/gettext.mo, got ''"
700+ ):
701+ with open (MOFILE , 'rb' ) as fp :
702+ gettext .GNUTranslations (fp )
703+
704+
705+ def test_raise_descriptive_error_for_incorrect_plural_forms_with_semicolon (self ):
706+ with open (MOFILE , 'wb' ) as fp :
707+ # below is msgfmt run on such a PO file:
708+ # msgid ""
709+ # msgstr ""
710+ # "Plural-Forms: nplurals=1; prulal=0;\n"
711+ fp .write (
712+ b'\xde \x12 \x04 \x95 \x00 \x00 \x00 \x00 \x01 \x00 \x00 \x00 \x1c \x00 \x00 \x00 $\x00 \x00 \x00 \x03 \x00 \x00 \x00 ,\x00 '
713+ b'\x00 \x00 \x00 \x00 \x00 \x00 8\x00 \x00 \x00 $\x00 \x00 \x00 9\x00 \x00 \x00 \x01 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 '
714+ b'\x00 \x00 \x00 \x00 Plural-Forms: nplurals=1; prulal=0;\n \x00 '
715+
716+ )
717+ with self .assertRaisesRegex (
718+ ValueError ,
719+ "expected ';' and 'plural=' in Plural-Forms metadata in xx/LC_MESSAGES/gettext.mo, "
720+ "got 'nplurals=1; prulal=0;'"
699721 ):
700722 with open (MOFILE , 'rb' ) as fp :
701723 gettext .GNUTranslations (fp )
0 commit comments