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

        issue9215
        review389851002
diffstat:

 setup.py                           |   6 +-
 tests/__init__.py                  |   8 ---
 tests/test_account_credit_limit.py |  88 --------------------------------------
 tests/test_module.py               |  83 +++++++++++++++++++++++++++++++++++
 tox.ini                            |   3 +-
 5 files changed, 88 insertions(+), 100 deletions(-)

diffs (227 lines):

diff -r 3c8356b32e50 -r 1bad81fe827b setup.py
--- a/setup.py  Sun Apr 10 19:11:37 2022 +0200
+++ b/setup.py  Sat Apr 16 18:30:16 2022 +0200
@@ -138,13 +138,13 @@
     license='GPL-3',
     python_requires='>=3.7',
     install_requires=requires,
+    extras_require={
+        'test': tests_require,
+        },
     dependency_links=dependency_links,
     zip_safe=False,
     entry_points="""
     [trytond.modules]
     account_credit_limit = trytond.modules.account_credit_limit
     """,
-    test_suite='tests',
-    test_loader='trytond.test_loader:Loader',
-    tests_require=tests_require,
     )
diff -r 3c8356b32e50 -r 1bad81fe827b tests/__init__.py
--- a/tests/__init__.py Sun Apr 10 19:11:37 2022 +0200
+++ b/tests/__init__.py Sat Apr 16 18:30:16 2022 +0200
@@ -1,10 +1,2 @@
 # 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.account_credit_limit.tests.test_account_credit_limit 
