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