From 42c6768b4c6a9e0ca0a695264570fd30c49697d0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 Jul 2026 00:16:06 +0530 Subject: [PATCH] test: guard period_keys index access for clearer failure --- .../test_custom_financial_statement.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/custom_financial_statement/test_custom_financial_statement.py b/erpnext/accounts/report/custom_financial_statement/test_custom_financial_statement.py index 8fa3e530fcc..5d981b77c38 100644 --- a/erpnext/accounts/report/custom_financial_statement/test_custom_financial_statement.py +++ b/erpnext/accounts/report/custom_financial_statement/test_custom_financial_statement.py @@ -81,7 +81,9 @@ class TestCustomFinancialStatement(ERPNextTestSuite): self.assertIn("Test Expense", rows) self.assertIn("Expense Doubled", rows) - period_key = rows["Test Expense"].get("_segment_info", {}).get("period_keys", [])[0] + period_keys = rows["Test Expense"].get("_segment_info", {}).get("period_keys", []) + self.assertTrue(period_keys, "expected at least one period key in _segment_info") + period_key = period_keys[0] # the account-data row picks up the posted expense; the calculated row doubles it self.assertEqual(flt(rows["Test Expense"][period_key]), 2000.0)