def test_equality(self): """同一性テスト""" self.assertTrue(Dollar(5) == Dollar(5), "$5 == $5") self.assertFalse(Dollar(5) == Dollar(6), "$5 != $6") self.assertTrue(Franc(5) == Franc(5), "f5 == f5") self.assertFalse(Franc(5) == Franc(6), "f5 != f6") self.assertFalse(Franc(5) == Dollar(5), "f5 != $5")
def test_franc_multiplication(self): five = Franc(5) assert Franc(10) == five.times(2) assert Franc(15) == five.times(3)
def test_equality(self): assert Dollar(5) == Dollar(5) assert Dollar(5) != Dollar(6) assert Franc(5) == Franc(5) assert Franc(5) != Franc(6) assert Dollar(5) != Franc(5)
def test_franc_multiplication(self): """フランの計算""" five = Franc(5) self.assertEqual(Franc(10), five.times(2), "f10 == f10") self.assertEqual(Franc(15), five.times(3), "f15 == f15")
def test_different_class_equality(self): assert Money(10, 'CHF') == Franc(10)
def test_differentclass_equality(self): """異なる通貨の同一性テスト""" self.assertTrue(Money(10, "CHF") == Franc(10), "Money = Franc")