author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Fri, 01 Jul 2011 20:14:20 +0200 | |
branch | stable |
changeset 7613 | 63bac28113a5 |
parent 6340 | 470d8e828fda |
child 8930 | 6a02be304486 |
permissions | -rw-r--r-- |
5742
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
1 |
from logilab.common.testlib import unittest_main |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
2 |
from cubicweb.devtools.qunit import make_qunit_html, QUnitTestCase |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
3 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
4 |
from os import path as osp |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
5 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
6 |
JSTESTDIR = osp.abspath(osp.join(osp.dirname(__file__), 'data', 'js_examples')) |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
7 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
8 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
9 |
def js(name): |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
10 |
return osp.join(JSTESTDIR, name) |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
11 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
12 |
class QUnitTestCaseTC(QUnitTestCase): |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
13 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
14 |
all_js_tests = ( |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
15 |
(js('test_simple_success.js'),), |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
16 |
(js('test_with_dep.js'), (js('dep_1.js'),)), |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
17 |
(js('test_with_ordered_deps.js'), (js('dep_1.js'), js('deps_2.js'),)), |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
18 |
) |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
19 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
20 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
21 |
def test_simple_failure(self): |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
22 |
js_tests = list(self._test_qunit(js('test_simple_failure.js'))) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5742
diff
changeset
|
23 |
self.assertEqual(len(js_tests), 3) |
5742
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
24 |
test_1, test_2, test_3 = js_tests |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
25 |
self.assertRaises(self.failureException, test_1[0], *test_1[1:]) |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
26 |
self.assertRaises(self.failureException, test_2[0], *test_2[1:]) |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
27 |
test_3[0](*test_3[1:]) |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
28 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
29 |
|
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
30 |
if __name__ == '__main__': |
74c19dac29cf
Add a QUnitTestCase class to run qunit test case.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
31 |
unittest_main() |