diff options
author | Deniz Turgut <dturgut@gmail.com> | 2022-10-26 23:27:06 +0300 |
---|---|---|
committer | Deniz Turgut <dturgut@gmail.com> | 2022-10-26 23:52:38 +0300 |
commit | 3937028c00344dc82798750e5f13a8a1aea890d4 (patch) | |
tree | 0488da7eeb14993fdb60da436c56d596b5b34bab | |
parent | 6ddbc83f43f65bf6c42c72b9bee3756bbb7b5e6e (diff) | |
download | pelican-3937028c00344dc82798750e5f13a8a1aea890d4.tar.gz |
update unit test to avoid using deprecated locale.getdefaultlocale()
-rw-r--r-- | pelican/tests/test_settings.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/pelican/tests/test_settings.py b/pelican/tests/test_settings.py index c407f7c8..0f630ad5 100644 --- a/pelican/tests/test_settings.py +++ b/pelican/tests/test_settings.py @@ -2,7 +2,6 @@ import copy import locale import os from os.path import abspath, dirname, join -from sys import platform from pelican.settings import (DEFAULT_CONFIG, DEFAULT_THEME, @@ -136,18 +135,19 @@ class TestSettingsConfiguration(unittest.TestCase): settings['ARTICLE_DIR'] settings['PAGE_DIR'] - # locale.getdefaultlocale() is broken on Windows - # See: https://bugs.python.org/issue37945 - @unittest.skipIf(platform == 'win32', "Doesn't work on Windows") def test_default_encoding(self): - # Test that the default locale is set if not specified in settings + # Test that the user locale is set if not specified in settings - # Reset locale to Python's default locale locale.setlocale(locale.LC_ALL, 'C') - self.assertEqual(self.settings['LOCALE'], DEFAULT_CONFIG['LOCALE']) + # empty string = user system locale + self.assertEqual(self.settings['LOCALE'], ['']) configure_settings(self.settings) - self.assertEqual(locale.getlocale(), locale.getdefaultlocale()) + lc_time = locale.getlocale(locale.LC_TIME) # should be set to user locale + + # explicitly set locale to user pref and test + locale.setlocale(locale.LC_TIME, '') + self.assertEqual(lc_time, locale.getlocale(locale.LC_TIME)) def test_invalid_settings_throw_exception(self): # Test that the path name is valid |