devtools/livetest.py
changeset 1808 aa09e20dd8c0
parent 1802 d628defebc17
child 1977 606923dff11b
--- a/devtools/livetest.py	Tue May 05 17:18:49 2009 +0200
+++ b/devtools/livetest.py	Thu May 14 12:48:11 2009 +0200
@@ -1,4 +1,9 @@
-"""provide utilies for web (live) unit testing"""
+"""provide utilies for web (live) unit testing
+
+:organization: Logilab
+:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
+"""
 
 import socket
 import logging
@@ -36,17 +41,14 @@
         """Indicate which resource to use to process down the URL's path"""
         if len(segments) and segments[0] == 'data':
             # Anything in data/ is treated as static files
-            dirlist = [self.data_dir, join(dirname(cubicweb.web.__file__), 'data')]
-            for alternative in dirlist:
-                filepath = join(alternative, *segments[1:]) 
-                if exists(filepath):
-                    self.info('publish static file: %s', '/'.join(segments))
-                    return static.File(filepath), ()
+            datadir = self.config.locate_resource(segments[1])
+            if datadir:
+                return static.File(str(datadir), segments[1:])
         # Otherwise we use this single resource
         return self, ()
-    
-    
-    
+
+
+
 def make_site(cube, options=None):
     from cubicweb.etwist import twconfig # trigger configuration registration
     sourcefile = options.sourcefile
@@ -78,7 +80,7 @@
 def saveconf(templhome, port, user, passwd):
     import pickle
     conffile = file(join(templhome, 'test', 'livetest.conf'), 'w')
-    
+
     pickle.dump((port, user, passwd, get_starturl(port, user, passwd)),
                 conffile)
     conffile.close()
@@ -102,8 +104,8 @@
     from twill import browser as twb
     twc.OUT = new_output
     twb.OUT = new_output
-    
-    
+
+
 class LiveTestCase(TestCase):
 
     sourcefile = None
@@ -121,7 +123,7 @@
 
     def tearDown(self):
         self.teardown_db(self.cnx)
-    
+
 
     def setup_db(self, cnx):
         """override setup_db() to setup your environment"""
@@ -144,5 +146,3 @@
 
 if __name__ == '__main__':
     runserver()
-
-