changeset 9a30fd8c5a85 in modules/product_price_list_parent:default
details:
https://hg.tryton.org/modules/product_price_list_parent?cmd=changeset&node=9a30fd8c5a85
description:
Replace test setuptools command by unittest discover
issue9215
review389851002
diffstat:
setup.py | 6 +-
tests/__init__.py | 8 ---
tests/test_module.py | 69 +++++++++++++++++++++++++++++
tests/test_product_price_list_parent.py | 76 ---------------------------------
tox.ini | 3 +-
5 files changed, 74 insertions(+), 88 deletions(-)
diffs (201 lines):
diff -r 8bcfcb9d593b -r 9a30fd8c5a85 setup.py
--- a/setup.py Sun Apr 10 19:11:39 2022 +0200
+++ b/setup.py Sat Apr 16 18:30:18 2022 +0200
@@ -139,13 +139,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]
product_price_list_parent = trytond.modules.product_price_list_parent
""",
- test_suite='tests',
- test_loader='trytond.test_loader:Loader',
- tests_require=tests_require,
)
diff -r 8bcfcb9d593b -r 9a30fd8c5a85 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.product_price_list_parent.tests.test_product_price_list_parent
import \
- suite # noqa: E501
-except ImportError:
- from .test_product_price_list_parent import suite
-
-__all__ = ['suite']
diff -r 8bcfcb9d593b -r 9a30fd8c5a85 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,69 @@
+# 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.modules.company.tests import (
+ CompanyTestMixin, create_company, set_company)
+from trytond.pool import Pool
+from trytond.tests.test_tryton import ModuleTestCase, with_transaction
+
+
+class ProductPriceListParentTestCase(CompanyTestMixin, ModuleTestCase):
+ 'Test Product Price List Parent module'
+ module = 'product_price_list_parent'
+
+ @with_transaction()
+ def test_price_list_parent(self):
+ "Test price list with parent"
+ pool = Pool()
+ Template = pool.get('product.template')
+ Product = pool.get('product.product')
+ Party = pool.get('party.party')
+ Uom = pool.get('product.uom')
+ PriceList = pool.get('product.price_list')
+
+ company = create_company()
+ with set_company(company):
+ party = Party(name='Customer')
+ party.save()
+
+ unit, = Uom.search([('name', '=', "Unit")])
+
+ template = Template(
+ name="Template", list_price=Decimal(10), default_uom=unit)
+ template.save()
+ product = Product(template=template)
+ product.save()
+
+ price_list_parent, = PriceList.create([{
+ 'name': "Parent",
+ 'lines': [('create', [{
+ 'formula': 'unit_price * 2',
+ }])],
+ }])
+ price_list, = PriceList.create([{
+ 'name': "List",
+ 'parent': price_list_parent.id,
+ 'lines': [('create', [{
+ 'formula': 'parent_unit_price * 2',
+ }])],
+ }])
+
+ self.assertEqual(
+ price_list.compute(
+ party, product, product.list_price, 1, unit),
+ Decimal('40'))
+
+ @with_transaction()
+ def test_line_formula_help(self):
+ "Test help of line formula"
+ pool = Pool()
+ PriceListLine = pool.get('product.price_list.line')
+
+ fields = PriceListLine.fields_get(['formula'])
+
+ self.assertIn('parent_unit_price', fields['formula']['help'])
+
+
+del ModuleTestCase
diff -r 8bcfcb9d593b -r 9a30fd8c5a85 tests/test_product_price_list_parent.py
--- a/tests/test_product_price_list_parent.py Sun Apr 10 19:11:39 2022 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +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
-
-from trytond.modules.company.tests import (
- CompanyTestMixin, create_company, set_company)
-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 ProductPriceListParentTestCase(CompanyTestMixin, ModuleTestCase):
- 'Test Product Price List Parent module'
- module = 'product_price_list_parent'
-
- @with_transaction()
- def test_price_list_parent(self):
- "Test price list with parent"
- pool = Pool()
- Template = pool.get('product.template')
- Product = pool.get('product.product')
- Party = pool.get('party.party')
- Uom = pool.get('product.uom')
- PriceList = pool.get('product.price_list')
-
- company = create_company()
- with set_company(company):
- party = Party(name='Customer')
- party.save()
-
- unit, = Uom.search([('name', '=', "Unit")])
-
- template = Template(
- name="Template", list_price=Decimal(10), default_uom=unit)
- template.save()
- product = Product(template=template)
- product.save()
-
- price_list_parent, = PriceList.create([{
- 'name': "Parent",
- 'lines': [('create', [{
- 'formula': 'unit_price * 2',
- }])],
- }])
- price_list, = PriceList.create([{
- 'name': "List",
- 'parent': price_list_parent.id,
- 'lines': [('create', [{
- 'formula': 'parent_unit_price * 2',
- }])],
- }])
-
- self.assertEqual(
- price_list.compute(
- party, product, product.list_price, 1, unit),
- Decimal('40'))
-
- @with_transaction()
- def test_line_formula_help(self):
- "Test help of line formula"
- pool = Pool()
- PriceListLine = pool.get('product.price_list.line')
-
- fields = PriceListLine.fields_get(['formula'])
-
- self.assertIn('parent_unit_price', fields['formula']['help'])
-
-
-def suite():
- suite = test_suite()
- suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
- ProductPriceListParentTestCase))
- return suite
diff -r 8bcfcb9d593b -r 9a30fd8c5a85 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=.*/product_price_list_parent/* setup.py test
+ coverage run --include=.*/product_price_list_parent/* -m unittest discover
-s tests
coverage report --include=.*/product_price_list_parent/* --omit=*/tests/*
deps =
coverage