changeset c0273a2efe1d in modules/product_price_list_dates:default
details:
https://hg.tryton.org/modules/product_price_list_dates?cmd=changeset&node=c0273a2efe1d
description:
Replace test setuptools command by unittest discover
issue9215
review389851002
diffstat:
setup.py | 6 +-
tests/__init__.py | 8 ---
tests/test_module.py | 76 +++++++++++++++++++++++++++++++
tests/test_product_price_list_dates.py | 83 ----------------------------------
tox.ini | 3 +-
5 files changed, 81 insertions(+), 95 deletions(-)
diffs (215 lines):
diff -r b5379a82c8a9 -r c0273a2efe1d 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_dates = trytond.modules.product_price_list_dates
""",
- test_suite='tests',
- test_loader='trytond.test_loader:Loader',
- tests_require=tests_require,
)
diff -r b5379a82c8a9 -r c0273a2efe1d 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_dates.tests.test_product_price_list_dates
import \
- suite # noqa: E501
-except ImportError:
- from .test_product_price_list_dates import suite
-
-__all__ = ['suite']
diff -r b5379a82c8a9 -r c0273a2efe1d 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,76 @@
+# 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
+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 ProductPriceListDatesTestCase(CompanyTestMixin, ModuleTestCase):
+ 'Test Product Price List Dates module'
+ module = 'product_price_list_dates'
+ extras = ['sale_price_list']
+
+ def create_price_list(self, field, date):
+ pool = Pool()
+ PriceList = pool.get('product.price_list')
+
+ company = create_company()
+ with set_company(company):
+ price_list, = PriceList.create([{
+ 'name': "Price List",
+ 'lines': [('create', [{
+ field: date,
+ 'formula': 'unit_price * 0.9',
+ }, {
+ 'formula': 'unit_price',
+ }])],
+ }])
+ return price_list
+
+ @with_transaction()
+ def test_price_list_start_date(self):
+ "Test price list with start date"
+ pool = Pool()
+ Date = pool.get('ir.date')
+
+ today = Date.today()
+ tomorrow = today + datetime.timedelta(days=1)
+
+ price_list = self.create_price_list('start_date', tomorrow)
+
+ self.assertEqual(
+ price_list.compute(
+ None, None, Decimal(10), 1, None, pattern={'date': today}),
+ Decimal(10))
+ self.assertEqual(
+ price_list.compute(
+ None, None, Decimal(10), 1, None, pattern={'date': tomorrow}),
+ Decimal(9))
+
+ @with_transaction()
+ def test_price_list_end_date(self):
+ "Test price list with end date"
+ pool = Pool()
+ Date = pool.get('ir.date')
+
+ today = Date.today()
+ yesterday = today - datetime.timedelta(days=1)
+
+ price_list = self.create_price_list('end_date', yesterday)
+
+ self.assertEqual(
+ price_list.compute(
+ None, None, Decimal(10), 1, None, pattern={'date': today}),
+ Decimal(10))
+ self.assertEqual(
+ price_list.compute(
+ None, None, Decimal(10), 1, None, pattern={'date': yesterday}),
+ Decimal(9))
+
+
+del ModuleTestCase
diff -r b5379a82c8a9 -r c0273a2efe1d tests/test_product_price_list_dates.py
--- a/tests/test_product_price_list_dates.py Sun Apr 10 19:11:39 2022 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +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 datetime
-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 ProductPriceListDatesTestCase(CompanyTestMixin, ModuleTestCase):
- 'Test Product Price List Dates module'
- module = 'product_price_list_dates'
- extras = ['sale_price_list']
-
- def create_price_list(self, field, date):
- pool = Pool()
- PriceList = pool.get('product.price_list')
-
- company = create_company()
- with set_company(company):
- price_list, = PriceList.create([{
- 'name': "Price List",
- 'lines': [('create', [{
- field: date,
- 'formula': 'unit_price * 0.9',
- }, {
- 'formula': 'unit_price',
- }])],
- }])
- return price_list
-
- @with_transaction()
- def test_price_list_start_date(self):
- "Test price list with start date"
- pool = Pool()
- Date = pool.get('ir.date')
-
- today = Date.today()
- tomorrow = today + datetime.timedelta(days=1)
-
- price_list = self.create_price_list('start_date', tomorrow)
-
- self.assertEqual(
- price_list.compute(
- None, None, Decimal(10), 1, None, pattern={'date': today}),
- Decimal(10))
- self.assertEqual(
- price_list.compute(
- None, None, Decimal(10), 1, None, pattern={'date': tomorrow}),
- Decimal(9))
-
- @with_transaction()
- def test_price_list_end_date(self):
- "Test price list with end date"
- pool = Pool()
- Date = pool.get('ir.date')
-
- today = Date.today()
- yesterday = today - datetime.timedelta(days=1)
-
- price_list = self.create_price_list('end_date', yesterday)
-
- self.assertEqual(
- price_list.compute(
- None, None, Decimal(10), 1, None, pattern={'date': today}),
- Decimal(10))
- self.assertEqual(
- price_list.compute(
- None, None, Decimal(10), 1, None, pattern={'date': yesterday}),
- Decimal(9))
-
-
-def suite():
- suite = test_suite()
- suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
- ProductPriceListDatesTestCase))
- return suite
diff -r b5379a82c8a9 -r c0273a2efe1d 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_dates/* setup.py test
+ coverage run --include=.*/product_price_list_dates/* -m unittest discover
-s tests
coverage report --include=.*/product_price_list_dates/* --omit=*/tests/*
deps =
coverage