def test_duration_attribute_is_not_an_integer(self): """testing if a TypeError will be raised when the duration attribute is not set to a integer value """ d = DurationMixin(duration=10) with self.assertRaises(TypeError) as cm: d.duration = "not an integer" self.assertEqual(cm.exception.message, "DurationMixin.duration should be an non-negative float, not str")
def test_duration_attribute_is_negative(self): """testing if a ValueError will be raised when the duration attribute is set to a negative value """ d = DurationMixin(duration=10) with self.assertRaises(ValueError) as cm: d.duration = -10 self.assertEqual(cm.exception.message, "DurationMixin.duration should be an non-negative float")
def test_duration_attribute_is_not_an_integer(self): """testing if a TypeError will be raised when the duration attribute is not set to a integer value """ d = DurationMixin(duration=10) with self.assertRaises(TypeError) as cm: d.duration = 'not an integer' self.assertEqual( cm.exception.message, 'DurationMixin.duration should be an non-negative float, not str')
def test_duration_attribute_is_negative(self): """testing if a ValueError will be raised when the duration attribute is set to a negative value """ d = DurationMixin(duration=10) with self.assertRaises(ValueError) as cm: d.duration = -10 self.assertEqual( cm.exception.message, 'DurationMixin.duration should be an non-negative float')
def test_duration_attribute_is_working_properly(self): """testing if the duration attribute is working properly """ d = DurationMixin(duration=10) d.duration = 15 self.assertEqual(15, d.duration)