[test] Extract out method-which-is-not-a-method mocking iter_entry_points 3.25
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 29 Mar 2017 10:34:16 +0200
branch3.25
changeset 12117 49beb974888f
parent 12116 3522b19f35d6
child 12118 d7947c3c0eeb
[test] Extract out method-which-is-not-a-method mocking iter_entry_points to ease reuse and improve readability.
cubicweb/test/unittest_cwconfig.py
--- a/cubicweb/test/unittest_cwconfig.py	Wed Mar 29 10:32:24 2017 +0200
+++ b/cubicweb/test/unittest_cwconfig.py	Wed Mar 29 10:34:16 2017 +0200
@@ -93,6 +93,21 @@
             del sys.modules[module]
 
 
+def iter_entry_points(group, name):
+    """Mock pkg_resources.iter_entry_points to yield EntryPoint from
+    packages found in test/data/libpython even though these are not
+    installed.
+    """
+    libpython = CubicWebConfigurationTC.datapath('libpython')
+    prefix = 'cubicweb_'
+    for pkgname in os.listdir(libpython):
+        if not pkgname.startswith(prefix):
+            continue
+        location = join(libpython, pkgname)
+        yield EntryPoint(pkgname[len(prefix):], pkgname,
+                         dist=Distribution(location))
+
+
 class CubicWebConfigurationTC(BaseTestCase):
 
     @classmethod
@@ -110,20 +125,6 @@
     def tearDown(self):
         ApptestConfiguration.CUBES_PATH = []
 
-    def iter_entry_points(group, name):
-        """Mock pkg_resources.iter_entry_points to yield EntryPoint from
-        packages found in test/data/libpython even though these are not
-        installed.
-        """
-        libpython = CubicWebConfigurationTC.datapath('libpython')
-        prefix = 'cubicweb_'
-        for pkgname in os.listdir(libpython):
-            if not pkgname.startswith(prefix):
-                continue
-            location = join(libpython, pkgname)
-            yield EntryPoint(pkgname[len(prefix):], pkgname,
-                             dist=Distribution(location))
-
     @patch('pkg_resources.iter_entry_points', side_effect=iter_entry_points)
     def test_available_cubes(self, mock_iter_entry_points):
         expected_cubes = [