1
0
Fork 0
forked from github/pelican

Fix test errors on OSX

On OSX, if LC_TIME and LC_CTYPE differs the output of strftime is not properly decoded
in Python 3. This makes sure that the 'utils.DateFormatter' and the related Jinja filter
'strftime' set the same value for LC_TIME and LC_CTYPE while formatting.

Also, '%a' is removed from DEFAULT_DATE_FORMAT in 'custom_locale' tests. OSX and *nix have
different conversions for '%a' ('Jeu' vs 'jeu.') and there is not a feasible way to handle
the difference for tests.
This commit is contained in:
Deniz Turgut 2014-06-26 00:51:45 -04:00
commit 009543b7e4
33 changed files with 137 additions and 130 deletions

View file

@ -91,7 +91,7 @@ functional tests. To do so, you can use the following two commands::
$ LC_ALL=en_US.utf8 pelican -o pelican/tests/output/custom/ \
-s samples/pelican.conf.py samples/content/
$ LC_ALL=fr_FR.utf8 pelican -o pelican/tests/output/custom_locale/ \
-s samples/pelican_FR.conf.py samples/content/
-s samples/pelican.conf_FR.py samples/content/
$ LC_ALL=en_US.utf8 pelican -o pelican/tests/output/basic/ \
samples/content/

View file

@ -32,25 +32,25 @@
<h1>Archives for Alexis' log</h1>
<dl>
<dt>ven. 30 novembre 2012</dt>
<dt>30 novembre 2012</dt>
<dd><a href="./posts/2012/novembre/30/filename_metadata-example/">FILENAME_METADATA example</a></dd>
<dt>mer. 29 février 2012</dt>
<dt>29 février 2012</dt>
<dd><a href="./posts/2012/février/29/second-article/">Second article</a></dd>
<dt>mer. 20 avril 2011</dt>
<dt>20 avril 2011</dt>
<dd><a href="./posts/2011/avril/20/a-markdown-powered-article/">A markdown powered article</a></dd>
<dt>jeu. 17 février 2011</dt>
<dt>17 février 2011</dt>
<dd><a href="./posts/2011/février/17/article-1/">Article 1</a></dd>
<dt>jeu. 17 février 2011</dt>
<dt>17 février 2011</dt>
<dd><a href="./posts/2011/février/17/article-2/">Article 2</a></dd>
<dt>jeu. 17 février 2011</dt>
<dt>17 février 2011</dt>
<dd><a href="./posts/2011/février/17/article-3/">Article 3</a></dd>
<dt>jeu. 02 décembre 2010</dt>
<dt>02 décembre 2010</dt>
<dd><a href="./posts/2010/décembre/02/this-is-a-super-article/">This is a super article !</a></dd>
<dt>mer. 20 octobre 2010</dt>
<dt>20 octobre 2010</dt>
<dd><a href="./posts/2010/octobre/20/oh-yeah/">Oh yeah !</a></dd>
<dt>ven. 15 octobre 2010</dt>
<dt>15 octobre 2010</dt>
<dd><a href="./posts/2010/octobre/15/unbelievable/">Unbelievable !</a></dd>
<dt>dim. 14 mars 2010</dt>
<dt>14 mars 2010</dt>
<dd><a href="./tag/baz.html">The baz tag</a></dd>
</dl>
</section>

View file

@ -34,7 +34,7 @@
<h1 class="entry-title"><a href="../posts/2012/novembre/30/filename_metadata-example/">FILENAME_METADATA example</a></h1>
<footer class="post-info">
<abbr class="published" title="2012-11-30T00:00:00">
Published: ven. 30 novembre 2012
Published: 30 novembre 2012
</abbr>
<address class="vcard author">
@ -59,7 +59,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2012-02-29T00:00:00">
Published: mer. 29 février 2012
Published: 29 février 2012
</abbr>
<address class="vcard author">
@ -84,7 +84,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-04-20T00:00:00">
Published: mer. 20 avril 2011
Published: 20 avril 2011
</abbr>
<address class="vcard author">
@ -108,7 +108,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">

View file

@ -40,7 +40,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">
@ -63,7 +63,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">
@ -86,11 +86,11 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-12-02T10:14:00">
Published: jeu. 02 décembre 2010
Published: 02 décembre 2010
</abbr>
<br />
<abbr class="modified" title="2013-11-17T23:29:00">
Updated: dim. 17 novembre 2013
Updated: 17 novembre 2013
</abbr>
<address class="vcard author">
@ -114,7 +114,7 @@ as well as <strong>inline markup</strong>.</p>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-10-20T10:14:00">
Published: mer. 20 octobre 2010
Published: 20 octobre 2010
</abbr>
<address class="vcard author">

View file

@ -40,7 +40,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-10-15T20:30:00">
Published: ven. 15 octobre 2010
Published: 15 octobre 2010
</abbr>
<address class="vcard author">
@ -73,7 +73,7 @@ pelican.conf, it ...</p></div>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-03-14T00:00:00">
Published: dim. 14 mars 2010
Published: 14 mars 2010
</abbr>
<address class="vcard author">

