[test] make unittest_webconfig independant of CWD
authorDavid Douard <david.douard@logilab.fr>
Fri, 28 Nov 2014 00:39:31 +0100
changeset 10071 4bc099f2a089
parent 10070 5244592cb225
child 10072 934341b848a6
[test] make unittest_webconfig independant of CWD if apphome is unset in ApptestConfiguration constructor, this later looks for a 'data' directory in CWD, making this test runnable only from web/test (and pytest do chdir before executing tests, so we did not noticed this problem).
web/test/unittest_webconfig.py
--- a/web/test/unittest_webconfig.py	Fri Nov 28 11:51:36 2014 +0100
+++ b/web/test/unittest_webconfig.py	Fri Nov 28 00:39:31 2014 +0100
@@ -25,7 +25,9 @@
 
 class WebconfigTC(TestCase):
     def setUp(self):
-        self.config = ApptestConfiguration('data')
+        # need explicit None if dirname(__file__) is empty, see
+        # ApptestConfiguration.__init__
+        self.config = ApptestConfiguration('data', apphome=os.path.dirname(__file__) or None)
         self.config._cubes = ['file']
         self.config.load_configuration()
 
@@ -42,7 +44,11 @@
         rname = self.config.uiprops['FILE_ICON'].replace(self.config.datadir_url, '')
         self.assertIn('file', self.config.locate_resource(rname)[0].split(os.sep))
         cubicwebcsspath = self.config.locate_resource('cubicweb.css')[0].split(os.sep)
-        self.assertTrue('web' in cubicwebcsspath or 'shared' in cubicwebcsspath) # 'shared' if tests under apycot
+
+        # 'shared' if tests under apycot
+        self.assertTrue('web' in cubicwebcsspath or 'shared' in cubicwebcsspath,
+                        'neither "web" nor "shared" found in cubicwebcsspath (%s)'
+                        % cubicwebcsspath)
 
     def test_sign_text(self):
         signature = self.config.sign_text(u'hôp')