From b16dd3f2ddf02ba342f682c4aa9704f9936dc6c2 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 21 Apr 2026 17:35:34 +0530 Subject: [PATCH] refactor(test): remove explicit sql delete calls --- .../test_period_closing_voucher.py | 16 ------------ .../test_pos_closing_entry.py | 1 - .../doctype/pos_invoice/test_pos_invoice.py | 1 - .../pos_invoice/test_pos_invoice_merge.py | 4 +-- .../doctype/pricing_rule/test_pricing_rule.py | 11 -------- .../sales_invoice/test_sales_invoice.py | 4 --- .../share_transfer/test_share_transfer.py | 2 -- .../account_balance/test_account_balance.py | 3 --- .../balance_sheet/test_balance_sheet.py | 3 --- .../test_purchase_register.py | 9 ------- .../trial_balance/test_trial_balance.py | 3 --- .../test_asset_capitalization.py | 1 - .../test_supplier_scorecard.py | 21 --------------- .../test_supplier_scorecard_criteria.py | 26 ------------------- erpnext/crm/doctype/contract/test_contract.py | 1 - erpnext/crm/doctype/lead/test_lead.py | 9 ------- erpnext/manufacturing/doctype/bom/test_bom.py | 3 --- .../activity_cost/test_activity_cost.py | 2 -- .../selling/doctype/customer/test_customer.py | 8 ------ .../report/sales_analytics/test_analytics.py | 2 -- erpnext/setup/doctype/company/test_company.py | 9 ------- erpnext/stock/doctype/item/test_item.py | 6 ----- .../test_stock_ledger_entry.py | 11 +------- 23 files changed, 2 insertions(+), 154 deletions(-) diff --git a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py index 7b6d8e5c317..f90c2725241 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py @@ -17,9 +17,6 @@ class TestPeriodClosingVoucher(ERPNextTestSuite): frappe.db.set_single_value("Accounts Settings", "use_legacy_controller_for_pcv", 1) def test_closing_entry(self): - frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'") - frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'") - company = create_company() cost_center = create_cost_center("Test Cost Center 1") @@ -69,9 +66,6 @@ class TestPeriodClosingVoucher(ERPNextTestSuite): self.assertEqual(pcv_gle, expected_gle) def test_cost_center_wise_posting(self): - frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'") - frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'") - company = create_company() surplus_account = create_account() @@ -135,9 +129,6 @@ class TestPeriodClosingVoucher(ERPNextTestSuite): ) def test_period_closing_with_finance_book_entries(self): - frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'") - frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'") - company = create_company() surplus_account = create_account() cost_center = create_cost_center("Test Cost Center 1") @@ -189,9 +180,6 @@ class TestPeriodClosingVoucher(ERPNextTestSuite): self.assertSequenceEqual(pcv_gle, expected_gle) def test_gl_entries_restrictions(self): - frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'") - frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'") - company = create_company() cost_center = create_cost_center("Test Cost Center 1") @@ -212,10 +200,6 @@ class TestPeriodClosingVoucher(ERPNextTestSuite): self.assertRaises(frappe.ValidationError, jv1.submit) def test_closing_balance_with_dimensions_and_test_reposting_entry(self): - frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'") - frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'") - frappe.db.sql("delete from `tabAccount Closing Balance` where company='Test PCV Company'") - company = create_company() cost_center1 = create_cost_center("Test Cost Center 1") cost_center2 = create_cost_center("Test Cost Center 2") diff --git a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py index 7f546a4c7bb..d066c0910d4 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py +++ b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py @@ -200,7 +200,6 @@ class TestPOSClosingEntry(ERPNextTestSuite): ) from erpnext.stock.doctype.batch.batch import get_batch_qty - frappe.db.sql("delete from `tabPOS Invoice`") item_doc = make_item( "_Test Item With Batch FOR POS Merge Test", properties={ diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py index 7857f8b4cad..f8026afcba6 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py @@ -34,7 +34,6 @@ class POSInvoiceTestMixin(ERPNextTestSuite): frappe.db.set_single_value("Selling Settings", "validate_selling_price", 0) frappe.db.set_single_value("POS Settings", "invoice_type", "POS Invoice") make_stock_entry(target="_Test Warehouse - _TC", item_code="_Test Item", qty=800, basic_rate=100) - frappe.db.sql("delete from `tabTax Rule`") mode_of_payment = frappe.get_doc("Mode of Payment", "Bank Draft") set_default_account_for_mode_of_payment(mode_of_payment, "_Test Company", "_Test Bank - _TC") diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice_merge.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice_merge.py index a944ad71897..36b8635e9f9 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice_merge.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice_merge.py @@ -33,7 +33,6 @@ class TestPOSInvoiceMerging(POSInvoiceTestMixin): consolidate_pos_invoices, ) - frappe.db.sql("delete from `tabPOS Invoice`") test_user, pos_profile = init_user_and_profile() pos_inv = create_pos_invoice(rate=300, additional_discount_percentage=10, do_not_submit=1) pos_inv.append("payments", {"mode_of_payment": "Cash", "amount": 270}) @@ -63,7 +62,6 @@ class TestPOSInvoiceMerging(POSInvoiceTestMixin): consolidate_pos_invoices, ) - frappe.db.sql("delete from `tabPOS Invoice`") test_user, pos_profile = init_user_and_profile() pos_inv = create_pos_invoice(rate=300, do_not_submit=1) pos_inv.append("payments", {"mode_of_payment": "Cash", "amount": 300}) @@ -122,7 +120,7 @@ class TestPOSInvoiceMerging(POSInvoiceTestMixin): item = "Test Selling Price Validation" make_item(item, {"is_stock_item": 1}) make_purchase_receipt(item_code=item, warehouse="_Test Warehouse - _TC", qty=1, rate=300) - frappe.db.sql("delete from `tabPOS Invoice`") + test_user, pos_profile = init_user_and_profile() pos_inv = create_pos_invoice(item=item, rate=300, do_not_submit=1) pos_inv.append("payments", {"mode_of_payment": "Cash", "amount": 300}) diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py index effd87c8a70..6dd91826d71 100644 --- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py @@ -15,7 +15,6 @@ from erpnext.tests.utils import ERPNextTestSuite class TestPricingRule(ERPNextTestSuite): def setUp(self): - delete_existing_pricing_rules() setup_pricing_rule_data() self.enterClassContext(self.change_settings("Selling Settings", validate_selling_price=0)) @@ -1584,16 +1583,6 @@ def setup_pricing_rule_data(): ).insert() -def delete_existing_pricing_rules(): - for doctype in [ - "Pricing Rule", - "Pricing Rule Item Code", - "Pricing Rule Item Group", - "Pricing Rule Brand", - ]: - frappe.db.sql(f"delete from `tab{doctype}`") - - def make_item_price(item, price_list_name, item_price): frappe.get_doc( { diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index dd45e588137..504f354522c 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2025,10 +2025,6 @@ class TestSalesInvoice(ERPNextTestSuite): ) def test_multiple_uom_in_selling(self): - frappe.db.sql( - """delete from `tabItem Price` - where price_list='_Test Price List' and item_code='_Test Item'""" - ) item_price = frappe.new_doc("Item Price") item_price.price_list = "_Test Price List" item_price.item_code = "_Test Item" diff --git a/erpnext/accounts/doctype/share_transfer/test_share_transfer.py b/erpnext/accounts/doctype/share_transfer/test_share_transfer.py index e1d56167476..f11152a1bb7 100644 --- a/erpnext/accounts/doctype/share_transfer/test_share_transfer.py +++ b/erpnext/accounts/doctype/share_transfer/test_share_transfer.py @@ -9,8 +9,6 @@ from erpnext.tests.utils import ERPNextTestSuite class TestShareTransfer(ERPNextTestSuite): def setUp(self): - frappe.db.sql("delete from `tabShare Transfer`") - frappe.db.sql("delete from `tabShare Balance`") share_transfers = [ { "doctype": "Share Transfer", diff --git a/erpnext/accounts/report/account_balance/test_account_balance.py b/erpnext/accounts/report/account_balance/test_account_balance.py index 5edf078b31d..d83a26abea6 100644 --- a/erpnext/accounts/report/account_balance/test_account_balance.py +++ b/erpnext/accounts/report/account_balance/test_account_balance.py @@ -8,9 +8,6 @@ from erpnext.tests.utils import ERPNextTestSuite class TestAccountBalance(ERPNextTestSuite): def test_account_balance(self): - frappe.db.sql("delete from `tabSales Invoice` where company='_Test Company 2'") - frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 2'") - filters = { "company": "_Test Company 2", "report_date": getdate(), diff --git a/erpnext/accounts/report/balance_sheet/test_balance_sheet.py b/erpnext/accounts/report/balance_sheet/test_balance_sheet.py index dce9d8ab0fa..683aeecffbd 100644 --- a/erpnext/accounts/report/balance_sheet/test_balance_sheet.py +++ b/erpnext/accounts/report/balance_sheet/test_balance_sheet.py @@ -13,9 +13,6 @@ COMPANY_SHORT_NAME = "_TC6" class TestBalanceSheet(ERPNextTestSuite): def test_balance_sheet(self): - frappe.db.sql(f"delete from `tabJournal Entry` where company='{COMPANY}'") - frappe.db.sql(f"delete from `tabGL Entry` where company='{COMPANY}'") - create_account("VAT Liabilities", f"Duties and Taxes - {COMPANY_SHORT_NAME}", COMPANY) create_account("Advance VAT Paid", f"Duties and Taxes - {COMPANY_SHORT_NAME}", COMPANY) create_account("My Bank", f"Bank Accounts - {COMPANY_SHORT_NAME}", COMPANY) diff --git a/erpnext/accounts/report/purchase_register/test_purchase_register.py b/erpnext/accounts/report/purchase_register/test_purchase_register.py index e4ce5ffcfe3..9e0e2002f60 100644 --- a/erpnext/accounts/report/purchase_register/test_purchase_register.py +++ b/erpnext/accounts/report/purchase_register/test_purchase_register.py @@ -11,9 +11,6 @@ from erpnext.tests.utils import ERPNextTestSuite class TestPurchaseRegister(ERPNextTestSuite): def test_purchase_register(self): - frappe.db.sql("delete from `tabPurchase Invoice` where company='_Test Company 6'") - frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 6'") - filters = frappe._dict(company="_Test Company 6", from_date=add_months(today(), -1), to_date=today()) pi = make_purchase_invoice() @@ -28,9 +25,6 @@ class TestPurchaseRegister(ERPNextTestSuite): self.assertEqual(first_row.grand_total, 1100) def test_purchase_register_ignores_tax_rows_from_other_doctype(self): - frappe.db.sql("delete from `tabPurchase Invoice` where company='_Test Company 6'") - frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 6'") - filters = frappe._dict(company="_Test Company 6", from_date=add_months(today(), -1), to_date=today()) pi = make_purchase_invoice() @@ -74,9 +68,6 @@ class TestPurchaseRegister(ERPNextTestSuite): self.assertEqual(first_row.grand_total, 1100) def test_purchase_register_ledger_view(self): - frappe.db.sql("delete from `tabPurchase Invoice` where company='_Test Company 6'") - frappe.db.sql("delete from `tabGL Entry` where company='_Test Company 6'") - filters = frappe._dict( company="_Test Company 6", from_date=add_months(today(), -1), diff --git a/erpnext/accounts/report/trial_balance/test_trial_balance.py b/erpnext/accounts/report/trial_balance/test_trial_balance.py index c37f9d5a46a..ec8f48c2413 100644 --- a/erpnext/accounts/report/trial_balance/test_trial_balance.py +++ b/erpnext/accounts/report/trial_balance/test_trial_balance.py @@ -42,9 +42,6 @@ class TestTrialBalance(ERPNextTestSuite): """ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice - frappe.db.sql("delete from `tabSales Invoice` where company='Trial Balance Company'") - frappe.db.sql("delete from `tabGL Entry` where company='Trial Balance Company'") - branch1 = frappe.new_doc("Branch") branch1.branch = "Location 1" branch1.insert(ignore_if_duplicate=True) diff --git a/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py index aa50083a9d5..78266e31b76 100644 --- a/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py +++ b/erpnext/assets/doctype/asset_capitalization/test_asset_capitalization.py @@ -22,7 +22,6 @@ class TestAssetCapitalization(ERPNextTestSuite): def setUp(self): set_depreciation_settings_in_company() create_asset_capitalization_data() - frappe.db.sql("delete from `tabTax Rule`") def test_capitalization_with_perpetual_inventory(self): company = "_Test Company with perpetual inventory" diff --git a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py index a1d1dfc4709..92da4dd318d 100644 --- a/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py +++ b/erpnext/buying/doctype/supplier_scorecard/test_supplier_scorecard.py @@ -13,7 +13,6 @@ class TestSupplierScorecard(ERPNextTestSuite): self.assertEqual(doc.name, valid_scorecard[0].get("supplier")) def test_criteria_weight(self): - delete_test_scorecards() my_doc = make_supplier_scorecard() for d in my_doc.criteria: d.weight = 0 @@ -33,26 +32,6 @@ def make_supplier_scorecard(): return my_doc -def delete_test_scorecards(): - my_doc = make_supplier_scorecard() - if frappe.db.exists("Supplier Scorecard", my_doc.name): - # Delete all the periods, then delete the scorecard - frappe.db.sql( - """delete from `tabSupplier Scorecard Period` where scorecard = %(scorecard)s""", - {"scorecard": my_doc.name}, - ) - frappe.db.sql( - """delete from `tabSupplier Scorecard Scoring Criteria` where parenttype = 'Supplier Scorecard Period'""" - ) - frappe.db.sql( - """delete from `tabSupplier Scorecard Scoring Standing` where parenttype = 'Supplier Scorecard Period'""" - ) - frappe.db.sql( - """delete from `tabSupplier Scorecard Scoring Variable` where parenttype = 'Supplier Scorecard Period'""" - ) - frappe.delete_doc(my_doc.doctype, my_doc.name) - - valid_scorecard = [ { "standings": [ diff --git a/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py b/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py index 951d33ed901..0d2a547c634 100644 --- a/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py +++ b/erpnext/buying/doctype/supplier_scorecard_criteria/test_supplier_scorecard_criteria.py @@ -9,41 +9,15 @@ from erpnext.tests.utils import ERPNextTestSuite class TestSupplierScorecardCriteria(ERPNextTestSuite): def test_variables_exist(self): - delete_test_scorecards() for d in test_good_criteria: frappe.get_doc(d).insert() self.assertRaises(frappe.ValidationError, frappe.get_doc(test_bad_criteria[0]).insert) def test_formula_validate(self): - delete_test_scorecards() self.assertRaises(frappe.ValidationError, frappe.get_doc(test_bad_criteria[1]).insert) -def delete_test_scorecards(): - # Delete all the periods so we can delete all the criteria - frappe.db.sql("""delete from `tabSupplier Scorecard Period`""") - frappe.db.sql( - """delete from `tabSupplier Scorecard Scoring Criteria` where parenttype = 'Supplier Scorecard Period'""" - ) - frappe.db.sql( - """delete from `tabSupplier Scorecard Scoring Standing` where parenttype = 'Supplier Scorecard Period'""" - ) - frappe.db.sql( - """delete from `tabSupplier Scorecard Scoring Variable` where parenttype = 'Supplier Scorecard Period'""" - ) - - for d in test_good_criteria: - if frappe.db.exists("Supplier Scorecard Criteria", d.get("name")): - # Delete all the periods, then delete the scorecard - frappe.delete_doc(d.get("doctype"), d.get("name")) - - for d in test_bad_criteria: - if frappe.db.exists("Supplier Scorecard Criteria", d.get("name")): - # Delete all the periods, then delete the scorecard - frappe.delete_doc(d.get("doctype"), d.get("name")) - - test_good_criteria = [ { "name": "Delivery", diff --git a/erpnext/crm/doctype/contract/test_contract.py b/erpnext/crm/doctype/contract/test_contract.py index 03c3864c700..f6924011d32 100644 --- a/erpnext/crm/doctype/contract/test_contract.py +++ b/erpnext/crm/doctype/contract/test_contract.py @@ -9,7 +9,6 @@ from erpnext.tests.utils import ERPNextTestSuite class TestContract(ERPNextTestSuite): def setUp(self): - frappe.db.sql("delete from `tabContract`") self.contract_doc = get_contract() def test_validate_start_date_before_end_date(self): diff --git a/erpnext/crm/doctype/lead/test_lead.py b/erpnext/crm/doctype/lead/test_lead.py index 6f9692e10f2..7a196e12ca1 100644 --- a/erpnext/crm/doctype/lead/test_lead.py +++ b/erpnext/crm/doctype/lead/test_lead.py @@ -86,9 +86,6 @@ class TestLead(ERPNextTestSuite): self.assertEqual(len(address_1.get("links")), 1) def test_prospect_creation_from_lead(self): - frappe.db.sql("delete from `tabLead` where lead_name='Rahul Tripathi'") - frappe.db.sql("delete from `tabProspect` where name='Prospect Company'") - lead = make_lead( first_name="Rahul", last_name="Tripathi", @@ -108,9 +105,6 @@ class TestLead(ERPNextTestSuite): self.assertEqual(event.event_participants[1].reference_docname, prospect) def test_opportunity_from_lead(self): - frappe.db.sql("delete from `tabLead` where lead_name='Rahul Tripathi'") - frappe.db.sql("delete from `tabOpportunity` where party_name='Rahul Tripathi'") - lead = make_lead( first_name="Rahul", last_name="Tripathi", @@ -138,9 +132,6 @@ class TestLead(ERPNextTestSuite): ) def test_copy_events_from_lead_to_prospect(self): - frappe.db.sql("delete from `tabLead` where lead_name='Rahul Tripathi'") - frappe.db.sql("delete from `tabProspect` where name='Prospect Company'") - lead = make_lead( first_name="Rahul", last_name="Tripathi", diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py index 3296559afc5..78d8795162b 100644 --- a/erpnext/manufacturing/doctype/bom/test_bom.py +++ b/erpnext/manufacturing/doctype/bom/test_bom.py @@ -165,9 +165,6 @@ class TestBOM(ERPNextTestSuite): def test_bom_cost_multi_uom_multi_currency_based_on_price_list(self): frappe.db.set_value("Price List", "_Test Price List", "price_not_uom_dependent", 1) for item_code, rate in (("_Test Item", 3600), ("_Test Item Home Desktop Manufactured", 3000)): - frappe.db.sql( - "delete from `tabItem Price` where price_list='_Test Price List' and item_code=%s", item_code - ) item_price = frappe.new_doc("Item Price") item_price.price_list = "_Test Price List" item_price.item_code = item_code diff --git a/erpnext/projects/doctype/activity_cost/test_activity_cost.py b/erpnext/projects/doctype/activity_cost/test_activity_cost.py index 59c4b806ecc..71b8c5e6896 100644 --- a/erpnext/projects/doctype/activity_cost/test_activity_cost.py +++ b/erpnext/projects/doctype/activity_cost/test_activity_cost.py @@ -14,7 +14,6 @@ class TestActivityCost(ERPNextTestSuite): "Activity Type", filters={"activity_type": "_Test Activity Type 1"} )[0].name - frappe.db.sql("delete from `tabActivity Cost`") activity_cost1 = frappe.new_doc("Activity Cost") activity_cost1.update( { @@ -28,4 +27,3 @@ class TestActivityCost(ERPNextTestSuite): activity_cost1.insert() activity_cost2 = frappe.copy_doc(activity_cost1) self.assertRaises(DuplicationError, activity_cost2.insert) - frappe.db.sql("delete from `tabActivity Cost`") diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 5eef7f95651..e3efd4a5b21 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -137,12 +137,6 @@ class TestCustomer(ERPNextTestSuite): # delete communication linked to these 2 customers new_name = "_Test Customer 1 Renamed" - for name in ("_Test Customer 1", new_name): - frappe.db.sql( - """delete from `tabComment` - where reference_doctype=%s and reference_name=%s""", - ("Customer", name), - ) # add comments comment = frappe.get_doc("Customer", "_Test Customer 1").add_comment( @@ -209,8 +203,6 @@ class TestCustomer(ERPNextTestSuite): so.save() def test_duplicate_customer(self): - frappe.db.sql("delete from `tabCustomer` where customer_name='_Test Customer 1'") - if not frappe.db.get_value("Customer", "_Test Customer 1"): test_customer_1 = frappe.get_doc(get_customer_dict("_Test Customer 1")).insert( ignore_permissions=True diff --git a/erpnext/selling/report/sales_analytics/test_analytics.py b/erpnext/selling/report/sales_analytics/test_analytics.py index cada5c07c81..3e687954133 100644 --- a/erpnext/selling/report/sales_analytics/test_analytics.py +++ b/erpnext/selling/report/sales_analytics/test_analytics.py @@ -11,8 +11,6 @@ from erpnext.tests.utils import ERPNextTestSuite class TestAnalytics(ERPNextTestSuite): def test_sales_analytics(self): - frappe.db.sql("delete from `tabSales Order` where company='_Test Company 2'") - create_sales_orders() self.compare_result_for_customer() diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py index 36606e90755..db4e8c07482 100644 --- a/erpnext/setup/doctype/company/test_company.py +++ b/erpnext/setup/doctype/company/test_company.py @@ -44,7 +44,6 @@ class TestCompany(ERPNextTestSuite): for prop, val in acc_property.items(): self.assertEqual(acc.get(prop), val) - self.delete_mode_of_payment("COA from Existing Company") frappe.delete_doc("Company", "COA from Existing Company") def test_coa_based_on_country_template(self): @@ -95,16 +94,8 @@ class TestCompany(ERPNextTestSuite): self.assertTrue(has_matching_accounts, msg=error_message) finally: - self.delete_mode_of_payment(template) frappe.delete_doc("Company", template) - def delete_mode_of_payment(self, company): - frappe.db.sql( - """ delete from `tabMode of Payment Account` - where company =%s """, - (company), - ) - def test_basic_tree(self, records=None): self.load_test_records("Company") min_lft = 1 diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 293d100a188..5404c58fb07 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -459,11 +459,6 @@ class TestItem(ERPNextTestSuite): frappe.delete_doc_if_exists("Item", "_Test Numeric Template Item") frappe.delete_doc_if_exists("Item Attribute", "Test Item Length") - frappe.db.sql( - """delete from `tabItem Variant Attribute` - where attribute='Test Item Length' """ - ) - frappe.flags.attribute_values = None # make item attribute @@ -607,7 +602,6 @@ class TestItem(ERPNextTestSuite): def test_add_item_barcode(self): # Clean up - frappe.db.sql("""delete from `tabItem Barcode`""") item_code = "Test Item Barcode" if frappe.db.exists("Item", item_code): frappe.delete_doc("Item", item_code) diff --git a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py index 787ce0a4d34..a92e6401be4 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py @@ -31,18 +31,9 @@ from erpnext.tests.utils import ERPNextTestSuite class TestStockLedgerEntry(ERPNextTestSuite, StockTestMixin): def setUp(self): - items = create_items() + create_items() reset("Stock Entry") - # delete SLE and BINs for all items - frappe.db.sql( - "delete from `tabStock Ledger Entry` where item_code in (%s)" % (", ".join(["%s"] * len(items))), - items, - ) - frappe.db.sql( - "delete from `tabBin` where item_code in (%s)" % (", ".join(["%s"] * len(items))), items - ) - def test_item_cost_reposting(self): company = "_Test Company"