Esempio n. 1
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
     self.assertNotEqual(entry.amount, test_value)
     entry.amount = test_value
     self.assertEqual(entry.amount, test_value)
Esempio n. 2
0
 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)
Esempio n. 3
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
Esempio n. 4
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 self.assertRaises(TypeError) as cm:
            entry.amount = 'some string'

        self.assertEqual(str(cm.exception),
                         'BudgetEntry.amount should be a number, not str')
Esempio n. 5
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
     self.assertNotEqual(entry.amount, test_value)
     entry.amount = test_value
     self.assertEqual(entry.amount, test_value)
Esempio n. 6
0
 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)
Esempio n. 7
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'
Esempio n. 8
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 self.assertRaises(TypeError) as cm:
            entry.amount = 'some string'

        self.assertEqual(
            str(cm.exception),
            'BudgetEntry.amount should be a number, not str'
        )