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