fix sys.path adjustment
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 10 Mar 2009 09:41:04 +0100
changeset 1023 278f997aa257
parent 1022 15d3e1b3a27d
child 1029 2f984d7a5f8a
fix sys.path adjustment
cwconfig.py
test/unittest_cwconfig.py
--- a/cwconfig.py	Tue Mar 10 09:39:23 2009 +0100
+++ b/cwconfig.py	Tue Mar 10 09:41:04 2009 +0100
@@ -353,8 +353,9 @@
     @classmethod
     def cls_adjust_sys_path(cls):
         """update python path if necessary"""
-        if not cls.CUBES_DIR in sys.path:
-            sys.path.insert(0, cls.CUBES_DIR)
+        cubes_parent_dir = normpath(join(cls.CUBES_DIR, '..'))
+        if not cubes_parent_dir in sys.path:
+            sys.path.insert(0, cubes_parent_dir)
         try:
             import cubes
             cubes.__path__ = cls.cubes_search_path()
--- a/test/unittest_cwconfig.py	Tue Mar 10 09:39:23 2009 +0100
+++ b/test/unittest_cwconfig.py	Tue Mar 10 09:41:04 2009 +0100
@@ -73,6 +73,9 @@
                            'email/entities.py', 'email/views', 'email/hooks.py'])
 
     def test_cubes_path(self):
+        # make sure we don't import the email cube, but the stdlib email package
+        import email
+        self.assertNotEquals(dirname(email.__file__), self.config.CUBES_DIR)
         os.environ['CW_CUBES_PATH'] = join(dirname(__file__), 'data', 'cubes')
         self.assertEquals(self.config.cubes_search_path(),
                           [abspath(join(dirname(__file__), 'data', 'cubes')),