From c488de8f1219ea0a0914fa8ce0207923b4438c92 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 3 Aug 2026 16:43:07 +0530 Subject: [PATCH] test(stock): isolate the disabled attribute fixtures The test disabled the shared `Test Size` Item Attribute. On version-15 `FrappeTestCase` rolls back once per class instead of once per test, so the flag stayed visible for the rest of `TestItem` and broke the seven tests that build a variant from that attribute. Build a dedicated attribute and template instead. Nothing the test writes is reachable from another test, on either branch, so no cleanup is needed. --- erpnext/stock/doctype/item/test_item.py | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 05846afbc58..deda65c911c 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -361,12 +361,33 @@ class TestItem(FrappeTestCase): frappe.db.rollback() def test_disabled_attribute_blocks_only_attribute_changes(self): - frappe.delete_doc_if_exists("Item", "_Test Variant Item-L", force=1) + frappe.delete_doc_if_exists("Item", "_Test Disabled Attribute Template-L", force=1) + frappe.delete_doc_if_exists("Item", "_Test Disabled Attribute Template", force=1) + frappe.delete_doc_if_exists("Item Attribute", "_Test Disabled Size", force=1) - variant = create_variant("_Test Variant Item", {"Test Size": "Large"}) + attribute = frappe.get_doc( + { + "doctype": "Item Attribute", + "attribute_name": "_Test Disabled Size", + "item_attribute_values": [ + {"attribute_value": "Large", "abbr": "L"}, + {"attribute_value": "Small", "abbr": "S"}, + ], + } + ).insert() + + template = make_item( + "_Test Disabled Attribute Template", + { + "has_variants": 1, + "variant_based_on": "Item Attribute", + "attributes": [{"attribute": attribute.name}], + }, + ) + + variant = create_variant(template.name, {attribute.name: "Large"}) variant.save() - attribute = frappe.get_doc("Item Attribute", "Test Size") attribute.disabled = 1 attribute.save()