changeset 91986753f931 in modules/timesheet_cost:default
details:
https://hg.tryton.org/modules/timesheet_cost?cmd=changeset&node=91986753f931
description:
Replace test setuptools command by unittest discover
issue9215
review389851002
diffstat:
setup.py | 2 -
tests/__init__.py | 7 -----
tests/test_module.py | 52 ++++++++++++++++++++++++++++++++++++++++
tests/test_timesheet_cost.py | 57 --------------------------------------------
tox.ini | 2 +-
5 files changed, 53 insertions(+), 67 deletions(-)
diffs (152 lines):
diff -r 1152a601cc97 -r 91986753f931 setup.py
--- a/setup.py Sun Apr 10 19:11:40 2022 +0200
+++ b/setup.py Sat Apr 16 18:30:20 2022 +0200
@@ -142,6 +142,4 @@
[trytond.modules]
timesheet_cost = trytond.modules.timesheet_cost
""",
- test_suite='tests',
- test_loader='trytond.test_loader:Loader',
)
diff -r 1152a601cc97 -r 91986753f931 tests/__init__.py
--- a/tests/__init__.py Sun Apr 10 19:11:40 2022 +0200
+++ b/tests/__init__.py Sat Apr 16 18:30:20 2022 +0200
@@ -1,9 +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.timesheet_cost.tests.test_timesheet_cost import suite
-except ImportError:
- from .test_timesheet_cost import suite
-
-__all__ = ['suite']
diff -r 1152a601cc97 -r 91986753f931 tests/test_module.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_module.py Sat Apr 16 18:30:20 2022 +0200
@@ -0,0 +1,52 @@
+# 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, create_employee, set_company)
+from trytond.pool import Pool
+from trytond.tests.test_tryton import ModuleTestCase, with_transaction
+
+
+class TimesheetCostTestCase(CompanyTestMixin, ModuleTestCase):
+ 'Test TimesheetCost module'
+ module = 'timesheet_cost'
+
+ @with_transaction()
+ def test_compute_cost_price(self):
+ 'Test compute_cost_price'
+ pool = Pool()
+ Party = pool.get('party.party')
+ EmployeeCostPrice = pool.get('company.employee_cost_price')
+
+ cost_prices = [
+ (datetime.date(2011, 1, 1), Decimal(10)),
+ (datetime.date(2012, 1, 1), Decimal(15)),
+ (datetime.date(2013, 1, 1), Decimal(20)),
+ ]
+ test_prices = [
+ (datetime.date(2010, 1, 1), 0),
+ (datetime.date(2011, 1, 1), Decimal(10)),
+ (datetime.date(2011, 6, 1), Decimal(10)),
+ (datetime.date(2012, 1, 1), Decimal(15)),
+ (datetime.date(2012, 6, 1), Decimal(15)),
+ (datetime.date(2013, 1, 1), Decimal(20)),
+ (datetime.date(2013, 6, 1), Decimal(20)),
+ ]
+ party = Party(name='Pam Beesly')
+ party.save()
+ company = create_company()
+ with set_company(company):
+ employee = create_employee(company)
+ for date, cost_price in cost_prices:
+ EmployeeCostPrice(
+ employee=employee,
+ date=date,
+ cost_price=cost_price).save()
+ for date, cost_price in test_prices:
+ self.assertEqual(employee.compute_cost_price(date), cost_price)
+
+
+del ModuleTestCase
diff -r 1152a601cc97 -r 91986753f931 tests/test_timesheet_cost.py
--- a/tests/test_timesheet_cost.py Sun Apr 10 19:11:40 2022 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +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
-
-import trytond.tests.test_tryton
-from trytond.modules.company.tests import (
- CompanyTestMixin, create_company, create_employee, set_company)
-from trytond.pool import Pool
-from trytond.tests.test_tryton import ModuleTestCase, with_transaction
-
-
-class TimesheetCostTestCase(CompanyTestMixin, ModuleTestCase):
- 'Test TimesheetCost module'
- module = 'timesheet_cost'
-
- @with_transaction()
- def test_compute_cost_price(self):
- 'Test compute_cost_price'
- pool = Pool()
- Party = pool.get('party.party')
- EmployeeCostPrice = pool.get('company.employee_cost_price')
-
- cost_prices = [
- (datetime.date(2011, 1, 1), Decimal(10)),
- (datetime.date(2012, 1, 1), Decimal(15)),
- (datetime.date(2013, 1, 1), Decimal(20)),
- ]
- test_prices = [
- (datetime.date(2010, 1, 1), 0),
- (datetime.date(2011, 1, 1), Decimal(10)),
- (datetime.date(2011, 6, 1), Decimal(10)),
- (datetime.date(2012, 1, 1), Decimal(15)),
- (datetime.date(2012, 6, 1), Decimal(15)),
- (datetime.date(2013, 1, 1), Decimal(20)),
- (datetime.date(2013, 6, 1), Decimal(20)),
- ]
- party = Party(name='Pam Beesly')
- party.save()
- company = create_company()
- with set_company(company):
- employee = create_employee(company)
- for date, cost_price in cost_prices:
- EmployeeCostPrice(
- employee=employee,
- date=date,
- cost_price=cost_price).save()
- for date, cost_price in test_prices:
- self.assertEqual(employee.compute_cost_price(date), cost_price)
-
-
-def suite():
- suite = trytond.tests.test_tryton.suite()
- suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
- TimesheetCostTestCase))
- return suite
diff -r 1152a601cc97 -r 91986753f931 tox.ini
--- a/tox.ini Sun Apr 10 19:11:40 2022 +0200
+++ b/tox.ini Sat Apr 16 18:30:20 2022 +0200
@@ -3,7 +3,7 @@
[testenv]
commands =
- coverage run --include=.*/timesheet_cost/* setup.py test
+ coverage run --include=.*/timesheet_cost/* -m unittest discover -s tests
coverage report --include=.*/timesheet_cost/* --omit=*/tests/*
deps =
coverage