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

        issue9215
        review389851002
diffstat:

 setup.py                       |   6 ++--
 tests/__init__.py              |   8 ------
 tests/test_module.py           |  45 ++++++++++++++++++++++++++++++++++++
 tests/test_production_split.py |  52 ------------------------------------------
 tox.ini                        |   3 +-
 5 files changed, 50 insertions(+), 64 deletions(-)

diffs (153 lines):

diff -r f006462e75f5 -r 0848fff481f1 setup.py
--- a/setup.py  Sun Apr 10 19:11:39 2022 +0200
+++ b/setup.py  Sat Apr 16 18:30:18 2022 +0200
@@ -137,13 +137,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]
     production_split = trytond.modules.production_split
     """,
-    test_suite='tests',
-    test_loader='trytond.test_loader:Loader',
-    tests_require=tests_require,
     )
diff -r f006462e75f5 -r 0848fff481f1 tests/__init__.py
--- a/tests/__init__.py Sun Apr 10 19:11:39 2022 +0200
+++ b/tests/__init__.py Sat Apr 16 18:30:18 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.production_split.tests.test_production_split import \
-        suite  # noqa: E501
-except ImportError:
-    from .test_production_split import suite
-
-__all__ = ['suite']
diff -r f006462e75f5 -r 0848fff481f1 tests/test_module.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_module.py      Sat Apr 16 18:30:18 2022 +0200
@@ -0,0 +1,45 @@
+# 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.mock import patch
+
+from trytond.pool import Pool
+from trytond.tests.test_tryton import ModuleTestCase, with_transaction
+
+
+class ProductionSplitTestCase(ModuleTestCase):
+    'Test Production Split module'
+    module = 'production_split'
+
+    @with_transaction()
+    def test_split(self):
+        'Test split'
+        pool = Pool()
+        Uom = pool.get('product.uom')
+        Production = pool.get('production')
+
+        unit, = Uom.search([('name', '=', 'Unit')])
+
+        with patch.object(Production, 'save'), \
+                patch.object(Production, 'explode_bom'), \
+                patch.object(Production, 'copy') as copy:
+            copy.side_effect = lambda l, values: [
+                Production(**values) for r in l]
+            for quantity, quantity_split, count, quantities in [
+                    (10, 5, None, [5, 5]),
+                    (13, 5, None, [5, 5, 3]),
+                    (7, 8, None, [7]),
+                    (20, 5, 2, [5, 5, 10]),
+                    (20, 5, 4, [5, 5, 5, 5]),
+                    ]:
+                production = Production()
+                production.quantity = quantity
+                production.uom = unit
+
+                productions = production.split(
+                    quantity_split, unit, count=count)
+                self.assertEqual(
+                    [p.quantity for p in productions], quantities)
+
+
+del ModuleTestCase
diff -r f006462e75f5 -r 0848fff481f1 tests/test_production_split.py
--- a/tests/test_production_split.py    Sun Apr 10 19:11:39 2022 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +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 unittest.mock import patch
-
-from trytond.pool import Pool
-from trytond.tests.test_tryton import ModuleTestCase
-from trytond.tests.test_tryton import suite as test_suite
-from trytond.tests.test_tryton import with_transaction
-
-
-class ProductionSplitTestCase(ModuleTestCase):
-    'Test Production Split module'
-    module = 'production_split'
-
-    @with_transaction()
-    def test_split(self):
-        'Test split'
-        pool = Pool()
-        Uom = pool.get('product.uom')
-        Production = pool.get('production')
-
-        unit, = Uom.search([('name', '=', 'Unit')])
-
-        with patch.object(Production, 'save'), \
-                patch.object(Production, 'explode_bom'), \
-                patch.object(Production, 'copy') as copy:
-            copy.side_effect = lambda l, values: [
-                Production(**values) for r in l]
-            for quantity, quantity_split, count, quantities in [
-                    (10, 5, None, [5, 5]),
-                    (13, 5, None, [5, 5, 3]),
-                    (7, 8, None, [7]),
-                    (20, 5, 2, [5, 5, 10]),
-                    (20, 5, 4, [5, 5, 5, 5]),
-                    ]:
-                production = Production()
-                production.quantity = quantity
-                production.uom = unit
-
-                productions = production.split(
-                    quantity_split, unit, count=count)
-                self.assertEqual(
-                    [p.quantity for p in productions], quantities)
-
-
-def suite():
-    suite = test_suite()
-    suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
-            ProductionSplitTestCase))
-    return suite
diff -r f006462e75f5 -r 0848fff481f1 tox.ini
--- a/tox.ini   Sun Apr 10 19:11:39 2022 +0200
+++ b/tox.ini   Sat Apr 16 18:30:18 2022 +0200
@@ -2,8 +2,9 @@
 envlist = {py37,py38,py39,py310}-{sqlite,postgresql}
 
 [testenv]
+extras = test
 commands =
-    coverage run --include=.*/production_split/* setup.py test
+    coverage run --include=.*/production_split/* -m unittest discover -s tests
     coverage report --include=.*/production_split/* --omit=*/tests/*
 deps =
     coverage

Reply via email to