Skip to content

Commit

Permalink
[IMP] component_event: test performance improvement
Browse files Browse the repository at this point in the history
- Switch to setUpClass for avoiding repeat the same setup for each test.
- Include context keys for avoiding mail operations overhead.
  • Loading branch information
josep-tecnativa committed Oct 20, 2023
1 parent 4a25322 commit 4b5c93b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions component_event/tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from odoo.tests.common import MetaCase, tagged

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
from odoo.addons.component.core import Component
from odoo.addons.component.tests.common import (
ComponentRegistryCase,
Expand All @@ -23,11 +24,13 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.test_sequence = 0

def setUp(self):
super().setUp()
self.env = mock.MagicMock(name="env")
self.record = mock.MagicMock(name="record")
self.components_registry = mock.MagicMock(name="ComponentRegistry")
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = mock.MagicMock(name="env")
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
cls.record = mock.MagicMock(name="record")
cls.components_registry = mock.MagicMock(name="ComponentRegistry")

def test_env(self):
"""WorkContext with env"""
Expand Down

0 comments on commit 4b5c93b

Please sign in to comment.