From 941423067140779b8e1eb94411dbb9bea9c70927 Mon Sep 17 00:00:00 2001 From: Afsal Syed Date: Fri, 17 Jul 2026 00:21:48 +0530 Subject: [PATCH] chore: fix test case user context --- erpnext/buying/doctype/supplier/test_supplier.py | 4 ++-- erpnext/selling/doctype/customer/test_customer.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index 719770a6853..e0a2a379ed8 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -204,8 +204,8 @@ class TestSupplierPortal(FrappeTestCase): supplier.append("portal_users", {"user": user}) supplier.save() - frappe.set_user(user) - _, suppliers = get_customers_suppliers("Purchase Order", user) + with self.set_user(user): + _, suppliers = get_customers_suppliers("Purchase Order", user) self.assertIn(supplier.name, suppliers) diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index bfd66d51d24..e6ed7acb508 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -29,7 +29,8 @@ class TestCustomer(FrappeTestCase): make_test_records("Item") def tearDown(self): - set_credit_limit("_Test Customer", "_Test Company", 0) + if frappe.db.exists("Customer", "_Test Customer"): + set_credit_limit("_Test Customer", "_Test Company", 0) def test_get_customer_group_details(self): doc = frappe.new_doc("Customer Group")