refactor: clean up code to py39+ supported syntax - f-strings instead of format - latest typing support instead of pre 3.9 TitleCase - remove UTF-8 declarations. - many more changes Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
20 lines
611 B
Python
20 lines
611 B
Python
import unittest
|
|
|
|
import frappe
|
|
from frappe import format
|
|
|
|
|
|
class TestFormatter(unittest.TestCase):
|
|
def test_currency_formatting(self):
|
|
df = frappe._dict({"fieldname": "amount", "fieldtype": "Currency", "options": "currency"})
|
|
|
|
doc = frappe._dict({"amount": 5})
|
|
frappe.db.set_default("currency", "INR")
|
|
|
|
# if currency field is not passed then default currency should be used.
|
|
self.assertEqual(format(100000, df, doc, format="#,###.##"), "₹ 100,000.00")
|
|
|
|
doc.currency = "USD"
|
|
self.assertEqual(format(100000, df, doc, format="#,###.##"), "$ 100,000.00")
|
|
|
|
frappe.db.set_default("currency", None)
|