Possible bug in python budget app test module

Apologies if this is incorrect, but I’m testing my budget.py and I can see the test_module.py line 56 is evaluating the last entry in the ledger, when I’m expecting to add it to the front of the ledger.

actual = self.food.ledger[2]

Whereas when the target ledger is looked at on line 62 the test is inspecting the first ledger item (as I’d expect):

actual = self.entertainment.ledger[0]

Do you think this is an error in the test?

It helps if you share a link to your code.

Can you explain why you expect the test suite to do what you are describing?

Apologies, I’ve sussed it; I can see that the test suite expects appended ledger values, but I’ve inserted them.

I don’t know if that’s normal for a test as it feels quite prescriptive. Perhaps I’ve not followed a convention here, but perhaps it would be less prone to misunderstanding to have a method to request the most recent item from the ledger, rather than specify how to code it.

I just need to swap my insert for append.

Sorry, I’m working offline and didn’t want to post code as it’s from one of the projects for certification.

You can always post is progress code for certification projects.

I generally avoid insertion into an array since it involves moving everything currently in the array. Rarely am I in the case where I very specifically must have most recent data at the very beginning.

1 Like

That makes a lot of sense; I’ll do that in future.

Thank you for chatting through.

1 Like

A post was split to a new topic: Python Budget App