|
1 | 1 | # Copyright 2019 Camptocamp |
2 | 2 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
3 | | -import doctest |
4 | | -import logging |
5 | 3 | import typing |
6 | 4 | from contextlib import contextmanager |
7 | 5 | from itertools import groupby |
8 | 6 | from operator import attrgetter |
9 | 7 | from unittest import TestCase, mock |
10 | 8 |
|
11 | | -from odoo.tests.case import TestCase as _TestCase |
12 | | -from odoo.tests.common import MetaCase |
13 | | - |
14 | 9 | from odoo.addons.queue_job.delay import Graph |
15 | 10 |
|
16 | 11 | # pylint: disable=odoo-addons-relative-import |
@@ -411,51 +406,3 @@ def test_export(self): |
411 | 406 | delayable = mock.MagicMock(name="DelayableBinding") |
412 | 407 | delayable_cls.return_value = delayable |
413 | 408 | yield delayable_cls, delayable |
414 | | - |
415 | | - |
416 | | -class OdooDocTestCase(doctest.DocTestCase, _TestCase, MetaCase("DummyCase", (), {})): |
417 | | - """ |
418 | | - We need a custom DocTestCase class in order to: |
419 | | - - define test_tags to run as part of standard tests |
420 | | - - output a more meaningful test name than default "DocTestCase.runTest" |
421 | | - """ |
422 | | - |
423 | | - def __init__( |
424 | | - self, doctest, optionflags=0, setUp=None, tearDown=None, checker=None, seq=0 |
425 | | - ): |
426 | | - super().__init__( |
427 | | - doctest._dt_test, |
428 | | - optionflags=optionflags, |
429 | | - setUp=setUp, |
430 | | - tearDown=tearDown, |
431 | | - checker=checker, |
432 | | - ) |
433 | | - self.test_sequence = seq |
434 | | - |
435 | | - def setUp(self): |
436 | | - """Log an extra statement which test is started.""" |
437 | | - super().setUp() |
438 | | - logging.getLogger(__name__).info("Running tests for %s", self._dt_test.name) |
439 | | - |
440 | | - |
441 | | -def load_doctests(module): |
442 | | - """ |
443 | | - Generates a tests loading method for the doctests of the given module |
444 | | - https://docs.python.org/3/library/unittest.html#load-tests-protocol |
445 | | - """ |
446 | | - |
447 | | - def load_tests(loader, tests, ignore): |
448 | | - """ |
449 | | - Apply the 'test_tags' attribute to each DocTestCase found by the DocTestSuite. |
450 | | - Also extend the DocTestCase class trivially to fit the class teardown |
451 | | - that Odoo backported for its own test classes from Python 3.8. |
452 | | - """ |
453 | | - |
454 | | - for idx, test in enumerate(doctest.DocTestSuite(module)): |
455 | | - odoo_test = OdooDocTestCase(test, seq=idx) |
456 | | - odoo_test.test_tags = {"standard", "at_install", "queue_job", "doctest"} |
457 | | - tests.addTest(odoo_test) |
458 | | - |
459 | | - return tests |
460 | | - |
461 | | - return load_tests |
0 commit comments