From d256bbac3e2de1e7113a6a682121aff658f623b1 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 29 Aug 2022 07:10:03 +0000 Subject: [PATCH] [FIX] test_lint: l10n linter The linter would require flagging "Common" classes with `post_install_l10n`, which is incorrect but innocuous before tag inheritance, however it's incorrect and broken with tag inheritance. Fix to only apply the lint to actual test containers. Although eventually the analysis should probably run on the actual classes, so that the "common" classes can be tagged and the children don't need to be (since they inherit tagging from their parents). Part-of: odoo/odoo#98814 --- odoo/addons/test_lint/tests/test_l10n.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/odoo/addons/test_lint/tests/test_l10n.py b/odoo/addons/test_lint/tests/test_l10n.py index 43c445ef659..225ce9d2bcc 100644 --- a/odoo/addons/test_lint/tests/test_l10n.py +++ b/odoo/addons/test_lint/tests/test_l10n.py @@ -28,10 +28,14 @@ class L10nChecker(lint_case.NodeVisitor): (len({'post_install_l10n', 'external_l10n'} & tags) != 1) or ('post_install_l10n' in tags and 'post_install' not in tags) # or ('post_install_l10n' not in tags and 'post_install' in tags) - or ('external_l10n' in tags and 'external' not in tags) - or ('external_l10n' not in tags and 'external' in tags) + or (('external_l10n' in tags) ^ ('external' in tags)) ): - return [node] + if any( + stmt.name.startswith('test_') + for stmt in node.body + if isinstance(stmt, ast.FunctionDef) + ): + return [node] return []