changeset b0d60f23ed96 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=b0d60f23ed96
description:
        Replace test setuptools command by unittest discover

        issue9215
        review389851002
diffstat:

 CHANGELOG                                  |   1 +
 doc/topics/testing.rst                     |  97 ++++++++++++++---------------
 setup.py                                   |   4 +-
 tox.ini                                    |   3 +-
 trytond/test_loader.py                     |  10 ---
 trytond/tests/__init__.py                  |   5 -
 trytond/tests/run-tests.py                 |  54 ----------------
 trytond/tests/test_access.py               |  18 +-----
 trytond/tests/test_backend.py              |   4 -
 trytond/tests/test_bus.py                  |   9 --
 trytond/tests/test_cache.py                |  14 ----
 trytond/tests/test_copy.py                 |   8 --
 trytond/tests/test_descriptors.py          |   8 +-
 trytond/tests/test_exportdata.py           |   4 -
 trytond/tests/test_field_binary.py         |   4 -
 trytond/tests/test_field_boolean.py        |   4 -
 trytond/tests/test_field_char.py           |  10 ---
 trytond/tests/test_field_context.py        |   8 --
 trytond/tests/test_field_date.py           |   4 -
 trytond/tests/test_field_datetime.py       |   4 -
 trytond/tests/test_field_depends.py        |   4 -
 trytond/tests/test_field_dict.py           |   4 -
 trytond/tests/test_field_float.py          |   4 -
 trytond/tests/test_field_function.py       |   4 -
 trytond/tests/test_field_integer.py        |   4 -
 trytond/tests/test_field_many2many.py      |   9 --
 trytond/tests/test_field_many2one.py       |  10 ---
 trytond/tests/test_field_multiselection.py |   9 --
 trytond/tests/test_field_numeric.py        |   4 -
 trytond/tests/test_field_one2many.py       |   9 --
 trytond/tests/test_field_one2one.py        |   4 -
 trytond/tests/test_field_reference.py      |   4 -
 trytond/tests/test_field_selection.py      |   4 -
 trytond/tests/test_field_text.py           |   9 --
 trytond/tests/test_field_time.py           |   4 -
 trytond/tests/test_field_timedelta.py      |   4 -
 trytond/tests/test_filestore.py            |   4 -
 trytond/tests/test_history.py              |   4 -
 trytond/tests/test_i18n.py                 |   7 --
 trytond/tests/test_importdata.py           |   4 -
 trytond/tests/test_ir.py                   |   4 +-
 trytond/tests/test_mixins.py               |   8 --
 trytond/tests/test_model.py                |  12 ---
 trytond/tests/test_modelsingleton.py       |   4 -
 trytond/tests/test_modelsql.py             |   9 --
 trytond/tests/test_modelstorage.py         |   8 --
 trytond/tests/test_modelview.py            |   8 --
 trytond/tests/test_mptt.py                 |   4 -
 trytond/tests/test_multivalue.py           |   4 -
 trytond/tests/test_order.py                |   5 -
 trytond/tests/test_path.py                 |   4 -
 trytond/tests/test_protocols.py            |   7 --
 trytond/tests/test_pyson.py                |   4 -
 trytond/tests/test_report.py               |   7 --
 trytond/tests/test_res.py                  |   3 +-
 trytond/tests/test_resource.py             |   4 -
 trytond/tests/test_routes.py               |   4 -
 trytond/tests/test_rpc.py                  |   4 -
 trytond/tests/test_rule.py                 |   7 --
 trytond/tests/test_sendmail.py             |   4 -
 trytond/tests/test_sequence.py             |   9 --
 trytond/tests/test_tools.py                |  13 +---
 trytond/tests/test_transaction.py          |   4 -
 trytond/tests/test_tree.py                 |   4 -
 trytond/tests/test_trigger.py              |   4 -
 trytond/tests/test_tryton.py               |  69 ++------------------
 trytond/tests/test_union.py                |   4 -
 trytond/tests/test_user.py                 |   4 -
 trytond/tests/test_wizard.py               |   4 -
 trytond/tests/test_workflow.py             |   4 -
 trytond/tests/test_wsgi.py                 |   7 --
 71 files changed, 68 insertions(+), 554 deletions(-)

diffs (1170 lines):

diff -r 8b1644ea12fa -r b0d60f23ed96 CHANGELOG
--- a/CHANGELOG Sat Apr 16 11:25:38 2022 +0200
+++ b/CHANGELOG Sat Apr 16 18:30:20 2022 +0200
@@ -1,3 +1,4 @@
+* Use unittest discover
 * Add module tutorial
 * Test all XML view and SVG icon files are used
 * Add notification message
diff -r 8b1644ea12fa -r b0d60f23ed96 doc/topics/testing.rst
--- a/doc/topics/testing.rst    Sat Apr 16 11:25:38 2022 +0200
+++ b/doc/topics/testing.rst    Sat Apr 16 18:30:20 2022 +0200
@@ -42,71 +42,66 @@
             "Test method"
             self.assertTrue(True)
 
+    del ModuleTestCase
 