import \
-        suite  # noqa: E501
-except ImportError:
-    from .test_account_credit_limit import suite
-
-__all__ = ['suite']
diff -r 3c8356b32e50 -r 1bad81fe827b tests/test_account_credit_limit.py
--- a/tests/test_account_credit_limit.py        Sun Apr 10 19:11:37 2022 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +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.
-import unittest
-from decimal import Decimal
-
-import trytond.tests.test_tryton
-from trytond.exceptions import UserError, UserWarning
-from trytond.modules.account.tests import create_chart, get_fiscalyear
-from trytond.modules.company.tests import (
-    CompanyTestMixin, create_company, set_company)
-from trytond.pool import Pool
-from trytond.tests.test_tryton import ModuleTestCase, with_transaction
-
-
-class AccountCreditLimitTestCase(CompanyTestMixin, ModuleTestCase):
-    'Test AccountCreditLimit module'
-    module = 'account_credit_limit'
-    extras = ['account_dunning']
-
-    @with_transaction()
-    def test_check_credit_limit(self):
-        'Test check_credit_limit'
-        pool = Pool()
-        Account = pool.get('account.account')
-        Move = pool.get('account.move')
-        Journal = pool.get('account.journal')
-        Party = pool.get('party.party')
-
-        company = create_company()
-        with set_company(company):
-            create_chart(company)
-            fiscalyear = get_fiscalyear(company)
-            fiscalyear.save()
-            fiscalyear.create_period([fiscalyear])
-            period = fiscalyear.periods[0]
-
-            receivable, = Account.search([
-                    ('type.receivable', '=', True),
-                    ])
-            revenue, = Account.search([
-                    ('type.revenue', '=', True),
-                    ])
-            journal, = Journal.search([], limit=1)
-            party, = Party.create([{
-                        'name': 'Party',
-                        }])
-            Move.create([{
-                        'journal': journal.id,
-                        'period': period.id,
-                        'date': period.start_date,
-                        'lines': [
-                            ('create', [{
-                                        'debit': Decimal(100),
-                                        'account': receivable.id,
-                                        'party': party.id,
-                                        }, {
-                                        'credit': Decimal(100),
-                                        'account': revenue.id,
-                                        }]),
-                            ],
-                        }])
-            self.assertEqual(party.credit_amount, Decimal(100))
-            self.assertEqual(party.credit_limit_amount, None)
-            party.check_credit_limit(Decimal(0))
-            party.check_credit_limit(Decimal(0), 'test')
-            party.check_credit_limit(Decimal(100))
-            party.check_credit_limit(Decimal(100), 'test')
-            party.credit_limit_amount = Decimal(0)
-            party.save()
-            self.assertRaises(UserError, party.check_credit_limit,
-                Decimal(0))
-            self.assertRaises(UserWarning, party.check_credit_limit,
-                Decimal(0), 'test')
-            party.credit_limit_amount = Decimal(200)
-            party.save()
-            party.check_credit_limit(Decimal(0))
-            party.check_credit_limit(Decimal(0), 'test')
-            self.assertRaises(UserError, party.check_credit_limit,
-                Decimal(150))
-            self.assertRaises(UserWarning, party.check_credit_limit,
-                Decimal(150), 'test')
-
-
-def suite():
-    suite = trytond.tests.test_tryton.suite()
-    suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
-        AccountCreditLimitTestCase))
-    return suite
diff -r 3c8356b32e50 -r 1bad81fe827b tests/test_module.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_module.py      Sat Apr 16 18:30:16 2022 +0200
@@ -0,0 +1,83 @@
+# 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 decimal import Decimal
+
+from trytond.exceptions import UserError, UserWarning
+from trytond.modules.account.tests import create_chart, get_fiscalyear
+from trytond.modules.company.tests import (
+    CompanyTestMixin, create_company, set_company)
+from trytond.pool import Pool
+from trytond.tests.test_tryton import ModuleTestCase, with_transaction
+
+
+class AccountCreditLimitTestCase(CompanyTestMixin, ModuleTestCase):
+    'Test AccountCreditLimit module'
+    module = 'account_credit_limit'
+    extras = ['account_dunning']
+
+    @with_transaction()
+    def test_check_credit_limit(self):
+        'Test check_credit_limit'
+        pool = Pool()
+        Account = pool.get('account.account')
+        Move = pool.get('account.move')
+        Journal = pool.get('account.journal')
+        Party = pool.get('party.party')
+
+        company = create_company()
+        with set_company(company):
+            create_chart(company)
+            fiscalyear = get_fiscalyear(company)
+            fiscalyear.save()
+            fiscalyear.create_period([fiscalyear])
+            period = fiscalyear.periods[0]
+
+            receivable, = Account.search([
+                    ('type.receivable', '=', True),
+                    ])
+            revenue, = Account.search([
+                    ('type.revenue', '=', True),
+                    ])
+            journal, = Journal.search([], limit=1)
+            party, = Party.create([{
+                        'name': 'Party',
+                        }])
+            Move.create([{
+                        'journal': journal.id,
+                        'period': period.id,
+                        'date': period.start_date,
+                        'lines': [
+                            ('create', [{
+                                        'debit': Decimal(100),
+                                        'account': receivable.id,
+                                        'party': party.id,
+                                        }, {
+                                        'credit': Decimal(100),
+                                        'account': revenue.id,
+                                        }]),
+                            ],
+                        }])
+            self.assertEqual(party.credit_amount, Decimal(100))
+            self.assertEqual(party.credit_limit_amount, None)
+            party.check_credit_limit(Decimal(0))
+            party.check_credit_limit(Decimal(0), 'test')
+            party.check_credit_limit(Decimal(100))
+            party.check_credit_limit(Decimal(100), 'test')
+            party.credit_limit_amount = Decimal(0)
+            party.save()
+            self.assertRaises(UserError, party.check_credit_limit,
+                Decimal(0))
+            self.assertRaises(UserWarning, party.check_credit_limit,
+                Decimal(0), 'test')
+            party.credit_limit_amount = Decimal(200)
+            party.save()
+            party.check_credit_limit(Decimal(0))
+            party.check_credit_limit(Decimal(0), 'test')
+            self.assertRaises(UserError, party.check_credit_limit,
+                Decimal(150))
+            self.assertRaises(UserWarning, party.check_credit_limit,
+                Decimal(150), 'test')
+
+
+del ModuleTestCase
diff -r 3c8356b32e50 -r 1bad81fe827b tox.ini
--- a/tox.ini   Sun Apr 10 19:11:37 2022 +0200
+++ b/tox.ini   Sat Apr 16 18:30:16 2022 +0200
@@ -2,8 +2,9 @@
 envlist = {py37,py38,py39,py310}-{sqlite,postgresql}
 
 [testenv]
+extras = test
 commands =
-    coverage run --include=.*/account_credit_limit/* setup.py test
+    coverage run --include=.*/account_credit_limit/* -m unittest discover -s 
tests
     coverage report --include=.*/account_credit_limit/* --omit=*/tests/*
 deps =
     coverage

Reply via email to