Пример #1
0
 def test_get_preferred_dividend_yield_floats(self):
     stock = Stock('ABC', 12, 100, is_preferred=True, fixed_dividend=2)
     self.assertAlmostEqual(2.0, stock.get_dividend_yield(100))
     self.assertAlmostEqual(6.66666,
                            stock.get_dividend_yield(30),
                            delta=0.00001)
Пример #2
0
 def test_get_preferred_dividend_yield_ints(self):
     stock = Stock('ABC', 12, 100, is_preferred=True, fixed_dividend=2)
     self.assertEquals(1, stock.get_dividend_yield(200))
     self.assertEquals(4, stock.get_dividend_yield(50))
     self.assertEquals(10, stock.get_dividend_yield(20))
Пример #3
0
 def test_get_common_dividend_yield_ints(self):
     stock = Stock('ABC', 12, 100)
     self.assertEquals(1, stock.get_dividend_yield(12))
     self.assertEquals(2, stock.get_dividend_yield(6))
     self.assertEquals(3, stock.get_dividend_yield(4))
Пример #4
0
 def test_get_common_dividend_yield_floats(self):
     stock = Stock('ABC', 10, 100)
     self.assertAlmostEqual(0.1, stock.get_dividend_yield(100))
     self.assertAlmostEqual(0.33333,
                            stock.get_dividend_yield(30),
                            delta=0.00001)
Пример #5
0
 def test_get_dividend_yield_with_zero(self):
     stock = Stock('ABC', 12, 100)
     with self.assertRaises(Exception) as context:
         stock.get_dividend_yield(0)
     self.assertEquals(context.exception.message, 'Price cant be zero')