-Tests from this modules are found by the function
-``trytond.modules.my_module.tests.suite`` which must return a
-``unittest.TestSuite`` containing all the module's tests. This function is
-called by the Tryton test runner script to gather all the tests.
-
-A typical ``suite()`` function thus looks like this:
-
-.. code-block:: python
 
-    def suite():
-        suite = trytond.tests.test_tryton.suite()
-        suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            MyModuleTestCase))
-        suite.addTests(doctest.DocFileSuite('scenario_my_module.rst',
-                tearDown=doctest_teardown, encoding='utf-8',
-                optionflags=doctest.REPORT_ONLY_FIRST_FAILURE,
-                checker=doctest_checker))
-        return suite
+.. note::
+   The ``ModuleTestCase`` must be deleted to not be discovered by ``unittest``
+   as it fails to run without module declaration.
 
 .. _doctests: https://docs.python.org/library/doctest.html
 .. _unittest: https://docs.python.org/library/unittest.html
 
+Running trytond's tests
+-----------------------
+
+You can run a specific test file using ``unittest`` command line like:
+
+.. code-block:: console
+
+   $ python -m unittest trytond.tests.test_tools
+
+To run all trytond's tests using discover of ``unittest`` with:
+
+.. code-block:: console
+
+   $ python -m unittest discover -s trytond.tests
+
+To run all modules tests:
+
+.. code-block:: console
+
+   $ python -m unittest discover -s trytond.modules
+
+
 Running your module's tests
 ---------------------------
 
-Tryton provides the script ``trytond/tests/run-tests.py``, just invoke it like
-that:
+You just need to replace the directory path with the one of your module:
 
 .. code-block:: console
 
-    $ python -m trytond.tests.run-tests -m my_module
+   $ python -m unittest discover -s trytond.modules.my_module.tests
+
+Extending trytond's tests
+-------------------------
 
-Testing trytond
+Python modules extending ``trytond`` core can define additional classes to
+register in ``tests`` module.
+Those modules must create an entry point ``trytond.tests`` which defines a
+``register`` function to be called with the module name.
+
+Testing options
 ~~~~~~~~~~~~~~~
 
-Extending tests
----------------
-
-Python modules extending ``trytond`` core can define additional tests that
-should be added to the existing ones.
-
-Those modules must create an entry point ``trytond.tests``.
-Any file in the module path specified by this entry point starting with
-``test_`` and ending by ``.py`` will be imported.
-Each of those file must define a ``suite()`` function that returns a
-``unittest.TestSuite`` that will be included in the ``trytond`` test suite.
-If the module from the entry point defines a ``register`` function it will be
-called when registering the test-specific models in the
-:class:`~trytond.pool.Pool`.
+Tryton runs tests against the configured database backend.
+You can specify the name of the database to use via the environment variable
+``DB_NAME``.
+Otherwise it generates a random name.
 
-Running trytond tests
----------------------
-
-You should use the script ``trytond/tests/run-tests.py`` by invoking it like
-that:
-
-.. code-block:: console
+A configuration file can be used by setting its path to the environment
+variable ``TRYTOND_CONFIG``.
 
-    $ python -m trytond.tests.run-tests
-
-You can use a different configuration file to check ``trytond`` against
-different backend:
-
-.. code-block:: console
-
-    $ python -m trytond.tests.run-tests -c <config>
-
+The tests recreate frequently the database. You can accelerate the creation by
+setting a cache directory in ``DB_CACHE`` environment which will be used to
+dump and restore initial databases backups.
diff -r 8b1644ea12fa -r b0d60f23ed96 setup.py
--- a/setup.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/setup.py  Sat Apr 16 18:30:20 2022 +0200
@@ -163,6 +163,7 @@
         'passlib >= 1.7.0',
         ],
     extras_require={
+        'test': tests_require,
         'PostgreSQL': ['psycopg2 >= 2.7.0'],
         'graphviz': ['pydot'],
         'Levenshtein': ['python-Levenshtein'],
@@ -175,9 +176,6 @@
         },
     dependency_links=dependency_links,
     zip_safe=False,
-    test_suite='trytond.tests',
-    test_loader='trytond.test_loader:Loader',
-    tests_require=tests_require,
     cmdclass={
         'update_rng': rnc2rng,
         },
diff -r 8b1644ea12fa -r b0d60f23ed96 tox.ini
--- a/tox.ini   Sat Apr 16 11:25:38 2022 +0200
+++ b/tox.ini   Sat Apr 16 18:30:20 2022 +0200
@@ -2,8 +2,9 @@
 envlist = {py37,py38,py39,py310}-{sqlite,postgresql}
 
 [testenv]
+extras = test
 commands =
