On 2015-12-24 11:36, malitic...@gmail.com wrote: > it is a homework, but we are to figure out the solution first , all > we need is some guidance please and not to be spoon fed like many > thought
Ah, with the intended interface as given by the tests, and the code you've already put together, you'll find comp.lang.python is a much friendlier place. > def test_invalid_operation(self): > self.assertEqual(self.my_account.withdraw(1000), "invalid > transaction", msg='Invalid transaction') The test above is failing because your withdraw() method doesn't return "invalid transaction" but rather prints it: > def withdraw(self, amount): > if self.balance>= amount: > self.balance -= amount > else: > print('invalid transaction') as gleaned from this error message: > [{"message": "Failure in line 23, in test_invalid_operation\n > self.assertEqual(self.my_account.withdraw(1000), \"invalid > transaction\", msg='Invalid transaction')\nAssertionError: Invalid > transaction\n"}]}], "specs": {"count": 5, "pendingCount": 0, > "time": "0.000080"}} The test says "I expected that calling the function would return "invalid transaction" but it didn't" (a better test-runner would also have let you know that it had returned None) Though frankly, I'd consider that a bad test, since it's an exceptional condition, so it should be checking that a custom InvalidTransactionException was raised. But sometimes you have to work with what you've got. -tkc -- https://mail.python.org/mailman/listinfo/python-list