[tests] Don't import QUnitTestCase into tests' global namespace
authorRémi Cardona <remi.cardona@logilab.fr>
Wed, 02 Sep 2015 12:08:31 +0200
changeset 10887 a0315e9f4c20
parent 10886 941e3d15c338
child 10888 fbbb028d0a75
[tests] Don't import QUnitTestCase into tests' global namespace Unittest's test loader will try to execute QUnitTestCase's test_javascripts method. However this class is intended to be subclassed, not to be executed directly. This change has the following consequences: * slightly faster test execution * almost all rtags warnings are gone
devtools/test/unittest_qunit.py
web/test/test_jscript.py
--- a/devtools/test/unittest_qunit.py	Tue Sep 01 17:13:16 2015 +0200
+++ b/devtools/test/unittest_qunit.py	Wed Sep 02 12:08:31 2015 +0200
@@ -1,7 +1,7 @@
-from logilab.common.testlib import unittest_main
-from cubicweb.devtools.qunit import QUnitTestCase
+from os import path as osp
 
-from os import path as osp
+from cubicweb.devtools import qunit
+
 
 JSTESTDIR = osp.abspath(osp.join(osp.dirname(__file__), 'data', 'js_examples'))
 
@@ -9,7 +9,7 @@
 def js(name):
     return osp.join(JSTESTDIR, name)
 
-class QUnitTestCaseTC(QUnitTestCase):
+class QUnitTestCaseTC(qunit.QUnitTestCase):
 
     all_js_tests = (
                     (js('test_simple_success.js'),),
@@ -28,4 +28,5 @@
 
 
 if __name__ == '__main__':
-    unittest_main()
+    from unittest import main
+    main()
--- a/web/test/test_jscript.py	Tue Sep 01 17:13:16 2015 +0200
+++ b/web/test/test_jscript.py	Wed Sep 02 12:08:31 2015 +0200
@@ -1,9 +1,9 @@
-from cubicweb.devtools.qunit import QUnitTestCase, unittest_main
+from cubicweb.devtools import qunit
 
 from os import path as osp
 
 
-class JScript(QUnitTestCase):
+class JScript(qunit.QUnitTestCase):
 
     all_js_tests = (
         ("jstests/test_utils.js", (
@@ -34,4 +34,5 @@
 
 
 if __name__ == '__main__':
-    unittest_main()
+    from unittest import main
+    main()