diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-09-11 18:14:16 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-09-11 18:14:16 +0200 |
| commit | 295a377e5d4ecaa9afe66b6d40ebf3ecbfedc6ea (patch) | |
| tree | d9a309993479f05f8e5f7ef32252de3d4d8ae3ce | |
| parent | 7a87484856575ccb928563c6aad5e656a59cac16 (diff) | |
[IMP] web: add test to ensure nobody will commit again unwanted `QUnit.only`
| -rw-r--r-- | addons/web/tests/test_js.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/web/tests/test_js.py b/addons/web/tests/test_js.py index 1614be64c43..17eb5c8beb2 100644 --- a/addons/web/tests/test_js.py +++ b/addons/web/tests/test_js.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +import re import odoo.tests @@ -11,3 +12,19 @@ class WebSuite(odoo.tests.HttpCase): def test_01_js(self): self.phantom_js('/web/tests?mod=web', "", "", login='admin', timeout=300) + + def test_check_suite(self): + # verify no js test is using `QUnit.only` as it forbid any other test to be executed + re_only = re.compile('QUnit\.only\(') + + # As we currently aren't in a request context, we can't render `web.layout`. + # redefinied it as a minimal proxy template. + self.env.ref('web.layout').write({'arch_db': '<t t-name="web.layout"><t t-raw="head"/></t>'}) + + for asset in self.env['ir.qweb']._get_asset_content('web.qunit_suite', options={})[0]: + filename = asset['filename'] + if not filename or asset['atype'] != 'text/javascript': + continue + with open(filename, 'r') as fp: + if re_only.search(fp.read()): + self.fail("`QUnit.only()` used in file %r" % asset['url']) |
