diff options
author | Justin Mayer <entroP@gmail.com> | 2020-04-26 09:55:08 +0200 |
---|---|---|
committer | Justin Mayer <entroP@gmail.com> | 2020-04-27 09:45:31 +0200 |
commit | d43b786b300358e8a4cbae4afc4052199a7af762 (patch) | |
tree | 8c2231297301b1eb307e3c132ca4710cacd5eef0 /pelican/tests/test_utils.py | |
parent | 2cd1d44576ecc4fd0cc532cbb19c2b934ab5c665 (diff) | |
download | pelican-remove-legacy.tar.gz |
Modernize code base to Python 3+ syntaxremove-legacy
Replaces syntax that was relevant in earlier Python versions but that
now has modernized equivalents.
Diffstat (limited to 'pelican/tests/test_utils.py')
-rw-r--r-- | pelican/tests/test_utils.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 4a03cdc4..f0bc290d 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import locale import logging import os @@ -480,9 +478,9 @@ class TestUtils(LoggedTestCase): old_locale = locale.setlocale(locale.LC_ALL) if platform == 'win32': - locale.setlocale(locale.LC_ALL, str('Turkish')) + locale.setlocale(locale.LC_ALL, 'Turkish') else: - locale.setlocale(locale.LC_ALL, str('tr_TR.UTF-8')) + locale.setlocale(locale.LC_ALL, 'tr_TR.UTF-8') d = utils.SafeDatetime(2012, 8, 29) @@ -514,9 +512,9 @@ class TestUtils(LoggedTestCase): old_locale = locale.setlocale(locale.LC_ALL) if platform == 'win32': - locale.setlocale(locale.LC_ALL, str('French')) + locale.setlocale(locale.LC_ALL, 'French') else: - locale.setlocale(locale.LC_ALL, str('fr_FR.UTF-8')) + locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') d = utils.SafeDatetime(2012, 8, 29) @@ -557,7 +555,7 @@ class TestCopy(unittest.TestCase): def setUp(self): self.root_dir = mkdtemp(prefix='pelicantests.') self.old_locale = locale.setlocale(locale.LC_ALL) - locale.setlocale(locale.LC_ALL, str('C')) + locale.setlocale(locale.LC_ALL, 'C') def tearDown(self): shutil.rmtree(self.root_dir) @@ -666,26 +664,26 @@ class TestDateFormatter(unittest.TestCase): # This test tries to reproduce an issue that # occurred with python3.3 under macos10 only if platform == 'win32': - locale.setlocale(locale.LC_ALL, str('French')) + locale.setlocale(locale.LC_ALL, 'French') else: - locale.setlocale(locale.LC_ALL, str('fr_FR.UTF-8')) + locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') date = utils.SafeDatetime(2014, 8, 14) # we compare the lower() dates since macos10 returns # "Jeudi" for %A whereas linux reports "jeudi" self.assertEqual( - u'jeudi, 14 août 2014', + 'jeudi, 14 août 2014', utils.strftime(date, date_format="%A, %d %B %Y").lower()) df = utils.DateFormatter() self.assertEqual( - u'jeudi, 14 août 2014', + 'jeudi, 14 août 2014', df(date, date_format="%A, %d %B %Y").lower()) # Let us now set the global locale to C: - locale.setlocale(locale.LC_ALL, str('C')) + locale.setlocale(locale.LC_ALL, 'C') # DateFormatter should still work as expected # since it is the whole point of DateFormatter # (This is where pre-2014/4/15 code fails on macos10) df_date = df(date, date_format="%A, %d %B %Y").lower() - self.assertEqual(u'jeudi, 14 août 2014', df_date) + self.assertEqual('jeudi, 14 août 2014', df_date) @unittest.skipUnless(locale_available('fr_FR.UTF-8') or locale_available('French'), |