diff --git a/erpnext/hr/doctype/attendance/test_attendance.py b/erpnext/hr/doctype/attendance/test_attendance.py index 118cc987efb..c74967d213e 100644 --- a/erpnext/hr/doctype/attendance/test_attendance.py +++ b/erpnext/hr/doctype/attendance/test_attendance.py @@ -1,10 +1,9 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors # See license.txt -import unittest - import frappe -from frappe.utils import add_days, get_first_day, getdate, nowdate +from frappe.tests.utils import FrappeTestCase +from frappe.utils import add_days, get_first_day, getdate, now_datetime, nowdate from erpnext.hr.doctype.attendance.attendance import ( get_month_map, @@ -16,7 +15,7 @@ from erpnext.hr.doctype.leave_application.test_leave_application import get_firs test_records = frappe.get_test_records('Attendance') -class TestAttendance(unittest.TestCase): +class TestAttendance(FrappeTestCase): def test_mark_absent(self): employee = make_employee("test_mark_absent@example.com") date = nowdate() @@ -74,12 +73,14 @@ class TestAttendance(unittest.TestCase): self.assertNotIn(first_sunday, unmarked_days) def test_unmarked_days_as_per_joining_and_relieving_dates(self): - first_day = get_first_day(getdate()) + now = now_datetime() + previous_month = now.month - 1 + first_day = now.replace(day=1).replace(month=previous_month).date() doj = add_days(first_day, 1) relieving_date = add_days(first_day, 5) employee = make_employee('test_unmarked_days_as_per_doj@example.com', date_of_joining=doj, - date_of_relieving=relieving_date) + relieving_date=relieving_date) frappe.db.delete('Attendance', {'employee': employee}) attendance_date = add_days(first_day, 2) @@ -104,4 +105,4 @@ def get_month_name(date): month_number = date.month for month, number in get_month_map().items(): if number == month_number: - return month \ No newline at end of file + return month diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 39356bdcf18..38b8eef0c9b 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -791,4 +791,4 @@ def get_first_sunday(holiday_list): order by holiday_date """, (holiday_list, month_start_date, month_end_date))[0][0] - return first_sunday \ No newline at end of file + return first_sunday diff --git a/erpnext/projects/report/project_profitability/test_project_profitability.py b/erpnext/projects/report/project_profitability/test_project_profitability.py index 3396a2193cf..c80f301962c 100644 --- a/erpnext/projects/report/project_profitability/test_project_profitability.py +++ b/erpnext/projects/report/project_profitability/test_project_profitability.py @@ -2,6 +2,7 @@ import unittest import frappe +from frappe.tests.utils import FrappeTestCase from frappe.utils import add_days, getdate from erpnext.hr.doctype.employee.test_employee import make_employee @@ -13,7 +14,7 @@ from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_ from erpnext.projects.report.project_profitability.project_profitability import execute -class TestProjectProfitability(unittest.TestCase): +class TestProjectProfitability(FrappeTestCase): def setUp(self): frappe.db.sql('delete from `tabTimesheet`') emp = make_employee('test_employee_9@salary.com', company='_Test Company') @@ -68,6 +69,3 @@ class TestProjectProfitability(unittest.TestCase): fractional_cost = self.salary_slip.base_gross_pay * utilization self.assertEqual(fractional_cost, row.fractional_cost) - - def tearDown(self): - frappe.db.rollback()