|
3 | 3 | from .helpers.ptrack_helpersimportProbackupTest,ProbackupException |
4 | 4 | importlocale |
5 | 5 |
|
6 | | - |
7 | 6 | classOptionTest(ProbackupTest,unittest.TestCase): |
8 | 7 |
|
9 | 8 | # @unittest.skip("skip") |
@@ -220,12 +219,28 @@ def test_options_5(self): |
220 | 219 | deftest_help_6(self): |
221 | 220 | """help options""" |
222 | 221 | ifProbackupTest.enable_nls: |
223 | | -self.test_env['LC_ALL']='ru_RU.utf-8' |
224 | | -withopen(os.path.join(self.dir_path,"expected/option_help_ru.out"),"rb")ashelp_out: |
225 | | -self.assertEqual( |
226 | | -self.run_pb(["--help"]), |
227 | | -help_out.read().decode("utf-8") |
228 | | - ) |
| 222 | +ifcheck_locale('ru_RU.utf-8'): |
| 223 | +self.test_env['LC_ALL']='ru_RU.utf-8' |
| 224 | +withopen(os.path.join(self.dir_path,"expected/option_help_ru.out"),"rb")ashelp_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") |
229 | 232 | else: |
230 | 233 | self.skipTest( |
231 | 234 | 'You need configure PostgreSQL with --enabled-nls option for this test') |
| 235 | + |
| 236 | + |
| 237 | +defcheck_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 | +exceptlocale.Error: |
| 243 | +ret=False |
| 244 | +finally: |
| 245 | +locale.setlocale(locale.LC_CTYPE,old_locale) |
| 246 | +returnret |