def test_amount_attribute_is_working_properly(self): """testing if the amount attribute is working properly """ entry = BudgetEntry(budget=self.test_budget, good=self.test_good, amount=10) test_value = 5.0 self.assertNotEqual(entry.amount, test_value) entry.amount = test_value self.assertEqual(entry.amount, test_value)
def test_amount_attribute_is_set_to_None(self): """testing if the amount attribute will be set to 0 if it is set to None """ entry = BudgetEntry(budget=self.test_budget, good=self.test_good, amount=10.0) self.assertEqual(entry.amount, 10.0) entry.amount = None self.assertEqual(entry.amount, 0.0)
def test_amount_attribute_is_working_properly(self): """testing if the amount attribute is working properly """ entry = BudgetEntry(budget=self.test_budget, good=self.test_good, amount=10) test_value = 5.0 assert entry.amount != test_value entry.amount = test_value assert entry.amount == test_value
def test_amount_attribute_is_not_a_number(self): """testing if a TypeError will be raised if amount attribute is set to something other than a number """ entry = BudgetEntry(budget=self.test_budget, good=self.test_good, amount=10) with self.assertRaises(TypeError) as cm: entry.amount = 'some string' self.assertEqual(str(cm.exception), 'BudgetEntry.amount should be a number, not str')
def test_amount_attribute_is_working_properly(self): """testing if the amount attribute is working properly """ entry = BudgetEntry( budget=self.test_budget, good=self.test_good, amount=10 ) test_value = 5.0 self.assertNotEqual(entry.amount, test_value) entry.amount = test_value self.assertEqual(entry.amount, test_value)
def test_amount_attribute_is_set_to_None(self): """testing if the amount attribute will be set to 0 if it is set to None """ entry = BudgetEntry( budget=self.test_budget, good=self.test_good, amount=10.0 ) self.assertEqual(entry.amount, 10.0) entry.amount = None self.assertEqual(entry.amount, 0.0)
def test_amount_attribute_is_not_a_number(self): """testing if a TypeError will be raised if amount attribute is set to something other than a number """ entry = BudgetEntry(budget=self.test_budget, good=self.test_good, amount=10) with pytest.raises(TypeError) as cm: entry.amount = 'some string' assert str(cm.value) == \ 'BudgetEntry.amount should be a number, not str'
def test_amount_attribute_is_not_a_number(self): """testing if a TypeError will be raised if amount attribute is set to something other than a number """ entry = BudgetEntry( budget=self.test_budget, good=self.test_good, amount=10 ) with self.assertRaises(TypeError) as cm: entry.amount = 'some string' self.assertEqual( str(cm.exception), 'BudgetEntry.amount should be a number, not str' )