Skip to content

Commit

Permalink
test: silent test failure in stock assertions (#31377)
Browse files Browse the repository at this point in the history
If actual values are not present then test is silently passing, # of
actual values should be at least equal to expected values.
  • Loading branch information
ankush committed Jun 15, 2022
1 parent 5c6f22f commit 86919d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,9 @@ def repost_gle_for_stock_vouchers(
voucher_obj.make_gl_entries(gl_entries=expected_gle, from_repost=True)
else:
_delete_gl_entries(voucher_type, voucher_no)
frappe.db.commit()

if not frappe.flags.in_test:
frappe.db.commit()

if repost_doc:
repost_doc.db_set(
Expand Down
3 changes: 2 additions & 1 deletion erpnext/stock/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def assertSLEs(self, doc, expected_sles, sle_filters=None):
filters=filters,
order_by="timestamp(posting_date, posting_time), creation",
)
self.assertGreaterEqual(len(sles), len(expected_sles))

for exp_sle, act_sle in zip(expected_sles, sles):
for k, v in exp_sle.items():
Expand All @@ -49,7 +50,7 @@ def assertGLEs(self, doc, expected_gles, gle_filters=None, order_by=None):
filters=filters,
order_by=order_by or "posting_date, creation",
)

self.assertGreaterEqual(len(actual_gles), len(expected_gles))
for exp_gle, act_gle in zip(expected_gles, actual_gles):
for k, exp_value in exp_gle.items():
act_value = act_gle[k]
Expand Down

0 comments on commit 86919d2

Please sign in to comment.