[devtools] deprecate usage of sources file for test
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 20 May 2016 11:09:46 +0200
changeset 11265 ce04184fbf90
parent 11264 1a3a0ac2b41d
child 11266 ea25d87a8537
[devtools] deprecate usage of sources file for test This is old support which clutters the code and should no more be used. As this is rarely used (if it is) and test only, it feels ok to drop support at once without a deprecation phase.
cubicweb/devtools/__init__.py
--- a/cubicweb/devtools/__init__.py	Fri May 20 13:07:21 2016 +0200
+++ b/cubicweb/devtools/__init__.py	Fri May 20 11:09:46 2016 +0200
@@ -189,33 +189,24 @@
             # no cubes
             self.init_cubes(())
 
-    sourcefile = None
-    def sources_file(self):
-        """define in subclasses self.sourcefile if necessary"""
-        if self.sourcefile:
-            print('Reading sources from', self.sourcefile)
-            sourcefile = self.sourcefile
-            if not isabs(sourcefile):
-                sourcefile = join(self.apphome, sourcefile)
-        else:
-            sourcefile = super(TestServerConfiguration, self).sources_file()
-        return sourcefile
-
     def read_sources_file(self):
         """By default, we run tests with the sqlite DB backend.  One may use its
         own configuration by just creating a 'sources' file in the test
         directory from which tests are launched or by specifying an alternative
         sources file using self.sourcefile.
         """
+        if getattr(self, 'sourcefile', None):
+            raise Exception('sourcefile isn\'t supported anymore, specify your database '
+                            'configuration using proper configuration class (e.g. '
+                            'PostgresApptestConfiguration)')
         try:
-            sources = super(TestServerConfiguration, self).read_sources_file()
+            super(TestServerConfiguration, self).read_sources_file()
+            raise Exception('test configuration shouldn\'t provide a sources file, specify your '
+                            'database configuration using proper configuration class (e.g. '
+                            'PostgresApptestConfiguration)')
         except ExecutionError:
-            sources = {}
-        if not sources:
-            sources = self.default_sources
-        if 'admin' not in sources:
-            sources['admin'] = self.default_sources['admin']
-        return sources
+            pass
+        return self.default_sources
 
     # web config methods needed here for cases when we use this config as a web
     # config