|
10 | 10 | import subprocess |
11 | 11 | import threading |
12 | 12 | from contextlib import contextmanager |
13 | | -from unittest import mock |
| 13 | +from unittest import mock, TestCase |
14 | 14 | from pathlib import Path |
15 | 15 | from typing import Optional |
16 | 16 |
|
@@ -89,6 +89,7 @@ def pytest_cmdline_main(config): |
89 | 89 | "please provide a database name in the Odoo configuration file" |
90 | 90 | ) |
91 | 91 | disable_odoo_test_retry() |
| 92 | + support_subtest() |
92 | 93 | monkey_patch_resolve_pkg_root_and_module_name() |
93 | 94 | odoo.service.server.start(preload=[], stop=True) |
94 | 95 | # odoo.service.server.start() modifies the SIGINT signal by its own |
@@ -215,6 +216,22 @@ def disable_odoo_test_retry(): |
215 | 216 | # Odoo <= 15.0 |
216 | 217 | pass |
217 | 218 |
|
| 219 | +def support_subtest(): |
| 220 | + """Odoo from version 16.0 overwrite TestCase.SubTest context manager |
| 221 | +
|
| 222 | + This overwrite assume the usage of OdooTestResult which we are not |
| 223 | + using with pytest-odoo. So this restaure unitest SubTest Context manager |
| 224 | + """ |
| 225 | + try: |
| 226 | + from odoo.tests import BaseCase |
| 227 | + BaseCase.subTest = TestCase.subTest |
| 228 | + |
| 229 | + from odoo.tests.case import _Outcome |
| 230 | + _Outcome.result_supports_subtests = False |
| 231 | + except (ImportError, AttributeError): |
| 232 | + # Odoo <= 15.0 |
| 233 | + pass |
| 234 | + |
218 | 235 | def _find_manifest_path(collection_path: Path) -> Path: |
219 | 236 | """Try to locate an Odoo manifest file in the collection path.""" |
220 | 237 | # check if collection_path is an addon directory |
|
0 commit comments