mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Modernize code base to Python 3+ syntax
Replaces syntax that was relevant in earlier Python versions but that now has modernized equivalents.
This commit is contained in:
parent
2cd1d44576
commit
d43b786b30
37 changed files with 104 additions and 171 deletions
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import locale
|
||||
import os
|
||||
from shutil import copy, rmtree
|
||||
|
|
@ -27,7 +25,7 @@ CONTENT_DIR = os.path.join(CUR_DIR, 'content')
|
|||
class TestGenerator(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.old_locale = locale.setlocale(locale.LC_ALL)
|
||||
locale.setlocale(locale.LC_ALL, str('C'))
|
||||
locale.setlocale(locale.LC_ALL, 'C')
|
||||
self.settings = get_settings()
|
||||
self.settings['READERS'] = {'asc': None}
|
||||
self.generator = Generator(self.settings.copy(), self.settings,
|
||||
|
|
@ -403,7 +401,7 @@ class TestArticlesGenerator(unittest.TestCase):
|
|||
'period' : a tuple of year, month, day according to the time period
|
||||
"""
|
||||
old_locale = locale.setlocale(locale.LC_ALL)
|
||||
locale.setlocale(locale.LC_ALL, str('C'))
|
||||
locale.setlocale(locale.LC_ALL, 'C')
|
||||
settings = get_settings()
|
||||
|
||||
settings['YEAR_ARCHIVE_SAVE_AS'] = 'posts/{date:%Y}/index.html'
|
||||
|
|
@ -788,7 +786,7 @@ class TestTemplatePagesGenerator(unittest.TestCase):
|
|||
self.temp_content = mkdtemp(prefix='pelicantests.')
|
||||
self.temp_output = 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):
|
||||
rmtree(self.temp_content)
|
||||
|
|
@ -823,7 +821,7 @@ class TestTemplatePagesGenerator(unittest.TestCase):
|
|||
self.assertTrue(os.path.exists(output_path))
|
||||
|
||||
# output content is correct
|
||||
with open(output_path, 'r') as output_file:
|
||||
with open(output_path) as output_file:
|
||||
self.assertEqual(output_file.read(), 'foo: bar')
|
||||
|
||||
|
||||
|
|
@ -1013,7 +1011,7 @@ class TestStaticGenerator(unittest.TestCase):
|
|||
f.write("staticcontent")
|
||||
self.generator.generate_context()
|
||||
self.generator.generate_output(None)
|
||||
with open(self.endfile, "r") as f:
|
||||
with open(self.endfile) as f:
|
||||
self.assertEqual(f.read(), "staticcontent")
|
||||
|
||||
@unittest.skipUnless(MagicMock, 'Needs Mock module')
|
||||
|
|
@ -1162,7 +1160,7 @@ class TestJinja2Environment(unittest.TestCase):
|
|||
self.temp_content = mkdtemp(prefix='pelicantests.')
|
||||
self.temp_output = 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):
|
||||
rmtree(self.temp_content)
|
||||
|
|
@ -1197,7 +1195,7 @@ class TestJinja2Environment(unittest.TestCase):
|
|||
self.assertTrue(os.path.exists(output_path))
|
||||
|
||||
# output content is correct
|
||||
with open(output_path, 'r') as output_file:
|
||||
with open(output_path) as output_file:
|
||||
self.assertEqual(output_file.read(), expected)
|
||||
|
||||
def test_jinja2_filter(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue