From 9f6412057e306777890d1002ded8d65ea7ff9368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 16 Apr 2022 18:30:17 +0200 Subject: [PATCH] Replace test setuptools command by unittest discover issue9215 review389851002 --- setup.py | 2 -- tests/__init__.py | 14 ++++---------- tests/{test_company.py => test_module.py} | 12 +++--------- tox.ini | 2 +- 4 files changed, 8 insertions(+), 22 deletions(-) rename tests/{test_company.py => test_module.py} (97%) diff --git a/setup.py b/setup.py index f6000e9913..ed1273ed51 100755 --- a/setup.py +++ b/setup.py @@ -149,6 +149,4 @@ setup(name=name, [trytond.modules] company = trytond.modules.company """, - test_suite='tests', - test_loader='trytond.test_loader:Loader', ) diff --git a/tests/__init__.py b/tests/__init__.py index 46ba80b18f..0988502b60 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,15 +1,9 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. - -try: - from trytond.modules.company.tests.test_company import ( - CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, - create_employee, set_company, suite) -except ImportError: - from .test_company import ( - CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, - create_employee, set_company, suite) +from .test_module import ( + CompanyTestMixin, PartyCompanyCheckEraseMixin, create_company, + create_employee, set_company) __all__ = [ - 'suite', 'create_company', 'set_company', 'create_employee', + 'create_company', 'set_company', 'create_employee', 'PartyCompanyCheckEraseMixin', 'CompanyTestMixin'] diff --git a/tests/test_company.py b/tests/test_module.py similarity index 97% rename from tests/test_company.py rename to tests/test_module.py index 9d8222352f..05289a6aa1 100644 --- a/tests/test_company.py +++ b/tests/test_module.py @@ -1,11 +1,11 @@ # 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 unittest + from collections import defaultdict from contextlib import contextmanager -import trytond.tests.test_tryton from trytond.model import ModelStorage, ModelView +from trytond.modules.company.model import CompanyMultiValueMixin from trytond.modules.currency.tests import add_currency_rate, create_currency from trytond.modules.party.tests import PartyCheckEraseMixin from trytond.pool import Pool, isregisteredby @@ -13,8 +13,6 @@ from trytond.pyson import Eval, PYSONEncoder from trytond.tests.test_tryton import ModuleTestCase, with_transaction from trytond.transaction import Transaction -from ..model import CompanyMultiValueMixin - def create_company(name='Dunder Mifflin', currency=None): pool = Pool() @@ -299,8 +297,4 @@ class CompanyTestCase( self.assertEqual(root.employee, employee) -def suite(): - suite = trytond.tests.test_tryton.suite() - suite.addTests(unittest.TestLoader().loadTestsFromTestCase( - CompanyTestCase)) - return suite +del ModuleTestCase diff --git a/tox.ini b/tox.ini index 914541a945..e4fa4df053 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = {py37,py38,py39,py310}-{sqlite,postgresql} [testenv] commands = - coverage run --include=.*/company/* setup.py test + coverage run --include=.*/company/* -m unittest discover -s tests coverage report --include=.*/company/* --omit=*/tests/* deps = coverage