File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change 33from .helpers .ptrack_helpers import ProbackupTest , ProbackupException
44import locale
55
6-
76class OptionTest (ProbackupTest , unittest .TestCase ):
87
98 # @unittest.skip("skip")
@@ -220,12 +219,28 @@ def test_options_5(self):
220219 def test_help_6 (self ):
221220 """help options"""
222221 if ProbackupTest .enable_nls :
223- self .test_env ['LC_ALL' ] = 'ru_RU.utf-8'
224- with open (os .path .join (self .dir_path , "expected/option_help_ru.out" ), "rb" ) as help_out :
225- self .assertEqual (
226- self .run_pb (["--help" ]),
227- help_out .read ().decode ("utf-8" )
228- )
222+ if check_locale ('ru_RU.utf-8' ):
223+ self .test_env ['LC_ALL' ] = 'ru_RU.utf-8'
224+ with open (os .path .join (self .dir_path , "expected/option_help_ru.out" ), "rb" ) as help_out :
225+ self .assertEqual (
226+ self .run_pb (["--help" ]),
227+ help_out .read ().decode ("utf-8" )
228+ )
229+ else :
230+ self .skipTest (
231+ "Locale ru_RU.utf-8 doesn't work. You need install ru_RU.utf-8 locale for this test" )
229232 else :
230233 self .skipTest (
231234 'You need configure PostgreSQL with --enabled-nls option for this test' )
235+
236+
237+ def check_locale (locale_name ):
238+ ret = True
239+ old_locale = locale .setlocale (locale .LC_CTYPE ,"" )
240+ try :
241+ locale .setlocale (locale .LC_CTYPE , locale_name )
242+ except locale .Error :
243+ ret = False
244+ finally :
245+ locale .setlocale (locale .LC_CTYPE , old_locale )
246+ return ret
You can’t perform that action at this time.
0 commit comments