From 29cf028f9afa00740317cca80a5b8426b90617e6 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 16 Jul 2025 13:29:02 +0530 Subject: [PATCH] refactor: replace all IntegrationTestCase -> ERPNextTestSuite --- .../test_tax_withholding_entry.py | 11 ++--------- .../test_tax_withholding_group.py | 11 ++--------- .../test_consolidated_trial_balance.py | 4 ++-- .../assets/doctype/asset_repair/test_asset_repair.py | 1 - .../tests/test_item_wise_inventory_account.py | 6 +++--- erpnext/selling/doctype/quotation/test_quotation.py | 2 +- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 6 +----- 7 files changed, 11 insertions(+), 30 deletions(-) diff --git a/erpnext/accounts/doctype/tax_withholding_entry/test_tax_withholding_entry.py b/erpnext/accounts/doctype/tax_withholding_entry/test_tax_withholding_entry.py index 8a09f46e079..3f52eb77ee5 100644 --- a/erpnext/accounts/doctype/tax_withholding_entry/test_tax_withholding_entry.py +++ b/erpnext/accounts/doctype/tax_withholding_entry/test_tax_withholding_entry.py @@ -1,17 +1,10 @@ # Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt -# import frappe -from frappe.tests import IntegrationTestCase - -# On IntegrationTestCase, the doctype test records and all -# link-field test record dependencies are recursively loaded -# Use these module variables to add/remove to/from that list -EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] -IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +from erpnext.tests.utils import ERPNextTestSuite -class IntegrationTestTaxWithholdingEntry(IntegrationTestCase): +class IntegrationTestTaxWithholdingEntry(ERPNextTestSuite): """ Integration tests for TaxWithholdingEntry. Use this class for testing interactions between multiple components. diff --git a/erpnext/accounts/doctype/tax_withholding_group/test_tax_withholding_group.py b/erpnext/accounts/doctype/tax_withholding_group/test_tax_withholding_group.py index 268febe3d7e..eacdf7f36fc 100644 --- a/erpnext/accounts/doctype/tax_withholding_group/test_tax_withholding_group.py +++ b/erpnext/accounts/doctype/tax_withholding_group/test_tax_withholding_group.py @@ -1,17 +1,10 @@ # Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt -# import frappe -from frappe.tests import IntegrationTestCase - -# On IntegrationTestCase, the doctype test records and all -# link-field test record dependencies are recursively loaded -# Use these module variables to add/remove to/from that list -EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] -IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +from erpnext.tests.utils import ERPNextTestSuite -class IntegrationTestTaxWithholdingGroup(IntegrationTestCase): +class IntegrationTestTaxWithholdingGroup(ERPNextTestSuite): """ Integration tests for TaxWithholdingGroup. Use this class for testing interactions between multiple components. diff --git a/erpnext/accounts/report/consolidated_trial_balance/test_consolidated_trial_balance.py b/erpnext/accounts/report/consolidated_trial_balance/test_consolidated_trial_balance.py index d9d74f483b0..3e6ea82e13b 100644 --- a/erpnext/accounts/report/consolidated_trial_balance/test_consolidated_trial_balance.py +++ b/erpnext/accounts/report/consolidated_trial_balance/test_consolidated_trial_balance.py @@ -3,18 +3,18 @@ import frappe from frappe import _ -from frappe.tests import IntegrationTestCase from frappe.utils import flt, today from erpnext.accounts.report.consolidated_trial_balance.consolidated_trial_balance import execute from erpnext.setup.utils import get_exchange_rate +from erpnext.tests.utils import ERPNextTestSuite class ForeignCurrencyTranslationReserveNotFoundError(frappe.ValidationError): pass -class TestConsolidatedTrialBalance(IntegrationTestCase): +class TestConsolidatedTrialBalance(ERPNextTestSuite): @classmethod def setUpClass(cls): from erpnext.accounts.report.trial_balance.test_trial_balance import create_company diff --git a/erpnext/assets/doctype/asset_repair/test_asset_repair.py b/erpnext/assets/doctype/asset_repair/test_asset_repair.py index 9a837ca3853..e52e5b524a6 100644 --- a/erpnext/assets/doctype/asset_repair/test_asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/test_asset_repair.py @@ -5,7 +5,6 @@ import unittest import frappe from frappe import qb from frappe.query_builder.functions import Sum -from frappe.tests import IntegrationTestCase from frappe.utils import add_days, add_months, flt, get_first_day, nowdate, nowtime, today from erpnext.assets.doctype.asset.asset import ( diff --git a/erpnext/controllers/tests/test_item_wise_inventory_account.py b/erpnext/controllers/tests/test_item_wise_inventory_account.py index e8b2c1343e7..92881fcdb78 100644 --- a/erpnext/controllers/tests/test_item_wise_inventory_account.py +++ b/erpnext/controllers/tests/test_item_wise_inventory_account.py @@ -5,8 +5,7 @@ import copy from collections import defaultdict import frappe -from frappe.tests import IntegrationTestCase -from frappe.utils import add_days, cint, today +from frappe.utils import add_days, today from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record @@ -14,9 +13,10 @@ from erpnext.manufacturing.doctype.work_order.work_order import make_stock_entry from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note from erpnext.stock.doctype.item.test_item import make_item from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt +from erpnext.tests.utils import ERPNextTestSuite -class TestItemWiseInventoryAccount(IntegrationTestCase): +class TestItemWiseInventoryAccount(ERPNextTestSuite): def setUp(self): self.company = make_company() self.company_abbr = frappe.db.get_value("Company", self.company, "abbr") diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index e1889d10fd1..238b5144933 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -1021,7 +1021,7 @@ class TestQuotation(ERPNextTestSuite): quotation.reload() self.assertEqual(quotation.status, "Ordered") - @change_settings("Accounts Settings", {"allow_pegged_currencies_exchange_rates": True}) + @ERPNextTestSuite.change_settings("Accounts Settings", {"allow_pegged_currencies_exchange_rates": True}) def test_make_quotation_qar_to_inr(self): quotation = make_quotation( currency="QAR", diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index e43af88d0f7..49ff8b425aa 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -2369,10 +2369,8 @@ class TestStockEntry(ERPNextTestSuite): self.assertEqual(target_sabb.entries[0].batch_no, batch) self.assertEqual([entry.serial_no for entry in target_sabb.entries], serial_nos[:2]) + @ERPNextTestSuite.change_settings("Manufacturing Settings", {"material_consumption": 0}) def test_raw_material_missing_validation(self): - original_value = frappe.db.get_single_value("Manufacturing Settings", "material_consumption") - frappe.db.set_single_value("Manufacturing Settings", "material_consumption", 0) - stock_entry = make_stock_entry( item_code="_Test Item", qty=1, @@ -2389,8 +2387,6 @@ class TestStockEntry(ERPNextTestSuite): stock_entry.save, ) - frappe.db.set_single_value("Manufacturing Settings", "material_consumption", original_value) - @ERPNextTestSuite.change_settings( "Manufacturing Settings", {