Skip to content
Snippets Groups Projects
Commit adf28d52 authored by Raphael Collet's avatar Raphael Collet
Browse files

[FIX] tests: allow OdooSuite to handle unittest.TestCase without crashing


closes odoo/odoo#79669

Signed-off-by: default avatarRaphael Collet (rco) <rco@openerp.com>
parent ffca224e
No related branches found
No related tags found
No related merge requests found
......@@ -36,5 +36,6 @@ from . import test_res_partner
from . import test_res_partner_bank
from . import test_res_users
from . import test_reports
from . import test_test_suite
from . import test_tests_tags
from . import test_cloc
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from unittest import TestCase
class TestTestSuite(TestCase):
test_tags = {'standard', 'at_install'}
test_module = 'base'
def test_test_suite(self):
""" Check that OdooSuite handles unittest.TestCase correctly. """
......@@ -200,12 +200,13 @@ class OdooSuite(unittest.suite.TestSuite):
finally:
unittest.suite._call_if_exists(result, '_restoreStdout')
if currentClass._classSetupFailed is True:
currentClass.doClassCleanups()
if len(currentClass.tearDown_exceptions) > 0:
for exc in currentClass.tearDown_exceptions:
self._createClassOrModuleLevelException(
result, exc[1], 'setUpClass', className,
info=exc)
if hasattr(currentClass, 'doClassCleanups'):
currentClass.doClassCleanups()
if len(currentClass.tearDown_exceptions) > 0:
for exc in currentClass.tearDown_exceptions:
self._createClassOrModuleLevelException(
result, exc[1], 'setUpClass', className,
info=exc)
def _createClassOrModuleLevelException(self, result, exc, method_name, parent, info=None):
errorName = '%s (%s)' % (method_name, parent)
......@@ -248,14 +249,15 @@ class OdooSuite(unittest.suite.TestSuite):
className)
finally:
unittest.suite._call_if_exists(result, '_restoreStdout')
previousClass.doClassCleanups()
if len(previousClass.tearDown_exceptions) > 0:
for exc in previousClass.tearDown_exceptions:
className = unittest.util.strclass(previousClass)
self._createClassOrModuleLevelException(result, exc[1],
'tearDownClass',
className,
info=exc)
if hasattr(previousClass, 'doClassCleanups'):
previousClass.doClassCleanups()
if len(previousClass.tearDown_exceptions) > 0:
for exc in previousClass.tearDown_exceptions:
className = unittest.util.strclass(previousClass)
self._createClassOrModuleLevelException(result, exc[1],
'tearDownClass',
className,
info=exc)
class TreeCase(unittest.TestCase):
......
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