You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
583 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
  4. from contextlib import contextmanager
  5. from mock import MagicMock
  6. from odoo.tests.common import HttpCase
  7. class Common(HttpCase):
  8. @contextmanager
  9. def _mock_method(self, method_name, method_obj=None):
  10. if method_obj is None:
  11. method_obj = self.record
  12. magic = MagicMock()
  13. method_obj._patch_method(method_name, magic)
  14. try:
  15. yield magic
  16. finally:
  17. method_obj._revert_method(method_name)