From cf5de9d364c0c4238bc09cf9cc45ac10774c4856 Mon Sep 17 00:00:00 2001 From: Jared Esparza Date: Wed, 27 Apr 2022 15:37:56 +0200 Subject: [PATCH] Replace test setuptools command by unittest discover --- tests/__init__.py | 8 ------- ..._analytic_line_state.py => test_module.py} | 10 +------- tests/test_scenario.py | 23 +++++++++++++++++++ 3 files changed, 24 insertions(+), 17 deletions(-) rename tests/{test_analytic_line_state.py => test_module.py} (97%) create mode 100644 tests/test_scenario.py diff --git a/tests/__init__.py b/tests/__init__.py index 05fad51..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,8 +0,0 @@ -# The COPYRIGHT file at the top level of this repository contains the full -# copyright notices and license terms. -try: - from trytond.modules.analytic_line_state.tests.test_analytic_line_state import suite -except ImportError: - from .test_analytic_line_state import suite - -__all__ = ['suite'] diff --git a/tests/test_analytic_line_state.py b/tests/test_module.py similarity index 97% rename from tests/test_analytic_line_state.py rename to tests/test_module.py index 90f6ff6..d82ba94 100644 --- a/tests/test_analytic_line_state.py +++ b/tests/test_module.py @@ -445,12 +445,4 @@ class TestCase(CompanyTestMixin, ModuleTestCase): Move.post(move) -def suite(): - suite = test_suite() - suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestCase)) - suite.addTests(doctest.DocFileSuite( - 'scenario_account_asset_update_value.rst', - tearDown=doctest_teardown, encoding='utf-8', - checker=doctest_checker, - optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) - return suite +del ModuleTestCase diff --git a/tests/test_scenario.py b/tests/test_scenario.py new file mode 100644 index 0000000..b5e24ad --- /dev/null +++ b/tests/test_scenario.py @@ -0,0 +1,23 @@ + +# This file is part of Tryton. The COPYRIGHT file at the top level of +# this repository contains the full copyright notices and license terms. + +import doctest +import glob +import os + +from trytond.tests.test_tryton import doctest_checker, doctest_teardown + + +def load_tests(loader, tests, pattern): + cwd = os.getcwd() + try: + os.chdir(os.path.dirname(__file__)) + for scenario in glob.glob('*.rst'): + tests.addTests(doctest.DocFileSuite( + scenario, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, + optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) + finally: + os.chdir(cwd) + return tests \ No newline at end of file