-    coverage run setup.py test
+    coverage run -m unittest discover -s trytond.tests
     coverage report --include=./trytond/* --omit=*/tests/*
 deps =
     coverage
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/test_loader.py
--- a/trytond/test_loader.py    Sat Apr 16 11:25:38 2022 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-# This file is part of Tryton.  The COPYRIGHT file at the top level of
-# this repository contains the full copyright notices and license terms.
-
-from unittest import TestLoader
-
-
-class Loader(TestLoader):
-
-    def loadTestsFromModule(self, module):
-        return module.suite()
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/__init__.py
--- a/trytond/tests/__init__.py Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/__init__.py Sat Apr 16 18:30:20 2022 +0200
@@ -65,8 +65,3 @@
             test_module = test_ep.load()
             if hasattr(test_module, 'register'):
                 test_module.register('tests')
-
-
-def suite():
-    from .test_tryton import all_suite
-    return all_suite()
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/run-tests.py
--- a/trytond/tests/run-tests.py        Sat Apr 16 11:25:38 2022 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#!/usr/bin/env python3
-# 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 argparse
-import logging
-import os
-import sys
-import time
-import unittest
-
-from trytond.config import config
-
-if __name__ != '__main__':
-    raise ImportError('%s can not be imported' % __name__)
-
-logging.disable(logging.CRITICAL)
-parser = argparse.ArgumentParser()
-parser.add_argument("-c", "--config", dest="config",
-    help="specify config file")
-parser.add_argument("-f", "--failfast", action="store_true", dest="failfast",
-    help="Stop the test run on the first error or failure")
-parser.add_argument("-m", "--modules", action="store_true", dest="modules",
-    default=False, help="Run also modules tests")
-parser.add_argument("--no-doctest", action="store_false", dest="doctest",
-    default=True, help="Don't run doctest")
-parser.add_argument("-v", action="count", default=0, dest="verbosity",
-    help="Increase verbosity")
-parser.add_argument('tests', metavar='test', nargs='*')
-parser.epilog = ('The database name can be specified in the DB_NAME '
-    'environment variable.\n'
-    "A database dump cache directory can be specified in the DB_CACHE "
-    "environment variable. Dumps will be used to speed up re-run of tests.")
-opt = parser.parse_args()
-
-config.update_etc(opt.config)
-
-# Import after application is configured
-from trytond import backend  # noqa: E402
-
-if backend.name == 'sqlite':
-    database_name = ':memory:'
-else:
-    database_name = 'test_' + str(int(time.time()))
-os.environ.setdefault('DB_NAME', database_name)
-
-from trytond.tests.test_tryton import all_suite, modules_suite  # noqa: E402
-
-if not opt.modules:
-    suite = all_suite(opt.tests)
-else:
-    suite = modules_suite(opt.tests, doc=opt.doctest)
-result = unittest.TextTestRunner(
-    verbosity=opt.verbosity, failfast=opt.failfast).run(suite)
-sys.exit(not result.wasSuccessful())
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_access.py
--- a/trytond/tests/test_access.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_access.py      Sat Apr 16 18:30:20 2022 +0200
@@ -1030,20 +1030,4 @@
             TestAccess.write([record], {'field2': 'test'})
 
 
-def suite():
-    suite_ = unittest.TestSuite()
-    suite_.addTests(unittest.TestLoader(
-        ).loadTestsFromTestCase(ModelAccessReadTestCase))
-    suite_.addTests(unittest.TestLoader(
-        ).loadTestsFromTestCase(ModelAccessWriteTestCase))
-    suite_.addTests(unittest.TestLoader(
-        ).loadTestsFromTestCase(ModelAccessCreateTestCase))
-    suite_.addTests(unittest.TestLoader(
-        ).loadTestsFromTestCase(ModelAccessDeleteTestCase))
-    suite_.addTests(unittest.TestLoader(
-        ).loadTestsFromTestCase(ModelAccessModelTestCase))
-    suite_.addTests(unittest.TestLoader(
-        ).loadTestsFromTestCase(ModelFieldAccessReadTestCase))
-    suite_.addTests(unittest.TestLoader(
-        ).loadTestsFromTestCase(ModelFieldAccessWriteTestCase))
-    return suite_
+del _ModelAccessTestCase, _ModelFieldAccessTestCase
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_backend.py
--- a/trytond/tests/test_backend.py     Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_backend.py     Sat Apr 16 18:30:20 2022 +0200
@@ -171,7 +171,3 @@
                     cursor.execute(*Select([DateTrunc(type_, date)]))
                     value, = cursor.fetchone()
                     self.assertEqual(str(value), str(result))
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(BackendTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_bus.py
--- a/trytond/tests/test_bus.py Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_bus.py Sat Apr 16 18:30:20 2022 +0200
@@ -139,12 +139,3 @@
                     },
                 'channel': 'user:1',
                 })
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            MessageQueueTestCase))
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            BusTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_cache.py
--- a/trytond/tests/test_cache.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_cache.py       Sat Apr 16 18:30:20 2022 +0200
@@ -286,17 +286,3 @@
 
         self.assertEqual(lru_dict, {})
         self.assertEqual(lru_dict.counter, Transaction().counter)
-
-
-def suite():
-    func = unittest.TestLoader().loadTestsFromTestCase
-    suite = unittest.TestSuite()
-    for testcase in [
-            CacheTestCase,
-            MemoryCacheTestCase,
-            MemoryCacheChannelTestCase,
-            LRUDictTestCase,
-            LRUDictTransactionTestCase,
-            ]:
-        suite.addTests(func(testcase))
-    return suite
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_copy.py
--- a/trytond/tests/test_copy.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_copy.py        Sat Apr 16 18:30:20 2022 +0200
@@ -315,11 +315,3 @@
         with Transaction().set_context(language=self.other_language):
             record_copies = Translate.browse(record_copies)
             self.assertEqual({r.name for r in record_copies}, {"Bar"})
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(CopyTestCase))
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            CopyTranslationTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_descriptors.py
--- a/trytond/tests/test_descriptors.py Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_descriptors.py Sat Apr 16 18:30:20 2022 +0200
@@ -1,12 +1,10 @@
 # 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 unittest
 
 from trytond.model import descriptors
 
 
-def suite():
-    suite = unittest.TestSuite()
-    suite.addTest(doctest.DocTestSuite(descriptors))
-    return suite
+def load_tests(loader, tests, pattern):
+    tests.addTest(doctest.DocTestSuite(descriptors))
+    return tests
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_exportdata.py
--- a/trytond/tests/test_exportdata.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_exportdata.py  Sat Apr 16 18:30:20 2022 +0200
@@ -404,7 +404,3 @@
             ExportData.export_data_domain(
                 [('boolean', '=', True)], ['boolean']),
             [[True]])
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(ExportDataTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_binary.py
--- a/trytond/tests/test_field_binary.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_binary.py        Sat Apr 16 18:30:20 2022 +0200
@@ -202,7 +202,3 @@
 
         self.assertEqual(binary.binary, None)
         self.assertEqual(binary.binary_id, None)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldBinaryTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_boolean.py
--- a/trytond/tests/test_field_boolean.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_boolean.py       Sat Apr 16 18:30:20 2022 +0200
@@ -255,7 +255,3 @@
                 })
 
         self.assertEqual(boolean.boolean, True)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldBooleanTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_char.py
--- a/trytond/tests/test_field_char.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_char.py  Sat Apr 16 18:30:20 2022 +0200
@@ -673,13 +673,3 @@
         "Test order translated"
         pool = Pool()
         self._test_order(pool.get('test.char_translate'))
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite_.addTests(loader.loadTestsFromTestCase(FieldCharTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(FieldCharTranslatedTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(FieldCharUnaccentedTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(FieldCharSimilarityTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_context.py
--- a/trytond/tests/test_field_context.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_context.py       Sat Apr 16 18:30:20 2022 +0200
@@ -30,11 +30,3 @@
         parent.save()
         self.assertEqual(parent.child._context['name'], 'bar')
         self.assertEqual(parent.child._context['rec_name'], '')
-
-
-def suite():
-    func = unittest.TestLoader().loadTestsFromTestCase
-    suite = unittest.TestSuite()
-    for testcase in (FieldContextTestCase,):
-        suite.addTests(func(testcase))
-    return suite
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_date.py
--- a/trytond/tests/test_field_date.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_date.py  Sat Apr 16 18:30:20 2022 +0200
@@ -470,7 +470,3 @@
         result, = cursor.fetchone()
 
         self.assertEqual(result, datetime.date(2021, 10, 15))
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldDateTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_datetime.py
--- a/trytond/tests/test_field_datetime.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_datetime.py      Sat Apr 16 18:30:20 2022 +0200
@@ -487,7 +487,3 @@
             DateTime.write([datetime_], {
                     'datetime': datetime.date(2009, 1, 1),
                     })
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldDateTimeTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_depends.py
--- a/trytond/tests/test_field_depends.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_depends.py       Sat Apr 16 18:30:20 2022 +0200
@@ -263,7 +263,3 @@
                 ]:
             with self.subTest(value=value):
                 self.assertEqual(fields.get_eval_fields(value), result)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldDependsTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_dict.py
--- a/trytond/tests/test_field_dict.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_dict.py  Sat Apr 16 18:30:20 2022 +0200
@@ -928,7 +928,3 @@
                 ])
 
         self.assertListEqual(dicts, [dict_])
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldDictTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_float.py
--- a/trytond/tests/test_field_float.py Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_float.py Sat Apr 16 18:30:20 2022 +0200
@@ -455,7 +455,3 @@
             Float.write([float_], {
                     'digits': 0,
                     })
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldFloatTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_function.py
--- a/trytond/tests/test_field_function.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_function.py      Sat Apr 16 18:30:20 2022 +0200
@@ -86,7 +86,3 @@
             Model.read([record.id], ['function1', 'function2'])
 
             self.assertEqual(getter.call_count, 1)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldFunctionTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_integer.py
--- a/trytond/tests/test_field_integer.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_integer.py       Sat Apr 16 18:30:20 2022 +0200
@@ -344,7 +344,3 @@
             Integer.write([integer], {
                     'integer': 'non integer',
                     })
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldIntegerTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_many2many.py
--- a/trytond/tests/test_field_many2many.py     Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_many2many.py     Sat Apr 16 18:30:20 2022 +0200
@@ -724,12 +724,3 @@
 
     def Many2ManyTarget(self):
         return Pool().get('test.many2many_reference.target')
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite_.addTests(loader.loadTestsFromTestCase(FieldMany2ManyTestCase))
-    suite_.addTests(
-        loader.loadTestsFromTestCase(FieldMany2ManyReferenceTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_many2one.py
--- a/trytond/tests/test_field_many2one.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_many2one.py      Sat Apr 16 18:30:20 2022 +0200
@@ -431,13 +431,3 @@
 class FieldMany2OnePathTestCase(FieldMany2OneTreeTestCase):
     "Test Field Many2One Path"
     model_name = 'test.many2one_path'
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite_.addTests(loader.loadTestsFromTestCase(FieldMany2OneTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(FieldMany2OneTreeTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(FieldMany2OneMPTTTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(FieldMany2OnePathTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_multiselection.py
--- a/trytond/tests/test_field_multiselection.py        Sat Apr 16 11:25:38 
2022 +0200
+++ b/trytond/tests/test_field_multiselection.py        Sat Apr 16 18:30:20 
2022 +0200
@@ -345,12 +345,3 @@
                         'ALTER COLUMN %s TYPE json USING %s::json' % (
                             Model._table, name, name))
         Transaction().commit()
-
-
-def suite():
-    func = unittest.TestLoader().loadTestsFromTestCase
-    suite = unittest.TestSuite()
-    for testcase in [FieldMultiSelectionTestCase,
-            FieldMultiSelectionJSONBTestCase]:
-        suite.addTests(func(testcase))
-    return suite
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_numeric.py
--- a/trytond/tests/test_field_numeric.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_numeric.py       Sat Apr 16 18:30:20 2022 +0200
@@ -526,7 +526,3 @@
             Numeric.write([numeric], {
                     'digits': 0,
                     })
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldNumericTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_one2many.py
--- a/trytond/tests/test_field_one2many.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_one2many.py      Sat Apr 16 18:30:20 2022 +0200
@@ -630,12 +630,3 @@
 
     def One2ManyTarget(self):
         return Pool().get('test.one2many_reference.target')
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite_.addTests(loader.loadTestsFromTestCase(FieldOne2ManyTestCase))
-    suite_.addTests(
-        loader.loadTestsFromTestCase(FieldOne2ManyReferenceTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_one2one.py
--- a/trytond/tests/test_field_one2one.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_one2one.py       Sat Apr 16 18:30:20 2022 +0200
@@ -317,7 +317,3 @@
             One2One.write([one2one2], {
                     'one2one': target.id,
                     })
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldOne2OneTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_reference.py
--- a/trytond/tests/test_field_reference.py     Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_reference.py     Sat Apr 16 18:30:20 2022 +0200
@@ -524,7 +524,3 @@
                     'reference': str(target),
                     }])
         self.assertEqual(reference.reference, target)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldReferenceTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_selection.py
--- a/trytond/tests/test_field_selection.py     Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_selection.py     Sat Apr 16 18:30:20 2022 +0200
@@ -242,7 +242,3 @@
                     }])
 
         self.assertEqual(selection.dyn_select_static_string, '1')
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldSelectionTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_text.py
--- a/trytond/tests/test_field_text.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_text.py  Sat Apr 16 18:30:20 2022 +0200
@@ -653,12 +653,3 @@
             self.assertListEqual(
                 Model.search([], order=[('full_text', 'DESC')]),
                 [fat_cat, sad_cat, dog])
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite_.addTests(loader.loadTestsFromTestCase(FieldTextTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(FieldTextTranslatedTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(FieldFullTextTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_time.py
--- a/trytond/tests/test_field_time.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_time.py  Sat Apr 16 18:30:20 2022 +0200
@@ -485,7 +485,3 @@
             Time.write([time], {
                     'time': datetime.date(2009, 1, 1),
                     })
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldTimeTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_field_timedelta.py
--- a/trytond/tests/test_field_timedelta.py     Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_field_timedelta.py     Sat Apr 16 18:30:20 2022 +0200
@@ -475,7 +475,3 @@
         self.assertEqual(
             timedelta.timedelta,
             datetime.timedelta(seconds=42.5))
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FieldTimeDeltaTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_filestore.py
--- a/trytond/tests/test_filestore.py   Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_filestore.py   Sat Apr 16 18:30:20 2022 +0200
@@ -94,7 +94,3 @@
         self.assertNotEqual(id1, id2)
         self.assertEqual(filestore.get(id1, prefix='test'), data1)
         self.assertEqual(filestore.get(id2, prefix='test'), data2)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(FileStoreTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_history.py
--- a/trytond/tests/test_history.py     Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_history.py     Sat Apr 16 18:30:20 2022 +0200
@@ -497,7 +497,3 @@
 
             self.assertEqual({r.value for r in records}, {1})
             self.assertEqual(len(records), n)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(HistoryTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_i18n.py
--- a/trytond/tests/test_i18n.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_i18n.py        Sat Apr 16 18:30:20 2022 +0200
@@ -106,10 +106,3 @@
 
         self.assertIsInstance(lazy, LazyString)
         self.assertEqual(str(lazy), "Message")
-
-
-def suite():
-    suite = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite.addTests(loader.loadTestsFromTestCase(I18nTestCase))
-    return suite
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_importdata.py
--- a/trytond/tests/test_importdata.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_importdata.py  Sat Apr 16 18:30:20 2022 +0200
@@ -586,7 +586,3 @@
         self.assertEqual(count, 1)
         self.assertEqual(len(record.one2many), 2)
         self.assertEqual([t.name for t in record.one2many], ["bar", "baz"])
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(ImportDataTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_ir.py
--- a/trytond/tests/test_ir.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_ir.py  Sat Apr 16 18:30:20 2022 +0200
@@ -1,7 +1,6 @@
 # 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 datetime
-import unittest
 from decimal import Decimal
 from unittest.mock import ANY, Mock, patch
 
@@ -384,5 +383,4 @@
                 })
 
 
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(IrTestCase)
+del ModuleTestCase
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_mixins.py
--- a/trytond/tests/test_mixins.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_mixins.py      Sat Apr 16 18:30:20 2022 +0200
@@ -146,11 +146,3 @@
                 ([('active', 'in', [True, False])], [active, inactive]),
                 ]:
             self.assertListEqual(Deactivable.search(domain), founds)
-
-
-def suite():
-    func = unittest.TestLoader().loadTestsFromTestCase
-    suite = unittest.TestSuite()
-    for testcase in [UrlTestCase, MixinTestCase, DeactivableMixinTestCase]:
-        suite.addTests(func(testcase))
-    return suite
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_model.py
--- a/trytond/tests/test_model.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_model.py       Sat Apr 16 18:30:20 2022 +0200
@@ -415,15 +415,3 @@
         rec = Record(foo='baz')
 
         self.assertEqual(list(rec._values()), [('baz')])
-
-
-def suite():
-    func = unittest.TestLoader().loadTestsFromTestCase
-    suite_ = unittest.TestSuite()
-    for testcase in [
-            ModelTestCase,
-            ModelTranslationTestCase,
-            RecordTestCase,
-            ]:
-        suite_.addTests(func(testcase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_modelsingleton.py
--- a/trytond/tests/test_modelsingleton.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_modelsingleton.py      Sat Apr 16 18:30:20 2022 +0200
@@ -147,7 +147,3 @@
 
         Singleton.delete([singleton])
         self.assertEqual(singleton2.name, 'test')
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(ModelSingletonTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_modelsql.py
--- a/trytond/tests/test_modelsql.py    Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_modelsql.py    Sat Apr 16 18:30:20 2022 +0200
@@ -1350,12 +1350,3 @@
         self.assertIn(record.id, cache)
         self.assertEqual(cache[record.id]['name'], "Foo")
         self.assertNotIn('_timestamp', cache[record.id])
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            ModelSQLTestCase))
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            ModelSQLTranslationTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_modelstorage.py
--- a/trytond/tests/test_modelstorage.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_modelstorage.py        Sat Apr 16 18:30:20 2022 +0200
@@ -794,11 +794,3 @@
             record = Model(record.id)
 
             self.assertEqual(record.name, "Test")
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite_.addTests(loader.loadTestsFromTestCase(ModelStorageTestCase))
-    suite_.addTests(loader.loadTestsFromTestCase(EvalEnvironmentTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_modelview.py
--- a/trytond/tests/test_modelview.py   Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_modelview.py   Sat Apr 16 18:30:20 2022 +0200
@@ -689,11 +689,3 @@
         self.assertIn('bar', writeable_fields)
         self.assertIn('baz', writeable_fields)
         self.assertIn('quux', writeable_fields)
-
-
-def suite():
-    func = unittest.TestLoader().loadTestsFromTestCase
-    suite = unittest.TestSuite()
-    for testcase in (ModelView,):
-        suite.addTests(func(testcase))
-    return suite
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_mptt.py
--- a/trytond/tests/test_mptt.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_mptt.py        Sat Apr 16 18:30:20 2022 +0200
@@ -95,7 +95,3 @@
                                     }])],
                     }])
         self.check_tree()
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(MPTTTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_multivalue.py
--- a/trytond/tests/test_multivalue.py  Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_multivalue.py  Sat Apr 16 18:30:20 2022 +0200
@@ -156,7 +156,3 @@
 
         read, = ModelMultiValue.read([record.id], ['value'])
         self.assertEqual(read['value'], "getter")
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(MultiValueTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_order.py
--- a/trytond/tests/test_order.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_order.py       Sat Apr 16 18:30:20 2022 +0200
@@ -32,8 +32,3 @@
         models.insert(0, model)
 
         self.assertListEqual(Order.search([]), models)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(
-        SequenceOrderedMixinTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_path.py
--- a/trytond/tests/test_path.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_path.py        Sat Apr 16 18:30:20 2022 +0200
@@ -32,7 +32,3 @@
         pool = Pool()
         Path = pool.get(self.model_name)
         Path._rebuild_path('parent')
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(PathTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_protocols.py
--- a/trytond/tests/test_protocols.py   Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_protocols.py   Sat Apr 16 18:30:20 2022 +0200
@@ -118,10 +118,3 @@
         result, _ = client.loads(s)
         result, = result
         self.assertEqual(result, Decimal('3.141592653589793'))
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(JSONTestCase))
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(XMLTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_pyson.py
--- a/trytond/tests/test_pyson.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_pyson.py       Sat Apr 16 18:30:20 2022 +0200
@@ -870,7 +870,3 @@
     def test_eval_false(self):
         "Test PYSON.eval JS false"
         self.assertEqual(eval('false', pyson.CONTEXT), False)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(PYSONTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_report.py
--- a/trytond/tests/test_report.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_report.py      Sat Apr 16 18:30:20 2022 +0200
@@ -59,10 +59,3 @@
             ]):
     test_method = create_test_format_timedelta(i, in_, out)
     setattr(ReportTestCase, test_method.__name__, test_method)
-
-
-def suite():
-    suite = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite.addTests(loader.loadTestsFromTestCase(ReportTestCase))
-    return suite
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_res.py
--- a/trytond/tests/test_res.py Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_res.py Sat Apr 16 18:30:20 2022 +0200
@@ -85,5 +85,4 @@
         self.assertFalse(Warning_.check('test'))
 
 
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(ResTestCase)
+del ModuleTestCase
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_resource.py
--- a/trytond/tests/test_resource.py    Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_resource.py    Sat Apr 16 18:30:20 2022 +0200
@@ -78,7 +78,3 @@
 
         note = Note(note.id)
         self.assertEqual(user_note.write_date, write_date)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(ResourceTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_routes.py
--- a/trytond/tests/test_routes.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_routes.py      Sat Apr 16 18:30:20 2022 +0200
@@ -195,7 +195,3 @@
         self.assertEqual(response_std.status_code, 200)
         self.assertEqual(response_locale.status_code, 200)
         self.assertNotEqual(response_std.data, response_locale.data)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(RoutesTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_rpc.py
--- a/trytond/tests/test_rpc.py Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_rpc.py Sat Apr 16 18:30:20 2022 +0200
@@ -141,7 +141,3 @@
         self.assertEqual(
             rpc_with_access.convert(None, {}),
             ([], {}, {'_check_access': True}, None))
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(RPCTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_rule.py
--- a/trytond/tests/test_rule.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_rule.py        Sat Apr 16 18:30:20 2022 +0200
@@ -681,10 +681,3 @@
 
         with self.assertRaisesRegex(AccessError, "Field different from foo"):
             TestRuleModel.read([test.id], ['name'])
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    suite_.addTests(
-        unittest.TestLoader().loadTestsFromTestCase(ModelRuleTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_sendmail.py
--- a/trytond/tests/test_sendmail.py    Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_sendmail.py    Sat Apr 16 18:30:20 2022 +0200
@@ -112,7 +112,3 @@
 
         server.sendmail.assert_not_called()
         self.assertFalse(datamanager.queue)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(SendmailTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_sequence.py
--- a/trytond/tests/test_sequence.py    Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_sequence.py    Sat Apr 16 18:30:20 2022 +0200
@@ -149,12 +149,3 @@
     def get_model():
         pool = Pool()
         return pool.get('ir.sequence.strict')
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            SequenceTestCase))
-    suite_.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            SequenceStrictTestCase))
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_tools.py
--- a/trytond/tests/test_tools.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_tools.py       Sat Apr 16 18:30:20 2022 +0200
@@ -975,13 +975,6 @@
         self.assertEqual(extract_reference_models(domain, 'y'), set())
 
 
-def suite():
-    func = unittest.TestLoader().loadTestsFromTestCase
-    suite = unittest.TestSuite()
-    for testcase in [ToolsTestCase,
-            StringPartitionedTestCase,
-            ImmutableDictTestCase,
-            DomainInversionTestCase]:
-        suite.addTests(func(testcase))
-    suite.addTest(doctest.DocTestSuite(decimal_))
-    return suite
+def load_tests(loader, tests, pattern):
+    tests.addTest(doctest.DocTestSuite(decimal_))
+    return tests
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_transaction.py
--- a/trytond/tests/test_transaction.py Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_transaction.py Sat Apr 16 18:30:20 2022 +0200
@@ -121,7 +121,3 @@
         dm.tpc_vote.assert_not_called()
         dm.tpc_abort.assert_called_once_with(transaction)
         dm.tpc_finish.assert_not_called()
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(TransactionTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_tree.py
--- a/trytond/tests/test_tree.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_tree.py        Sat Apr 16 18:30:20 2022 +0200
@@ -429,7 +429,3 @@
         with self.assertRaises(RecursionError):
             parent1.parents = [child]
             parent1.save()
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(TreeMixinTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_trigger.py
--- a/trytond/tests/test_trigger.py     Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_trigger.py     Sat Apr 16 18:30:20 2022 +0200
@@ -479,7 +479,3 @@
 
         # Restart the cache on the get_triggers method of ir.trigger
         Trigger._get_triggers_cache.clear()
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(TriggerTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_tryton.py
--- a/trytond/tests/test_tryton.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_tryton.py      Sat Apr 16 18:30:20 2022 +0200
@@ -37,13 +37,18 @@
 
 __all__ = ['DB_NAME', 'USER', 'CONTEXT',
     'activate_module', 'ModuleTestCase', 'with_transaction',
-    'doctest_setup', 'doctest_teardown', 'doctest_checker',
-    'suite', 'all_suite', 'modules_suite']
+    'doctest_setup', 'doctest_teardown', 'doctest_checker']
 
 Pool.start()
 USER = 1
 CONTEXT = {}
-DB_NAME = os.environ['DB_NAME']
+if 'DB_NAME' in os.environ:
+    DB_NAME = os.environ['DB_NAME']
+elif backend.name == 'sqlite':
+    DB_NAME = ':memory:'
+else:
+    DB_NAME = 'test_' + str(int(time.time()))
+os.environ['DB_NAME'] = DB_NAME
 DB_CACHE = os.environ.get('DB_CACHE')
 Pool.test = True
 
@@ -1005,64 +1010,8 @@
         return result
 
 
-def suite():
+def load_tests(loader, tests, pattern):
     '''
     Return test suite for other modules
     '''
     return TestSuite()
-
-
-def all_suite(modules=None):
-    '''
-    Return all tests suite of current module
-    '''
-    suite_ = suite()
-
-    def add_tests(filename, module_prefix):
-        if not (filename.startswith('test_') and filename.endswith('.py')):
-            return
-        if modules and fn[:-3] not in modules:
-            return
-        modname = module_prefix + '.' + filename[:-3]
-        __import__(modname)
-        module = sys.modules[modname]
-        suite_.addTest(module.suite())
-
-    for fn in os.listdir(os.path.dirname(__file__)):
-        add_tests(fn, 'trytond.tests')
-    if pkg_resources is not None:
-        entry_points = pkg_resources.iter_entry_points('trytond.tests')
-        for test_entry_point in entry_points:
-            base_location = os.path.join(
-                test_entry_point.dist.location,
-                *test_entry_point.module_name.split('.'))
-            for fn in os.listdir(base_location):
-                add_tests(fn, test_entry_point.module_name)
-
-    return suite_
-
-
-def modules_suite(modules=None, doc=True):
-    '''
-    Return all tests suite of all modules
-    '''
-    if modules:
-        suite_ = suite()
-    else:
-        suite_ = all_suite()
-    from trytond.modules import create_graph, get_module_list, import_module
-    graph = create_graph(get_module_list())
-    for node in graph:
-        module = node.name
-        if modules and module not in modules:
-            continue
-        test_module = 'trytond.modules.%s.tests' % module
-        try:
-            test_mod = import_module(module, test_module)
-        except ImportError:
-            continue
-        for test in test_mod.suite():
-            if isinstance(test, doctest.DocTestCase) and not doc:
-                continue
-            suite_.addTest(test)
-    return suite_
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_union.py
--- a/trytond/tests/test_union.py       Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_union.py       Sat Apr 16 18:30:20 2022 +0200
@@ -101,7 +101,3 @@
         child_names = sorted((r.name for r in uroots[2].childs))
         self.assertEqual(child_names, ['Child1', 'Child2'])
         self.assertEqual(uroots[3].childs[0].name, 'Child3')
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(UnionMixinTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_user.py
--- a/trytond/tests/test_user.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_user.py        Sat Apr 16 18:30:20 2022 +0200
@@ -339,7 +339,3 @@
                         self.assertEqual(
                             User.get_login('user', {'device_cookie': value}),
                             result)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(UserTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_wizard.py
--- a/trytond/tests/test_wizard.py      Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_wizard.py      Sat Apr 16 18:30:20 2022 +0200
@@ -152,7 +152,3 @@
             with Transaction().set_context(
                     active_model='test.test_wizard.start'):
                 Wizard.execute(session_id, {}, start_state)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(WizardTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_workflow.py
--- a/trytond/tests/test_workflow.py    Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_workflow.py    Sat Apr 16 18:30:20 2022 +0200
@@ -29,7 +29,3 @@
         wkf.save()
         Workflowed.run([wkf])
         self.assertEqual(wkf.state, 'end')
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(WorkflowTestCase)
diff -r 8b1644ea12fa -r b0d60f23ed96 trytond/tests/test_wsgi.py
--- a/trytond/tests/test_wsgi.py        Sat Apr 16 11:25:38 2022 +0200
+++ b/trytond/tests/test_wsgi.py        Sat Apr 16 18:30:20 2022 +0200
@@ -110,10 +110,3 @@
 
         self.assertEqual(next(response.response), b'baz')
         self.assertEqual(response.status, "418 I'M A TEAPOT")
-
-
-def suite():
-    suite_ = unittest.TestSuite()
-    suite_.addTests(
-        unittest.TestLoader().loadTestsFromTestCase(WSGIAppTestCase))
-    return suite_

Reply via email to