Mercurial > piecrust2
comparison tests/tmpfs.py @ 520:bab91fcef741
bake/serve: Improve support for unicode, add slugification options.
* Add slugification options for taxonomies.
* Sort out some unicode support problems on OSX.
* Add tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 28 Jul 2015 18:34:21 -0700 |
parents | e7b865f8f335 |
children | d6403c21bdea |
comparison
equal
deleted
inserted
replaced
519:9d1a89cd8146 | 520:bab91fcef741 |
---|---|
1 import os | 1 import os |
2 import os.path | 2 import os.path |
3 import shutil | 3 import shutil |
4 import random | 4 import random |
5 import unicodedata | |
5 from .basefs import TestFileSystemBase | 6 from .basefs import TestFileSystemBase |
6 | 7 |
7 | 8 |
8 class TempDirFileSystem(TestFileSystemBase): | 9 class TempDirFileSystem(TestFileSystemBase): |
9 def __init__(self, default_spec=True): | 10 def __init__(self, default_spec=True): |
35 path = self.path(path) | 36 path = self.path(path) |
36 with open(path, 'r', encoding='utf8') as fp: | 37 with open(path, 'r', encoding='utf8') as fp: |
37 return fp.read() | 38 return fp.read() |
38 | 39 |
39 def _getStructureRecursive(self, target, parent, cur): | 40 def _getStructureRecursive(self, target, parent, cur): |
41 cur = unicodedata.normalize('NFC', cur) | |
40 full_cur = os.path.join(parent, cur) | 42 full_cur = os.path.join(parent, cur) |
41 if os.path.isdir(full_cur): | 43 if os.path.isdir(full_cur): |
42 e = {} | 44 e = {} |
43 for item in os.listdir(full_cur): | 45 for item in os.listdir(full_cur): |
44 self._getStructureRecursive(e, full_cur, item) | 46 self._getStructureRecursive(e, full_cur, item) |