View file

@ -34,7 +34,7 @@
<h1 class="entry-title"><a href="../posts/2010/octobre/20/oh-yeah/">Oh yeah !</a></h1>
<footer class="post-info">
<abbr class="published" title="2010-10-20T10:14:00">
Published: mer. 20 octobre 2010
Published: 20 octobre 2010
</abbr>
<address class="vcard author">

View file

@ -34,7 +34,7 @@
<h1 class="entry-title"><a href="../posts/2011/avril/20/a-markdown-powered-article/">A markdown powered article</a></h1>
<footer class="post-info">
<abbr class="published" title="2011-04-20T00:00:00">
Published: mer. 20 avril 2011
Published: 20 avril 2011
</abbr>
<address class="vcard author">
@ -60,7 +60,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">
@ -83,7 +83,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">
@ -106,7 +106,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">

View file

@ -34,7 +34,7 @@
<h1 class="entry-title"><a href="../posts/2012/novembre/30/filename_metadata-example/">FILENAME_METADATA example</a></h1>
<footer class="post-info">
<abbr class="published" title="2012-11-30T00:00:00">
Published: ven. 30 novembre 2012
Published: 30 novembre 2012
</abbr>
<address class="vcard author">
@ -59,7 +59,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2012-02-29T00:00:00">
Published: mer. 29 février 2012
Published: 29 février 2012
</abbr>
<address class="vcard author">
@ -84,7 +84,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-10-15T20:30:00">
Published: ven. 15 octobre 2010
Published: 15 octobre 2010
</abbr>
<address class="vcard author">
@ -117,7 +117,7 @@ pelican.conf, it ...</p></div>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-03-14T00:00:00">
Published: dim. 14 mars 2010
Published: 14 mars 2010
</abbr>
<address class="vcard author">

View file

@ -34,11 +34,11 @@
<h1 class="entry-title"><a href="../posts/2010/décembre/02/this-is-a-super-article/">This is a super article !</a></h1>
<footer class="post-info">
<abbr class="published" title="2010-12-02T10:14:00">
Published: jeu. 02 décembre 2010
Published: 02 décembre 2010
</abbr>
<br />
<abbr class="modified" title="2013-11-17T23:29:00">
Updated: dim. 17 novembre 2013
Updated: 17 novembre 2013
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2012-03-02T14:01:01">
Published: ven. 02 mars 2012
Published: 02 mars 2012
</abbr>
<address class="vcard author">

View file

@ -34,7 +34,7 @@
<h1 class="entry-title"><a href="./posts/2012/novembre/30/filename_metadata-example/">FILENAME_METADATA example</a></h1>
<footer class="post-info">
<abbr class="published" title="2012-11-30T00:00:00">
Published: ven. 30 novembre 2012
Published: 30 novembre 2012
</abbr>
<address class="vcard author">
@ -59,7 +59,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2012-02-29T00:00:00">
Published: mer. 29 février 2012
Published: 29 février 2012
</abbr>
<address class="vcard author">
@ -84,7 +84,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-04-20T00:00:00">
Published: mer. 20 avril 2011
Published: 20 avril 2011
</abbr>
<address class="vcard author">
@ -108,7 +108,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">

View file

@ -40,7 +40,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">
@ -63,7 +63,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">
@ -86,11 +86,11 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-12-02T10:14:00">
Published: jeu. 02 décembre 2010
Published: 02 décembre 2010
</abbr>
<br />
<abbr class="modified" title="2013-11-17T23:29:00">
Updated: dim. 17 novembre 2013
Updated: 17 novembre 2013
</abbr>
<address class="vcard author">
@ -114,7 +114,7 @@ as well as <strong>inline markup</strong>.</p>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-10-20T10:14:00">
Published: mer. 20 octobre 2010
Published: 20 octobre 2010
</abbr>
<address class="vcard author">

View file

@ -40,7 +40,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-10-15T20:30:00">
Published: ven. 15 octobre 2010
Published: 15 octobre 2010
</abbr>
<address class="vcard author">
@ -73,7 +73,7 @@ pelican.conf, it ...</p></div>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-03-14T00:00:00">
Published: dim. 14 mars 2010
Published: 14 mars 2010
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2012-03-02T14:01:01">
Published: ven. 02 mars 2012
Published: 02 mars 2012
</abbr>
<address class="vcard author">

View file

@ -39,11 +39,11 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-12-02T10:14:00">
Published: jeu. 02 décembre 2010
Published: 02 décembre 2010
</abbr>
<br />
<abbr class="modified" title="2013-11-17T23:29:00">
Updated: dim. 17 novembre 2013
Updated: 17 novembre 2013
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-10-15T20:30:00">
Published: ven. 15 octobre 2010
Published: 15 octobre 2010
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-10-20T10:14:00">
Published: mer. 20 octobre 2010
Published: 20 octobre 2010
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-04-20T00:00:00">
Published: mer. 20 avril 2011
Published: 20 avril 2011
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2011-02-17T00:00:00">
Published: jeu. 17 février 2011
Published: 17 février 2011
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2012-02-29T00:00:00">
Published: mer. 29 février 2012
Published: 29 février 2012
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2012-11-30T00:00:00">
Published: ven. 30 novembre 2012
Published: 30 novembre 2012
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2012-02-29T00:00:00">
Published: mer. 29 février 2012
Published: 29 février 2012
</abbr>
<address class="vcard author">

