Mercurial > piecrust2
comparison tests/tmpfs.py @ 979:45ad976712ec
tests: Big push to get the tests to pass again.
- Lots of fixes everywhere in the code.
- Try to handle debug logging in the multiprocessing worker pool when running in pytest. Not perfect, but usable for now.
- Replace all `.md` test files with `.html` since now a auto-format extension always sets the format.
- Replace `out` with `outfiles` in most places since now blog archives are added to the bake output and I don't want to add expected outputs for blog archives everywhere.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 29 Oct 2017 22:51:57 -0700 |
parents | 72f17534d58e |
children |
comparison
equal
deleted
inserted
replaced
978:7e51d14097cb | 979:45ad976712ec |
---|---|
16 | 16 |
17 def path(self, p): | 17 def path(self, p): |
18 p = p.lstrip('/\\') | 18 p = p.lstrip('/\\') |
19 return os.path.join(self._root, p) | 19 return os.path.join(self._root, p) |
20 | 20 |
21 def getStructure(self, path=None): | 21 def getStructure(self, path=''): |
22 path = self.path(path) | 22 path = self.path(path) |
23 if not os.path.exists(path): | 23 if not os.path.exists(path): |
24 raise Exception("No such path: %s" % path) | 24 raise Exception("No such path: %s" % path) |
25 if not os.path.isdir(path): | 25 if not os.path.isdir(path): |
26 raise Exception("Path is not a directory: %s" % path) | 26 raise Exception("Path is not a directory: %s" % path) |
42 e = {} | 42 e = {} |
43 for item in os.listdir(full_cur): | 43 for item in os.listdir(full_cur): |
44 self._getStructureRecursive(e, full_cur, item) | 44 self._getStructureRecursive(e, full_cur, item) |
45 target[cur] = e | 45 target[cur] = e |
46 else: | 46 else: |
47 with open(full_cur, 'r', encoding='utf8') as fp: | 47 try: |
48 target[cur] = fp.read() | 48 with open(full_cur, 'r', encoding='utf8') as fp: |
49 target[cur] = fp.read() | |
50 except Exception as ex: | |
51 target[cur] = "ERROR: CAN'T READ '%s': %s" % (full_cur, ex) | |
49 | 52 |
50 def _createDir(self, path): | 53 def _createDir(self, path): |
51 if not os.path.exists(path): | 54 if not os.path.exists(path): |
52 os.makedirs(path) | 55 os.makedirs(path) |
53 | 56 |
67 | 70 |
68 class TempDirScope(object): | 71 class TempDirScope(object): |
69 def __init__(self, fs, open_patches=None, keep=False): | 72 def __init__(self, fs, open_patches=None, keep=False): |
70 self._fs = fs | 73 self._fs = fs |
71 self._open = open | 74 self._open = open |
72 self._keep = keep | 75 self._keep = keep or TestFileSystemBase._leave_mockfs |
73 | 76 |
74 @property | 77 @property |
75 def root(self): | 78 def root(self): |
76 return self._fs._root | 79 return self._fs._root |
77 | 80 |