refactor: replace IntegrationTestCase with ERPNextTestCase repo-wide

- import ERPNextTestSuite
 - use it on test class
This commit is contained in:
ruthra kumar
2026-01-20 10:12:06 +05:30
parent 4027b82714
commit 33f4791698
320 changed files with 854 additions and 833 deletions

View File

@@ -5,7 +5,6 @@
import frappe
from frappe import qb
from frappe.query_builder.functions import Sum
from frappe.tests import IntegrationTestCase
from frappe.utils import add_days, getdate, nowdate
from frappe.utils.data import getdate as convert_to_date
@@ -20,6 +19,7 @@ from erpnext.buying.doctype.purchase_order.test_purchase_order import (
)
from erpnext.projects.doctype.project.test_project import make_project
from erpnext.stock.doctype.item.test_item import create_item
from erpnext.tests.utils import ERPNextTestSuite
def make_customer(customer_name, currency=None):
@@ -51,7 +51,7 @@ def make_supplier(supplier_name, currency=None):
return supplier_name
class TestAccountsController(IntegrationTestCase):
class TestAccountsController(ERPNextTestSuite):
"""
Test Exchange Gain/Loss booking on various scenarios.
Test Cases are numbered for better organization
@@ -810,9 +810,7 @@ class TestAccountsController(IntegrationTestCase):
self.assertEqual(exc_je_for_si, [])
self.assertEqual(exc_je_for_pe, [])
@IntegrationTestCase.change_settings(
"Stock Settings", {"allow_internal_transfer_at_arms_length_price": 1}
)
@ERPNextTestSuite.change_settings("Stock Settings", {"allow_internal_transfer_at_arms_length_price": 1})
def test_16_internal_transfer_at_arms_length_price(self):
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_inter_company_purchase_invoice
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
@@ -873,7 +871,7 @@ class TestAccountsController(IntegrationTestCase):
self.assertEqual(pi.items[0].rate, arms_length_price)
self.assertEqual(pi.items[0].valuation_rate, 100)
@IntegrationTestCase.change_settings(
@ERPNextTestSuite.change_settings(
"Accounts Settings", {"exchange_gain_loss_posting_date": "Reconciliation Date"}
)
def test_17_gain_loss_posting_date_for_normal_payment(self):
@@ -936,10 +934,7 @@ class TestAccountsController(IntegrationTestCase):
self.assertEqual(exc_je_for_si, [])
self.assertEqual(exc_je_for_pe, [])
@IntegrationTestCase.change_settings(
"Accounts Settings",
{"add_taxes_from_item_tax_template": 0, "add_taxes_from_taxes_and_charges_template": 1},
)
@ERPNextTestSuite.change_settings("Accounts Settings", {"add_taxes_from_item_tax_template": 1})
def test_18_fetch_taxes_based_on_taxes_and_charges_template(self):
# Create a Sales Taxes and Charges Template
if not frappe.db.exists("Sales Taxes and Charges Template", "_Test Tax - _TC"):
@@ -968,7 +963,7 @@ class TestAccountsController(IntegrationTestCase):
self.assertEqual(sinv.total_taxes_and_charges, 4.5)
@IntegrationTestCase.change_settings(
@ERPNextTestSuite.change_settings(
"Accounts Settings",
{"add_taxes_from_item_tax_template": 1, "add_taxes_from_taxes_and_charges_template": 0},
)

View File

@@ -1,11 +1,10 @@
from frappe.tests import IntegrationTestCase
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
from erpnext.tests.utils import ERPNextTestSuite
class TestTaxesAndTotals(AccountsTestMixin, IntegrationTestCase):
class TestTaxesAndTotals(AccountsTestMixin, ERPNextTestSuite):
def test_distributed_discount_amount(self):
so = make_sales_order(do_not_save=1)
so.apply_discount_on = "Net Total"

View File

@@ -1,16 +1,16 @@
import json
import frappe
from frappe.tests import IntegrationTestCase
from erpnext.controllers.item_variant import copy_attributes_to_variant, make_variant_item_code
from erpnext.stock.doctype.item.test_item import set_item_variant_settings
from erpnext.stock.doctype.quality_inspection.test_quality_inspection import (
create_quality_inspection_parameter,
)
from erpnext.tests.utils import ERPNextTestSuite
class TestItemVariant(IntegrationTestCase):
class TestItemVariant(ERPNextTestSuite):
def test_tables_in_template_copied_to_variant(self):
fields = [{"field_name": "quality_inspection_template"}]
set_item_variant_settings(fields)

View File

@@ -3,11 +3,12 @@ import json
import frappe
import frappe.utils
from frappe.model import mapper
from frappe.tests import IntegrationTestCase
from frappe.utils import add_months, nowdate
from erpnext.tests.utils import ERPNextTestSuite
class TestMapper(IntegrationTestCase):
class TestMapper(ERPNextTestSuite):
def test_map_docs(self):
"""Test mapping of multiple source docs on a single target doc"""

View File

@@ -1,14 +1,15 @@
from uuid import uuid4 as _uuid4
import frappe
from frappe.tests import IntegrationTestCase
from erpnext.tests.utils import ERPNextTestSuite
def uuid4():
return str(_uuid4())
class TestTaxes(IntegrationTestCase):
class TestTaxes(ERPNextTestSuite):
def setUp(self):
self.company = frappe.get_doc(
{

View File

@@ -115,7 +115,7 @@ class TestQueries(ERPNextTestSuite):
}
)
with self.set_user(user.name):
with ERPNextTestSuite.set_user(user.name):
params = {
"doctype": "Employee",
"txt": "",

View File

@@ -1,12 +1,12 @@
import frappe
from frappe import qb
from frappe.tests import IntegrationTestCase
from frappe.utils import today
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
from erpnext.tests.utils import ERPNextTestSuite
class TestReactivity(AccountsTestMixin, IntegrationTestCase):
class TestReactivity(AccountsTestMixin, ERPNextTestSuite):
def setUp(self):
self.create_company()
self.create_customer()

View File

@@ -5,7 +5,6 @@ import copy
from collections import defaultdict
import frappe
from frappe.tests import IntegrationTestCase
from frappe.utils import cint, flt
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
@@ -23,9 +22,10 @@ from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order import (
make_subcontracting_receipt,
)
from erpnext.tests.utils import ERPNextTestSuite
class TestSubcontractingController(IntegrationTestCase):
class TestSubcontractingController(ERPNextTestSuite):
def setUp(self):
make_subcontracted_items()
make_raw_materials()

View File

@@ -1,13 +1,13 @@
from unittest.mock import patch
import frappe
from frappe.tests import IntegrationTestCase
from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
from erpnext.tests.utils import ERPNextTestSuite
class TestTaxesAndTotals(IntegrationTestCase):
class TestTaxesAndTotals(ERPNextTestSuite):
def test_regional_round_off_accounts(self):
"""
Regional overrides cannot extend the list in-place — the return

View File

@@ -1,8 +1,9 @@
import frappe
from frappe.tests import IntegrationTestCase
from erpnext.tests.utils import ERPNextTestSuite
class TestUtils(IntegrationTestCase):
class TestUtils(ERPNextTestSuite):
def test_reset_default_field_value(self):
doc = frappe.get_doc(
{