cubicweb/test/unittest_cwconfig.py
branch3.26
changeset 12273 9d08f89a3d85
parent 12272 36032de96867
child 12274 d2e9999861a5
--- a/cubicweb/test/unittest_cwconfig.py	Thu Feb 15 10:55:49 2018 +0100
+++ b/cubicweb/test/unittest_cwconfig.py	Thu Feb 15 14:19:15 2018 +0100
@@ -35,7 +35,7 @@
 from cubicweb.devtools import ApptestConfiguration
 from cubicweb.devtools.testlib import BaseTestCase, TemporaryDirectory
 from cubicweb.cwconfig import (
-    CubicWebConfiguration, _find_prefix, _expand_modname)
+    CubicWebConfiguration, _expand_modname)
 
 
 def unabsolutize(path):
@@ -295,101 +295,6 @@
         self.assertNotIn('cubicweb_mycube.ccplugin', sys.modules, sorted(sys.modules))
 
 
-class FindPrefixTC(unittest.TestCase):
-
-    def make_dirs(self, basedir, *args):
-        path = join(basedir, *args)
-        if not os.path.exists(path):
-            os.makedirs(path)
-        return path
-
-    def make_file(self, basedir, *args):
-        self.make_dirs(basedir, *args[:-1])
-        file_path = join(basedir, *args)
-        with open(file_path, 'w') as f:
-            f.write('""" None """')
-        return file_path
-
-    def test_samedir(self):
-        with TemporaryDirectory() as prefix:
-            self.make_dirs(prefix, 'share', 'cubicweb')
-            self.assertEqual(_find_prefix(prefix), prefix)
-
-    def test_samedir_filepath(self):
-        with TemporaryDirectory() as prefix:
-            self.make_dirs(prefix, 'share', 'cubicweb')
-            file_path = self.make_file(prefix, 'bob.py')
-            self.assertEqual(_find_prefix(file_path), prefix)
-
-    def test_dir_inside_prefix(self):
-        with TemporaryDirectory() as prefix:
-            self.make_dirs(prefix, 'share', 'cubicweb')
-            dir_path = self.make_dirs(prefix, 'bob')
-            self.assertEqual(_find_prefix(dir_path), prefix)
-
-    def test_file_in_dir_inside_prefix(self):
-        with TemporaryDirectory() as prefix:
-            self.make_dirs(prefix, 'share', 'cubicweb')
-            file_path = self.make_file(prefix, 'bob', 'toto.py')
-            self.assertEqual(_find_prefix(file_path), prefix)
-
-    def test_file_in_deeper_dir_inside_prefix(self):
-        with TemporaryDirectory() as prefix:
-            self.make_dirs(prefix, 'share', 'cubicweb')
-            file_path = self.make_file(prefix, 'bob', 'pyves', 'alain',
-                                       'adim', 'syt', 'toto.py')
-            self.assertEqual(_find_prefix(file_path), prefix)
-
-    def test_multiple_candidate_prefix(self):
-        with TemporaryDirectory() as tempdir:
-            self.make_dirs(tempdir, 'share', 'cubicweb')
-            prefix = self.make_dirs(tempdir, 'bob')
-            self.make_dirs(prefix, 'share', 'cubicweb')
-            file_path = self.make_file(prefix, 'pyves', 'alain',
-                                       'adim', 'syt', 'toto.py')
-            self.assertEqual(_find_prefix(file_path), prefix)
-
-    def test_sister_candidate_prefix(self):
-        with TemporaryDirectory() as prefix:
-            self.make_dirs(prefix, 'share', 'cubicweb')
-            self.make_dirs(prefix, 'bob', 'share', 'cubicweb')
-            file_path = self.make_file(prefix, 'bell', 'toto.py')
-            self.assertEqual(_find_prefix(file_path), prefix)
-
-    def test_multiple_parent_candidate_prefix(self):
-        with TemporaryDirectory() as tempdir:
-            self.make_dirs(tempdir, 'share', 'cubicweb')
-            prefix = self.make_dirs(tempdir, 'share', 'cubicweb', 'bob')
-            self.make_dirs(tempdir, 'share', 'cubicweb', 'bob', 'share',
-                           'cubicweb')
-            file_path = self.make_file(tempdir, 'share', 'cubicweb', 'bob',
-                                       'pyves', 'alain', 'adim', 'syt',
-                                       'toto.py')
-            self.assertEqual(_find_prefix(file_path), prefix)
-
-    def test_upper_candidate_prefix(self):
-        with TemporaryDirectory() as prefix:
-            self.make_dirs(prefix, 'share', 'cubicweb')
-            self.make_dirs(prefix, 'bell', 'bob', 'share', 'cubicweb')
-            file_path = self.make_file(prefix, 'bell', 'toto.py')
-            self.assertEqual(_find_prefix(file_path), prefix)
-
-    def test_no_prefix(self):
-        with TemporaryDirectory() as prefix:
-            self.assertEqual(_find_prefix(prefix), sys.prefix)
-
-    def test_virtualenv(self):
-        venv = os.environ.get('VIRTUAL_ENV')
-        try:
-            with TemporaryDirectory() as prefix:
-                os.environ['VIRTUAL_ENV'] = prefix
-                self.make_dirs(prefix, 'share', 'cubicweb')
-                self.assertEqual(_find_prefix(), prefix)
-        finally:
-            if venv:
-                os.environ['VIRTUAL_ENV'] = venv
-
-
 class ModnamesTC(unittest.TestCase):
 
     @templibdir