fix: replace frappe.get_doc with frappe.new_doc in new tests, fix RUF003 comment

Agent-Logs-Url: https://github.com/frappe/erpnext/sessions/b87be10b-3c3e-4f96-a102-a0206d727bd1

Co-authored-by: mihir-kandoi <8833206+mihir-kandoi@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-05-02 17:32:22 +00:00
committed by GitHub
parent 252eef710c
commit 0e807f3ef1
2 changed files with 26 additions and 32 deletions

View File

@@ -113,7 +113,7 @@ class TestTaxesAndTotals(ERPNextTestSuite):
calculate_taxes_and_totals(qo)
# Only the first (non-alternative) item should contribute: 5 × 100 = 500
# Only the first (non-alternative) item should contribute: 5 x 100 = 500
self.assertEqual(qo.net_total, 500.0)
self.assertEqual(qo.grand_total, 500.0)

View File

@@ -96,7 +96,7 @@ class TestUtils(ERPNextTestSuite):
def test_validate_posting_time_invalid(self):
"""An invalid posting_time string must raise a ValidationError."""
doc = frappe.get_doc({"doctype": "Stock Entry"})
doc = frappe.new_doc("Stock Entry")
doc.set_posting_time = 1
doc.posting_time = "not-a-time"
@@ -104,9 +104,9 @@ class TestUtils(ERPNextTestSuite):
def test_validate_posting_time_auto_set(self):
"""When set_posting_time is falsy, posting_date and posting_time are replaced with now."""
from frappe.utils import getdate, nowdate
from frappe.utils import nowdate
doc = frappe.get_doc({"doctype": "Stock Entry"})
doc = frappe.new_doc("Stock Entry")
doc.set_posting_time = 0
doc.posting_date = "2000-01-01"
doc.posting_time = "00:00:00"
@@ -123,42 +123,36 @@ class TestUtils(ERPNextTestSuite):
from erpnext.utilities.transaction_base import UOMMustBeIntegerError
# Nos is seeded as a whole-number UOM in test fixtures
se = frappe.get_doc(
se = frappe.new_doc("Stock Entry")
se.purpose = "Material Receipt"
se.company = "_Test Company"
se.append(
"items",
{
"doctype": "Stock Entry",
"purpose": "Material Receipt",
"company": "_Test Company",
"items": [
{
"item_code": "_Test Item",
"uom": "Nos",
"qty": 1.5,
"t_warehouse": "_Test Warehouse - _TC",
"basic_rate": 100,
}
],
}
"item_code": "_Test Item",
"uom": "Nos",
"qty": 1.5,
"t_warehouse": "_Test Warehouse - _TC",
"basic_rate": 100,
},
)
self.assertRaises(UOMMustBeIntegerError, validate_uom_is_integer, se, "uom", "qty")
def test_validate_uom_is_integer_passes_for_whole_number(self):
"""Integer qty in a whole-number UOM must NOT raise any error."""
se = frappe.get_doc(
se = frappe.new_doc("Stock Entry")
se.purpose = "Material Receipt"
se.company = "_Test Company"
se.append(
"items",
{
"doctype": "Stock Entry",
"purpose": "Material Receipt",
"company": "_Test Company",
"items": [
{
"item_code": "_Test Item",
"uom": "Nos",
"qty": 3,
"t_warehouse": "_Test Warehouse - _TC",
"basic_rate": 100,
}
],
}
"item_code": "_Test Item",
"uom": "Nos",
"qty": 3,
"t_warehouse": "_Test Warehouse - _TC",
"basic_rate": 100,
},
)
# Should complete without raising