Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 49bb374

Browse filesBrowse files
committed
[PBCKP-365] Fixed test help_6 test. Added check_locale function for check that locale is installed.
1 parent 610216c commit 49bb374
Copy full SHA for 49bb374

File tree

Expand file treeCollapse file tree

1 file changed

+22
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-7
lines changed

‎tests/option_test.py

Copy file name to clipboardExpand all lines: tests/option_test.py
+22-7Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
44
import locale
55

6-
76
class 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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.