11import os
22import base64
33import gettext
4+ import sys
45import unittest
56import unittest .mock
67from functools import partial
@@ -664,6 +665,12 @@ def test_ignore_comments_in_headers_issue36239(self):
664665 t = gettext .GNUTranslations (fp )
665666 self .assertEqual (t .info ()["plural-forms" ], "nplurals=2; plural=(n != 1);" )
666667
668+ @property
669+ def expected_filename (self ):
670+ if sys .platform == 'win32' :
671+ return 'xx\LC_MESSAGES\gettext.mo'
672+ return 'xx/LC_MESSAGES/gettext.mo'
673+
667674 def test_raise_descriptive_error_for_incorrect_content_type (self ):
668675 with open (MOFILE , 'wb' ) as fp :
669676 # below is msgfmt run on such a PO file:
@@ -677,8 +684,8 @@ def test_raise_descriptive_error_for_incorrect_content_type(self):
677684 )
678685 with self .assertRaisesRegex (
679686 ValueError ,
680- "expected 'charset=' in Content-Type metadata in xx/LC_MESSAGES/gettext.mo , "
681- "got 'text/plain; charste=UTF-8'"
687+ f "expected 'charset=' in Content-Type metadata in { self . expected_filename } , "
688+ f "got 'text/plain; charste=UTF-8'"
682689 ):
683690 with open (MOFILE , 'rb' ) as fp :
684691 gettext .GNUTranslations (fp )
@@ -696,7 +703,7 @@ def test_raise_descriptive_error_for_incorrect_plural_forms(self):
696703 )
697704 with self .assertRaisesRegex (
698705 ValueError ,
699- "expected ';' and 'plural=' in Plural-Forms metadata in xx/LC_MESSAGES/gettext.mo , got ''"
706+ f "expected ';' and 'plural=' in Plural-Forms metadata in { self . expected_filename } , got ''",
700707 ):
701708 with open (MOFILE , 'rb' ) as fp :
702709 gettext .GNUTranslations (fp )
@@ -716,7 +723,7 @@ def test_raise_descriptive_error_for_incorrect_plural_forms_with_semicolon(self)
716723 )
717724 with self .assertRaisesRegex (
718725 ValueError ,
719- "expected ';' and 'plural=' in Plural-Forms metadata in xx/LC_MESSAGES/gettext.mo , "
726+ f "expected ';' and 'plural=' in Plural-Forms metadata in { self . expected_filename } , "
720727 "got 'nplurals=1; prulal=0;'"
721728 ):
722729 with open (MOFILE , 'rb' ) as fp :
0 commit comments