Skip to content
Snippets Groups Projects
Commit 852aa5ae authored by Christophe Monniez's avatar Christophe Monniez
Browse files

[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.

X-original-commit: edabed7b
parent c4069b90
No related branches found
No related tags found
No related merge requests found
......@@ -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
# -*- 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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment