Skip to content
Snippets Groups Projects
Commit c4e6f090 authored by Xavier-Do's avatar Xavier-Do
Browse files

[FIX] tests: check test tags *_install


Making a test post_install using @tagged should always remove the
at_install tag.

The main reason for that is that runbot split config select if an
at_install or post_install tests should be executed is using negation:
`--test-tags -post_install`. The reason for that is that giving a positive tag will
replace the "standard" tag and non standard tag could be executed if
giving `--test-tags at_install` (without negation)

Since runbot tests in parallel builds, one of them using
`--test-tags -post_install` and the other `--test-tags -at_install`,
a test that is both post install and at install wont be executed at all.

Also, a tests with both tags will be executed twice
in a normal flow, usually not intended.

The correct way to make a test post_install is to use

@tagged('post_install', '-at_install')

closes odoo/odoo#118042

Signed-off-by: default avatarChristophe Monniez (moc) <moc@odoo.com>
parent 1852571a
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
from odoo.tests import Form, tagged, TransactionCase
from odoo.exceptions import MissingError
@tagged('post_install')
@tagged('post_install', '-at_install')
class TestEmployeeDeletion(TransactionCase):
def test_employee_deletion(self):
......
......@@ -8,7 +8,7 @@ from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('post_install')
@tagged('post_install', '-at_install')
class TestSmsTemplateAccessRights(SavepointCase):
@classmethod
......
......@@ -326,7 +326,7 @@ class TestAccess(common.TestSurveyCommon):
(answer_own | answer_other | self.answer_0).unlink()
@tagged('post_install')
@tagged('post_install', '-at_install')
class TestSurveySecurityControllers(common.TestSurveyCommon, HttpCase):
def test_survey_start_short(self):
# avoid name clash with existing data
......
......@@ -89,19 +89,19 @@ class TestSetTags(TransactionCase):
self.assertEqual(fc.test_tags, {'at_install'})
self.assertEqual(fc.test_module, 'base')
@tagged('-standard', '-base', '-at_install')
@tagged('-standard', '-base', '-at_install', 'post_install')
class FakeClassB(TransactionCase):
pass
fc = FakeClassB()
self.assertEqual(fc.test_tags, set())
self.assertEqual(fc.test_tags, {'post_install'})
@tagged('-standard', '-base', '-at_install', 'fast')
@tagged('-standard', '-base', 'fast')
class FakeClassC(TransactionCase):
pass
fc = FakeClassC()
self.assertEqual(fc.test_tags, {'fast', })
self.assertEqual(fc.test_tags, {'fast', 'at_install'})
@tagged('nodatabase')
......
......@@ -2601,6 +2601,10 @@ def tagged(*tags):
include = {t for t in tags if not t.startswith('-')}
exclude = {t[1:] for t in tags if t.startswith('-')}
obj.test_tags = (getattr(obj, 'test_tags', set()) | include) - exclude # todo remove getattr in master since we want to limmit tagged to BaseCase and always have +standard tag
at_install = 'at_install' in obj.test_tags
post_install = 'post_install' in obj.test_tags
if not (at_install ^ post_install):
_logger.warning('A tests should be either at_install or post_install, which is not the case of %r', obj)
return obj
return tags_decorator
......
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