4
4
5
5
from num2words import num2words
6
6
7
- from odoo .tests .common import SavepointCase
7
+ from odoo .tests .common import TransactionCase
8
8
9
9
10
- class TestAmountToText (SavepointCase ):
11
- def setUp (self ):
12
- super (TestAmountToText , self ).setUp ()
13
- self .env ["res.lang" ]._activate_lang ("it_IT" )
10
+ class TestAmountToText (TransactionCase ):
11
+ @classmethod
12
+ def setUpClass (cls ):
13
+ super ().setUpClass ()
14
+ cls .env ["res.lang" ]._activate_lang ("it_IT" )
14
15
15
16
def test_01_currency_it_amount_to_text (self ):
16
17
"""check that amount_to_text correctly converts text
@@ -21,7 +22,7 @@ def test_01_currency_it_amount_to_text(self):
21
22
self .assertEqual (
22
23
amount_text_en , "One Thousand And Fifty Euros and Seventy-Five Cents"
23
24
)
24
- amount_text_it = currency .with_context ({ " lang" : " it_IT"} ).amount_to_text (amount )
25
+ amount_text_it = currency .with_context (lang = " it_IT" ).amount_to_text (amount )
25
26
num2words (amount , to = "currency" , lang = "it" )
26
27
self .assertEqual (
27
28
amount_text_it , "millecinquanta euro e settantacinque centesimi"
@@ -32,9 +33,7 @@ def test_02_currency_unit_it_amount_to_text(self):
32
33
unit/subunit to italian language singular form"""
33
34
currency = self .env .ref ("base.EUR" )
34
35
amount = 1.01
35
- amount_text_it_unit = currency .with_context ({"lang" : "it_IT" }).amount_to_text (
36
- amount
37
- )
36
+ amount_text_it_unit = currency .with_context (lang = "it_IT" ).amount_to_text (amount )
38
37
self .assertEqual (amount_text_it_unit , "un euro e un centesimo" )
39
38
40
39
def test_03_currency_usd_amount_to_text (self ):
@@ -52,7 +51,7 @@ def test_04_currency_zero_fractional_value_it_amount_to_text(self):
52
51
currency = self .env .ref ("base.EUR" )
53
52
amount = 3.00
54
53
amount_text_it_zero_fractional = currency .with_context (
55
- { " lang" : " it_IT"}
54
+ lang = " it_IT"
56
55
).amount_to_text (amount )
57
56
self .assertEqual (amount_text_it_zero_fractional , "tre euro e zero centesimi" )
58
57
@@ -61,7 +60,5 @@ def test_05_currency_aed_amount_to_text(self):
61
60
using a currency different from EUR/USD/GBP/CNY"""
62
61
currency = self .env .ref ("base.AED" )
63
62
amount = 1050.75
64
- amount_text_aed = currency .with_context ({"lang" : "it_IT" }).amount_to_text (
65
- amount
66
- )
63
+ amount_text_aed = currency .with_context (lang = "it_IT" ).amount_to_text (amount )
67
64
self .assertEqual (amount_text_aed , "millecinquanta dirham e settantacinque fils" )
0 commit comments