Example #1
0
 def test_div(self):
     a1 = Amount(15, self.symbol)
     self.dotest(a1 / 3, 5, self.symbol)
     self.dotest(a1 // 2, 7, self.symbol)
     with self.assertRaises(Exception):
         a1 / Amount(1, asset=self.asset2)
     # inline
     a2 = a1.copy()
     a2 /= 3
     self.dotest(a2, 5, self.symbol)
     a2 = a1.copy()
     a2 //= 2
     self.dotest(a2, 7, self.symbol)
     with self.assertRaises(Exception):
         a1 *= Amount(2, asset=self.asset2)
Example #2
0
 def test_pow(self):
     a1 = Amount(15, self.symbol)
     self.dotest(a1 ** 3, 15 ** 3, self.symbol)
     self.dotest(a1 ** 2, 15 ** 2, self.symbol)
     with self.assertRaises(Exception):
         a1 ** Amount(1, asset=self.asset2)
     # inline
     a2 = a1.copy()
     a2 **= 3
     self.dotest(a2, 15 ** 3, self.symbol)
     with self.assertRaises(Exception):
         a1 **= Amount(2, asset=self.asset2)
Example #3
0
 def test_mod(self):
     a1 = Amount(15, self.symbol)
     self.dotest(a1 % 3, 0, self.symbol)
     self.dotest(a1 % 2, 1, self.symbol)
     with self.assertRaises(Exception):
         a1 % Amount(1, asset=self.asset2)
     # inline
     a2 = a1.copy()
     a2 %= 3
     self.dotest(a2, 0, self.symbol)
     with self.assertRaises(Exception):
         a1 %= Amount(2, asset=self.asset2)
Example #4
0
 def test_copy(self):
     amount = Amount("1", self.symbol)
     self.dotest(amount.copy(), 1, self.symbol)