Permalink
Browse files

Make sure the filenames are unicode, fix #7.

  • Loading branch information...
SimonSapin committed Sep 27, 2012
1 parent c5ced2e commit 3570b59a1a19b20fe839f61aa5bde55a8df47ee3
Showing with 16 additions and 2 deletions.
  1. +1 −1 docs/_themes
  2. +2 −1 flask_flatpages/__init__.py
  3. +13 −0 flask_flatpages/tests.py
@@ -210,7 +210,8 @@ def _walk(directory, path_prefix=()):
extension = self.app.config['FLATPAGES_EXTENSION']
pages = {}
- _walk(self.root)
+ # Fail if the root is a non-ASCII byte string. Use Unicode.
+ _walk(unicode(self.root))
return pages
def _load_file(self, path, filename):
View
@@ -311,6 +311,19 @@ def test_configured_auto_reset(self):
with temp_pages(app) as pages:
self.assert_auto_reset(pages)
+ def test_unicode_filenames(self):
+ app = Flask(__name__)
+ with temp_pages(app) as pages:
+ self.assertEquals(
+ set(p.path for p in pages),
+ set(['foo/bar', 'foo/lorem/ipsum', 'foo', 'hello']))
+ os.remove(os.path.join(pages.root, 'foo', 'lorem', 'ipsum.html'))
+ open(os.path.join(pages.root, u'Unïcôdé.html'), 'w').close()
+ pages.reload()
+ self.assertEquals(
+ set(p.path for p in pages),
+ set(['foo/bar', 'foo', 'hello', u'Unïcôdé']))
+
if __name__ == '__main__':
unittest.main()

0 comments on commit 3570b59

Please sign in to comment.