[skel] nicer test file skeleton
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 07 Jul 2010 10:48:07 +0200
changeset 5915 e6cc50932720
parent 5914 dc5a77a2e485
child 5916 36206e846a27
[skel] nicer test file skeleton
skeleton/test/test_CUBENAME.py
skeleton/test/test_CUBENAME.py.tmpl
--- a/skeleton/test/test_CUBENAME.py	Wed Jul 07 10:46:33 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
-#
-# This file is part of CubicWeb.
-#
-# CubicWeb is free software: you can redistribute it and/or modify it under the
-# terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option)
-# any later version.
-#
-# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License along
-# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""template automatic tests
-
-"""
-
-from logilab.common.testlib import TestCase, unittest_main
-
-class DefaultTC(TestCase):
-    def test_something(self):
-        self.skip('this cube has no test')
-
-## uncomment the import if you want to activate automatic test for your
-## template
-
-# from cubicweb.devtools.testlib import AutomaticWebTest
-
-
-if __name__ == '__main__':
-    unittest_main()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/skeleton/test/test_CUBENAME.py.tmpl	Wed Jul 07 10:48:07 2010 +0200
@@ -0,0 +1,37 @@
+# copyright %(year)s %(author)s, all rights reserved.
+# contact %(author-web-site)s -- mailto:%(author-email)s
+#
+%(long-license)s
+"""%(distname)s automatic tests
+
+
+uncomment code below if you want to activate automatic test for your cube:
+
+.. sourcecode:: python
+
+    from cubicweb.devtools.testlib import AutomaticWebTest
+
+    class AutomaticWebTest(AutomaticWebTest):
+        '''provides `to_test_etypes` and/or `list_startup_views` implementation
+        to limit test scope
+        '''
+
+        def to_test_etypes(self):
+            '''only test views for entities of the returned types'''
+            return set(('My', 'Cube', 'Entity', 'Types'))
+
+        def list_startup_views(self):
+            '''only test startup views of the returned identifiers'''
+            return ('some', 'startup', 'views')
+"""
+
+from cubicweb.devtools import testlib
+
+class DefaultTC(testlib.CubicWebTC):
+    def test_something(self):
+        self.skip('this cube has no test')
+
+
+if __name__ == '__main__':
+    from logilab.common.testlib import unittest_main
+    unittest_main()