Scientific computing with python :- budget app

I haven’t started the chart part yet, but I have all the tests for the main part of the challenge passing, except, weirdly…

  1. the withdraw true/false tests
  2. the 2 ‘blank description’ tests

‘1’ has driven me mad. The much harder test that combines deposit and withdraw works fine! Even if I reduce the withdraw method to one that just returns True or just False, I still can’t pass either true/false test!!

‘2’ Maybe I am misunderstanding the spec for these. My deposit method is trivial and doesn’t care if description is zero chars or 100

Given the following calls:
food = Category(“Food”)
food.deposit(1000, “deposit_10deposit_20deposit_30”)
food.deposit(900, “”)
food.withdraw(45.67, “milk, cereal, eggs, bacon, bread”)

Here is a dump of the ledger list object afterwards:
[{‘amount’: 1000.0, ‘description’: ‘deposit_10deposit_20deposit_30’}, {‘amount’: 900.0, ‘description’: ‘’}, {‘amount’: -45.67, ‘description’: ‘milk, cereal, eggs, bacon, bread’}]

And here is the output of str()
image
Looks good to me, both the maths and formatting, but I’d guess the latter is the issue?

My replit is primed to run the above. Please see here

Thanks

ok, worked it out. The definitions for both deposit and withdraw should have desc with a default arg e.g.
def withdraw(self, amnt, desc=“”)

I clearly got the impression a call to either method with empty desc was something like:

deposit(47.00, “”)

rather than

deposit(47.00)

I missed this bit in the deposit instructions, and as I was 100% fixated on withdraw, I never went back and saw it :frowning:

I only twigged by finding the old boiler plate code on replit which had the actual test file. It’s a shame there is no link from the current ‘beta’ program to this, as I don’t enjoy playing “guess what the test is actually doing”.