mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #1307 from al-tonio/datetestfix
Fix unittest issue related to python2/python3 differences
This commit is contained in:
commit
66a16b560f
1 changed files with 9 additions and 3 deletions
|
|
@ -129,9 +129,15 @@ class TestPage(unittest.TestCase):
|
||||||
page_kwargs['metadata']['date'] = dt
|
page_kwargs['metadata']['date'] = dt
|
||||||
page = Page(**page_kwargs)
|
page = Page(**page_kwargs)
|
||||||
|
|
||||||
self.assertEqual(page.locale_date,
|
# page.locale_date is a unicode string in both python2 and python3
|
||||||
dt.strftime(DEFAULT_CONFIG['DEFAULT_DATE_FORMAT']))
|
dt_date = dt.strftime(DEFAULT_CONFIG['DEFAULT_DATE_FORMAT'])
|
||||||
|
# dt_date is a byte string in python2, and a unicode string in python3
|
||||||
|
# Let's make sure it is a unicode string (relies on python 3.3 supporting the u prefix)
|
||||||
|
if type(dt_date) != type(u''):
|
||||||
|
# python2:
|
||||||
|
dt_date = unicode(dt_date, 'utf8')
|
||||||
|
|
||||||
|
self.assertEqual(page.locale_date, dt_date )
|
||||||
page_kwargs['settings'] = get_settings()
|
page_kwargs['settings'] = get_settings()
|
||||||
|
|
||||||
# I doubt this can work on all platforms ...
|
# I doubt this can work on all platforms ...
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue