summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorChristophe Monniez <moc@odoo.com>2021-02-23 07:50:32 +0000
committerChristophe Monniez <moc@odoo.com>2021-02-23 09:35:52 +0000
commitedabed7b3ab351c76b9555378efa6258f9e76733 (patch)
tree791526971050083d40df6de817e65812e6d0e3b4 /odoo
parent2c9f91988aacdf2eb76dccb1aaebea34425e9437 (diff)
[FIX] tests: add a linter to check for __init__.py in modules
When a module is added, it happens that the `__init__.py` file is forgotten. In that case, those modules are not packaged. With this commit, a test is added to check that each Odoo module has the file.
Diffstat (limited to 'odoo')
-rw-r--r--odoo/addons/test_lint/tests/__init__.py1
-rw-r--r--odoo/addons/test_lint/tests/test_dunderinit.py23
2 files changed, 24 insertions, 0 deletions
diff --git a/odoo/addons/test_lint/tests/__init__.py b/odoo/addons/test_lint/tests/__init__.py
index c28bef7f107..b8416fe62bf 100644
--- a/odoo/addons/test_lint/tests/__init__.py
+++ b/odoo/addons/test_lint/tests/__init__.py
@@ -3,3 +3,4 @@ from . import test_pofile
from . import test_ecmascript
from . import test_markers
from . import test_onchange_domains
+from . import test_dunderinit
diff --git a/odoo/addons/test_lint/tests/test_dunderinit.py b/odoo/addons/test_lint/tests/test_dunderinit.py
new file mode 100644
index 00000000000..a074896832c
--- /dev/null
+++ b/odoo/addons/test_lint/tests/test_dunderinit.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import logging
+from pathlib import Path
+
+from odoo.modules import get_modules, get_module_path
+from . import lint_case
+
+_logger = logging.getLogger(__name__)
+
+
+class TestDunderinit(lint_case.LintCase):
+
+ def test_dunderinit(self):
+ """ Test that __init__.py exists in Odoo modules, otherwise they won't get packaged"""
+
+ modules_list = get_modules()
+ for mod in modules_list:
+ dunderinit_path = Path(get_module_path(mod)) / '__init__.py'
+ self.assertTrue(dunderinit_path.is_file(), "Missing `__init__.py ` in module %s" % mod)
+
+ _logger.info('%s modules checked', len(modules_list))