diff 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
line wrap: on
line diff
--- a/tests/tmpfs.py	Sun Oct 29 22:46:41 2017 -0700
+++ b/tests/tmpfs.py	Sun Oct 29 22:51:57 2017 -0700
@@ -18,7 +18,7 @@
         p = p.lstrip('/\\')
         return os.path.join(self._root, p)
 
-    def getStructure(self, path=None):
+    def getStructure(self, path=''):
         path = self.path(path)
         if not os.path.exists(path):
             raise Exception("No such path: %s" % path)
@@ -44,8 +44,11 @@
                 self._getStructureRecursive(e, full_cur, item)
             target[cur] = e
         else:
-            with open(full_cur, 'r', encoding='utf8') as fp:
-                target[cur] = fp.read()
+            try:
+                with open(full_cur, 'r', encoding='utf8') as fp:
+                    target[cur] = fp.read()
+            except Exception as ex:
+                target[cur] = "ERROR: CAN'T READ '%s': %s" % (full_cur, ex)
 
     def _createDir(self, path):
         if not os.path.exists(path):
@@ -69,7 +72,7 @@
     def __init__(self, fs, open_patches=None, keep=False):
         self._fs = fs
         self._open = open
-        self._keep = keep
+        self._keep = keep or TestFileSystemBase._leave_mockfs
 
     @property
     def root(self):