View file

@ -34,7 +34,7 @@
<h1 class="entry-title"><a href="../posts/2012/février/29/second-article/">Second article</a></h1>
<footer class="post-info">
<abbr class="published" title="2012-02-29T00:00:00">
Published: mer. 29 février 2012
Published: 29 février 2012
</abbr>
<address class="vcard author">
@ -61,11 +61,11 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-12-02T10:14:00">
Published: jeu. 02 décembre 2010
Published: 02 décembre 2010
</abbr>
<br />
<abbr class="modified" title="2013-11-17T23:29:00">
Updated: dim. 17 novembre 2013
Updated: 17 novembre 2013
</abbr>
<address class="vcard author">
@ -89,7 +89,7 @@ as well as <strong>inline markup</strong>.</p>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-10-20T10:14:00">
Published: mer. 20 octobre 2010
Published: 20 octobre 2010
</abbr>
<address class="vcard author">

View file

@ -39,7 +39,7 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-03-14T00:00:00">
Published: dim. 14 mars 2010
Published: 14 mars 2010
</abbr>
<address class="vcard author">

View file

@ -34,7 +34,7 @@
<h1 class="entry-title"><a href="../posts/2012/février/29/second-article/">Second article</a></h1>
<footer class="post-info">
<abbr class="published" title="2012-02-29T00:00:00">
Published: mer. 29 février 2012
Published: 29 février 2012
</abbr>
<address class="vcard author">
@ -61,11 +61,11 @@
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2010-12-02T10:14:00">
Published: jeu. 02 décembre 2010
Published: 02 décembre 2010
</abbr>
<br />
<abbr class="modified" title="2013-11-17T23:29:00">
Updated: dim. 17 novembre 2013
Updated: 17 novembre 2013
</abbr>
<address class="vcard author">

View file

@ -34,11 +34,11 @@
<h1 class="entry-title"><a href="../posts/2010/décembre/02/this-is-a-super-article/">This is a super article !</a></h1>
<footer class="post-info">
<abbr class="published" title="2010-12-02T10:14:00">
Published: jeu. 02 décembre 2010
Published: 02 décembre 2010
</abbr>
<br />
<abbr class="modified" title="2013-11-17T23:29:00">
Updated: dim. 17 novembre 2013
Updated: 17 novembre 2013
</abbr>
<address class="vcard author">

View file

@ -34,7 +34,7 @@
<h1 class="entry-title"><a href="../posts/2010/octobre/20/oh-yeah/">Oh yeah !</a></h1>
<footer class="post-info">
<abbr class="published" title="2010-10-20T10:14:00">
Published: mer. 20 octobre 2010
Published: 20 octobre 2010
</abbr>
<address class="vcard author">

View file

@ -20,7 +20,7 @@ OUTPUT_PATH = os.path.abspath(os.path.join(CURRENT_DIR, 'output'))
INPUT_PATH = os.path.join(SAMPLES_PATH, "content")
SAMPLE_CONFIG = os.path.join(SAMPLES_PATH, "pelican.conf.py")
SAMPLE_FR_CONFIG = os.path.join(SAMPLES_PATH, "pelican_FR.conf.py")
SAMPLE_FR_CONFIG = os.path.join(SAMPLES_PATH, "pelican.conf_FR.py")
def recursiveDiff(dcmp):

View file

@ -94,12 +94,18 @@ class DateFormatter(object):
self.locale = locale.setlocale(locale.LC_TIME)
def __call__(self, date, date_format):
old_locale = locale.setlocale(locale.LC_TIME)
old_lc_time = locale.setlocale(locale.LC_TIME)
old_lc_ctype = locale.setlocale(locale.LC_CTYPE)
locale.setlocale(locale.LC_TIME, self.locale)
# on OSX, encoding from LC_CTYPE determines the unicode output in PY3
# make sure it's same as LC_TIME
locale.setlocale(locale.LC_CTYPE, self.locale)
formatted = strftime(date, date_format)
locale.setlocale(locale.LC_TIME, old_locale)
locale.setlocale(locale.LC_TIME, old_lc_time)
locale.setlocale(locale.LC_CTYPE, old_lc_ctype)
return formatted

View file

@ -16,6 +16,7 @@ REVERSE_CATEGORY_ORDER = True
LOCALE = "fr_FR.UTF-8"
DEFAULT_PAGINATION = 4
DEFAULT_DATE = (2012, 3, 2, 14, 1, 1)
DEFAULT_DATE_FORMAT = '%d %B %Y'
ARTICLE_URL = 'posts/{date:%Y}/{date:%B}/{date:%d}/{slug}/'
ARTICLE_SAVE_AS = ARTICLE_URL + 'index.html'