From 895143a84735c91984f4803601c47b28e47d779b Mon Sep 17 00:00:00 2001 From: David Date: Wed, 16 Oct 2024 18:13:40 +0200 Subject: [PATCH] fix(testing): setup class must invoke super --- .../doctype/bank_clearance/test_bank_clearance.py | 1 + .../loyalty_point_entry/test_loyalty_point_entry.py | 1 + .../doctype/loyalty_program/test_loyalty_program.py | 3 ++- .../test_opening_invoice_creation_tool.py | 2 +- .../doctype/purchase_invoice/test_purchase_invoice.py | 4 ++-- erpnext/accounts/doctype/tax_rule/test_tax_rule.py | 1 + .../test_tax_withholding_category.py | 3 ++- .../test_deferred_revenue_and_expense.py | 4 +--- .../test_sales_payment_summary.py | 3 ++- erpnext/assets/doctype/asset/test_asset.py | 1 + .../test_asset_shift_allocation.py | 1 + erpnext/crm/doctype/appointment/test_appointment.py | 4 +++- .../test_opportunity_summary_by_sales_stage.py | 3 ++- erpnext/manufacturing/doctype/routing/test_routing.py | 1 + .../report/issue_analytics/test_issue_analytics.py | 11 ++++++----- erpnext/tests/test_point_of_sale.py | 8 -------- 16 files changed, 27 insertions(+), 24 deletions(-) diff --git a/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py index 087e41b3e5f..8c8bda311e3 100644 --- a/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/test_bank_clearance.py @@ -18,6 +18,7 @@ from erpnext.tests.utils import if_lending_app_installed, if_lending_app_not_ins class TestBankClearance(IntegrationTestCase): @classmethod def setUpClass(cls): + super().setUpClass() create_warehouse( warehouse_name="_Test Warehouse", properties={"parent_warehouse": "All Warehouses - _TC"}, diff --git a/erpnext/accounts/doctype/loyalty_point_entry/test_loyalty_point_entry.py b/erpnext/accounts/doctype/loyalty_point_entry/test_loyalty_point_entry.py index 4b185a45ae0..c085e6caf5e 100644 --- a/erpnext/accounts/doctype/loyalty_point_entry/test_loyalty_point_entry.py +++ b/erpnext/accounts/doctype/loyalty_point_entry/test_loyalty_point_entry.py @@ -13,6 +13,7 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal class TestLoyaltyPointEntry(IntegrationTestCase): @classmethod def setUpClass(cls): + super().setUpClass() # Create test records create_records() cls.loyalty_program_name = "Test Single Loyalty" diff --git a/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py b/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py index ee44ffcdc13..604e95df6b8 100644 --- a/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py +++ b/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py @@ -15,7 +15,8 @@ from erpnext.accounts.party import get_dashboard_info class TestLoyaltyProgram(IntegrationTestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): + super().setUpClass() # create relevant item, customer, loyalty program, etc create_records() diff --git a/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py b/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py index 1f9436a860c..decff33aeb1 100644 --- a/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py +++ b/erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py @@ -26,7 +26,7 @@ class UnitTestOpeningInvoiceCreationTool(UnitTestCase): class TestOpeningInvoiceCreationTool(IntegrationTestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): if not frappe.db.exists("Company", "_Test Opening Invoice Company"): make_company() create_dimension() diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index fdf4608ad62..b020b4fd905 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -44,13 +44,13 @@ IGNORE_TEST_RECORD_DEPENDENCIES = ["Serial No"] class TestPurchaseInvoice(IntegrationTestCase, StockTestMixin): @classmethod - def setUpClass(self): + def setUpClass(cls): super().setUpClass() unlink_payment_on_cancel_of_invoice() frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1) @classmethod - def tearDownClass(self): + def tearDownClass(cls): unlink_payment_on_cancel_of_invoice(0) def tearDown(self): diff --git a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py index dcc5c988e8c..2602ea14861 100644 --- a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py +++ b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py @@ -13,6 +13,7 @@ from erpnext.crm.doctype.opportunity.test_opportunity import make_opportunity class TestTaxRule(IntegrationTestCase): @classmethod def setUpClass(cls): + super().setUpClass() frappe.db.set_single_value("Shopping Cart Settings", "enabled", 0) @classmethod diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py index 0b3fd082c8e..9cda3036135 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py @@ -27,7 +27,8 @@ class UnitTestTaxWithholdingCategory(UnitTestCase): class TestTaxWithholdingCategory(IntegrationTestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): + super().setUpClass() # create relevant supplier, etc create_records() create_tax_withholding_category_records() diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py index 50e3e4b23c3..1d652a86f67 100644 --- a/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py +++ b/erpnext/accounts/report/deferred_revenue_and_expense/test_deferred_revenue_and_expense.py @@ -14,9 +14,7 @@ from erpnext.accounts.utils import get_fiscal_year class TestDeferredRevenueAndExpense(IntegrationTestCase, AccountsTestMixin): - @classmethod - def setUpClass(self): - self.maxDiff = None + maxDiff = None def clear_old_entries(self): sinv = qb.DocType("Sales Invoice") diff --git a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py index ea444b3444c..481e9381ff1 100644 --- a/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/test_sales_payment_summary.py @@ -17,7 +17,8 @@ EXTRA_TEST_RECORD_DEPENDENCIES = ["Sales Invoice"] class TestSalesPaymentSummary(IntegrationTestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): + super().setUpClass() create_records() pes = frappe.get_all("Payment Entry") jes = frappe.get_all("Journal Entry") diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 431110a382a..f475a785e4f 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -45,6 +45,7 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_pu class AssetSetup(IntegrationTestCase): @classmethod def setUpClass(cls): + super().setUpClass() set_depreciation_settings_in_company() create_asset_data() enable_cwip_accounting("Computers") diff --git a/erpnext/assets/doctype/asset_shift_allocation/test_asset_shift_allocation.py b/erpnext/assets/doctype/asset_shift_allocation/test_asset_shift_allocation.py index a739a7551db..4295901568b 100644 --- a/erpnext/assets/doctype/asset_shift_allocation/test_asset_shift_allocation.py +++ b/erpnext/assets/doctype/asset_shift_allocation/test_asset_shift_allocation.py @@ -23,6 +23,7 @@ class UnitTestAssetShiftAllocation(UnitTestCase): class TestAssetShiftAllocation(IntegrationTestCase): @classmethod def setUpClass(cls): + super().setUpClass() create_asset_shift_factors() @classmethod diff --git a/erpnext/crm/doctype/appointment/test_appointment.py b/erpnext/crm/doctype/appointment/test_appointment.py index 3e5f2526a76..e88a3dc67e5 100644 --- a/erpnext/crm/doctype/appointment/test_appointment.py +++ b/erpnext/crm/doctype/appointment/test_appointment.py @@ -27,7 +27,9 @@ def create_test_appointment(): class TestAppointment(IntegrationTestCase): - def setUpClass(): + @classmethod + def setUpClass(cls): + super().setUpClass() frappe.db.delete("Lead", {"email_id": LEAD_EMAIL}) def setUp(self): diff --git a/erpnext/crm/report/opportunity_summary_by_sales_stage/test_opportunity_summary_by_sales_stage.py b/erpnext/crm/report/opportunity_summary_by_sales_stage/test_opportunity_summary_by_sales_stage.py index 012ac5dc78f..63d6cae3b00 100644 --- a/erpnext/crm/report/opportunity_summary_by_sales_stage/test_opportunity_summary_by_sales_stage.py +++ b/erpnext/crm/report/opportunity_summary_by_sales_stage/test_opportunity_summary_by_sales_stage.py @@ -15,7 +15,8 @@ from erpnext.crm.report.sales_pipeline_analytics.test_sales_pipeline_analytics i class TestOpportunitySummaryBySalesStage(IntegrationTestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): + super().setUpClass() create_company() create_customer() create_opportunity() diff --git a/erpnext/manufacturing/doctype/routing/test_routing.py b/erpnext/manufacturing/doctype/routing/test_routing.py index 6fe6a5456e5..7e1ac11486a 100644 --- a/erpnext/manufacturing/doctype/routing/test_routing.py +++ b/erpnext/manufacturing/doctype/routing/test_routing.py @@ -21,6 +21,7 @@ class UnitTestRouting(UnitTestCase): class TestRouting(IntegrationTestCase): @classmethod def setUpClass(cls): + super().setUpClass() cls.item_code = "Test Routing Item - A" @classmethod diff --git a/erpnext/support/report/issue_analytics/test_issue_analytics.py b/erpnext/support/report/issue_analytics/test_issue_analytics.py index 05ff98f5cd6..1598ef9d295 100644 --- a/erpnext/support/report/issue_analytics/test_issue_analytics.py +++ b/erpnext/support/report/issue_analytics/test_issue_analytics.py @@ -16,17 +16,18 @@ months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", class TestIssueAnalytics(IntegrationTestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): + super().setUpClass() frappe.db.sql("delete from `tabIssue` where company='_Test Company'") frappe.db.set_single_value("Support Settings", "track_service_level_agreement", 1) current_month_date = getdate() last_month_date = add_months(current_month_date, -1) - self.current_month = str(months[current_month_date.month - 1]).lower() - self.last_month = str(months[last_month_date.month - 1]).lower() + cls.current_month = str(months[current_month_date.month - 1]).lower() + cls.last_month = str(months[last_month_date.month - 1]).lower() if current_month_date.year != last_month_date.year: - self.current_month += "_" + str(current_month_date.year) - self.last_month += "_" + str(last_month_date.year) + cls.current_month += "_" + str(current_month_date.year) + cls.last_month += "_" + str(last_month_date.year) def test_issue_analytics(self): create_service_level_agreements_for_issues() diff --git a/erpnext/tests/test_point_of_sale.py b/erpnext/tests/test_point_of_sale.py index 014a0ac53aa..589c7cb0e48 100644 --- a/erpnext/tests/test_point_of_sale.py +++ b/erpnext/tests/test_point_of_sale.py @@ -12,14 +12,6 @@ from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry class TestPointOfSale(IntegrationTestCase): - @classmethod - def setUpClass(cls) -> None: - frappe.db.savepoint("before_test_point_of_sale") - - @classmethod - def tearDownClass(cls) -> None: - frappe.db.rollback(save_point="before_test_point_of_sale") - def test_item_search(self): """ Test Stock and Service Item Search.