[py-svn] r34702 - in py/dist/py: path/local test

fijal at codespeak.net fijal at codespeak.net
Fri Nov 17 11:10:40 CET 2006


Author: fijal
Date: Fri Nov 17 11:10:38 2006
New Revision: 34702

Modified:
   py/dist/py/path/local/local.py
   py/dist/py/test/config.py
Log:
Added mtime() checks for caching.


Modified: py/dist/py/path/local/local.py
==============================================================================
--- py/dist/py/path/local/local.py	(original)
+++ py/dist/py/path/local/local.py	Fri Nov 17 11:10:38 2006
@@ -376,11 +376,11 @@
         #print "trying to import", self
         pkgpath = None
         if modname is None:
-            if modname is None:
-                try:
+            try:
+                if self.module_mtime == self.mtime():
                     return self.module
-                except AttributeError:
-                    pass
+            except AttributeError:
+                pass
             pkgpath = self.pypkgpath()
             if pkgpath is not None:
                 if ensuresyspath:
@@ -402,6 +402,7 @@
                     self._prependsyspath(self.dirpath())
                 modname = self.purebasename
             mod = __import__(modname, None, None, ['__doc__'])
+            self.module_mtime = self.mtime()
             self.module = mod
             return mod
         else:

Modified: py/dist/py/test/config.py
==============================================================================
--- py/dist/py/test/config.py	(original)
+++ py/dist/py/test/config.py	Fri Nov 17 11:10:38 2006
@@ -43,19 +43,17 @@
         """ return 'name' value looked up from the first conftest file 
             found up the path (including the path itself). 
         """
-        #try:
-        #    return cls.values_cache[name]
-        #except KeyError:
-        #    pass
         configpaths = guessconfigpaths(path) 
         if trydefaultconfig:
             configpaths.append(defaultconfig) 
         for p in configpaths:
             try:
-                mod = cls.configs_cache[p]
-            except KeyError:
-                mod = importconfig(p) 
-                cls.configs_cache[p] = mod
+                mtime, mod = cls.configs_cache[p]
+                if mtime != p.mtime():
+                    raise IndexError()
+            except (KeyError, IndexError):
+                mod = importconfig(p)
+                cls.configs_cache[p] = p.mtime(), mod
             try:
                 retval = getattr(mod, name)
                 cls.values_cache[name] = retval



More information about the pytest-commit mailing list