本文整理汇总了Python中money.Money.dollar方法的典型用法代码示例。如果您正苦于以下问题:Python Money.dollar方法的具体用法?Python Money.dollar怎么用?Python Money.dollar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类money.Money
的用法示例。
在下文中一共展示了Money.dollar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_less_equal_with_two_different_nationality_money
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def test_less_equal_with_two_different_nationality_money(self):
greatest = Money.dollar(20.1)
median = Money.yen(10)
median.set_exchanger(DummyExchanger())
least = Money.dollar(19.9)
self.check_less_operator_of_rich_comparison(median.__le__, greatest, median, least, True)
示例2: testMixedAddition
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testMixedAddition(self):
fiveBucks = Money.dollar(5)
tenFrancs = Money.franc(10)
bank = Bank()
bank.addRate('CHF', 'USD', 2)
result = bank.reduce(fiveBucks.plus(tenFrancs), 'USD')
self.assertEquals(Money.dollar(10), result)
示例3: testSumTimes
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testSumTimes(self):
fiveBucks = Money.dollar(5)
tenFrancs = Money.franc(10)
bank = Bank()
bank.addRate('CHF', 'USD', 2)
sum = Sum(fiveBucks, tenFrancs).times(2)
result = bank.reduce(sum, 'USD')
self.assertEquals(Money.dollar(20), result)
示例4: test_money_exchange_yen_to_dollar
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def test_money_exchange_yen_to_dollar(self):
money = Money.yen(10)
money.set_exchanger(DummyExchanger())
expected = Money.dollar(20)
result_money = money.exchange("dollar")
self.assertTrue(expected == result_money)
示例5: test_return_the_difference_between_the_different_nationality_money
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def test_return_the_difference_between_the_different_nationality_money(self):
money_yen = Money.yen(10)
money_yen.set_exchanger(DummyExchanger())
money_dollar = Money.dollar(2)
expected = Money.yen(9)
money_diff = money_yen - money_dollar
self.assertTrue(expected == money_diff)
示例6: test_return_the_sum_of_two_different_nationality_money
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def test_return_the_sum_of_two_different_nationality_money(self):
money_yen = Money.yen(10)
money_yen.set_exchanger(DummyExchanger())
money_dollar = Money.dollar(5)
expected = Money.yen(12.5)
money_sum = money_yen + money_dollar
self.assertTrue(expected == money_sum)
示例7: test_return_the_money_that_aligned_the_unit_to_currency_of_each_nationality
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def test_return_the_money_that_aligned_the_unit_to_currency_of_each_nationality(self):
money_yen = Money.yen(10.2)
expected = (10, 0)
self.assertTrue(expected == money_yen.currency())
money_dollar = Money.dollar(10.2)
expected = (10, 20)
self.assertTrue(expected == money_dollar.currency())
示例8: testMultiplication
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testMultiplication(self):
five = Money.dollar(5)
self.assertEquals(Money.dollar(10), five.times(2))
self.assertEquals(Money.dollar(15), five.times(3))
示例9: testReduceMoneyDifferentCurrency
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testReduceMoneyDifferentCurrency(self):
bank = Bank()
bank.addRate('CHF', 'USD', 2)
result = bank.reduce(Money.franc(2), 'USD')
self.assertEquals(Money.dollar(1), result)
示例10: testReduceMoney
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testReduceMoney(self):
bank = Bank()
result = bank.reduce(Money.dollar(1), 'USD')
self.assertEquals(Money.dollar(1), result)
示例11: testReduceSum
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testReduceSum(self):
sum = Sum(Money.dollar(3), Money.dollar(4))
bank = Bank()
result = bank.reduce(sum, 'USD')
self.assertEquals(Money.dollar(7), result)
示例12: testPlusReturnsSum
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testPlusReturnsSum(self):
five = Money.dollar(5)
sum = five.plus(five)
self.assertEquals(five, sum.augend)
self.assertEquals(five, sum.addend)
示例13: testSimpleAddition
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testSimpleAddition(self):
five = Money.dollar(5)
sum = five.plus(five)
bank = Bank()
reduced = bank.reduce(sum, 'USD')
self.assertEquals(Money.dollar(10), reduced)
示例14: testEquality
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def testEquality(self):
self.assertTrue(Money.dollar(5) == Money.dollar(5))
self.assertFalse(Money.dollar(5) == Money.dollar(6))
self.assertFalse(Money.franc(5) == Money.dollar(5))
示例15: test_money_recognize_non_equivalent_money_is_not_equal
# 需要导入模块: from money import Money [as 别名]
# 或者: from money.Money import dollar [as 别名]
def test_money_recognize_non_equivalent_money_is_not_equal(self):
money_yen1 = Money.yen(10)
money_yen2 = Money.yen(20)
money_dollar = Money.dollar(10)
self.assertFalse(money_yen1 == money_yen2)
self.assertFalse(money_yen1 == money_dollar)