after working some time in the Budget App, and seeing that the results were unexpected (it continously give me the same error), i enter in the test_module.py in replit.com in order to see the file.
After some investigation and tests i do for myself, i finally change some index of the expected results in that file, achieving that way pass the test.
some of my “investigations” and reasons to change it, what i see, is that after making an inscription in the ledger, when the test takes the supposed “actual” inscription, it doesn’t take the last inscription on the list…
… just changed the index for the [-1], and it works, like in the example below…
…had i do it well? there were any other complaints on that file?
and i think it’s all… thanks for the bootCamp!
" def test_withdraw_no_description(self):
self.food.deposit(900, “deposit”)
good_withdraw = self.food.withdraw(45.67)
actual = self.food.ledger[-1] #changed by user <----------
expected = {“amount”: -45.67, “description”: “”}
self.assertEqual(actual, expected, ‘Expected withdraw method with no description to create a blank description.’)
self.assertEqual(good_withdraw, True, ‘Expected withdraw method to return True.’)"
At that point in the food’s ledger should be only one entry. So if self.food.ledger[0] isn’t at the same time the self.food.ledger[-1], then something isn’t right in solution.
yes, i suposse its like cheating, but i would still be there, working in a problem that i think has something wrong…
…if i confess what i did, in order to solve a problem, maybe it’s not cheat… and its a help <3
yes, @JeremyLT , you are right…
just writing, because seeing the comparative test files (the first and the last), i also see that there is a test over some quantities of deposits and withdraws, that are made without decimals, but then in the test the decimals appears… with the error on the test. (these quantities are 900 and 20, that then appears as 900.00 and 20.00)
shouldn’t have changed it, but now… how can i solve that mistake?
You should reset the test suite and submit the project again once the original test suite passes. We can help you with any errors you have if you share your code.
thank you for your time and sorry for the inconvenience caused.
i’ve openned the project again, with the original test suite , and now it does only one failure:
=========================
FAIL: test_to_string (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/boilerplate-budget-app/test_module.py", line 91, in test_to_string
self.assertEqual(actual, expected, 'Expected different string representation of object.')
AssertionError: '****[47 chars] 900\nmilk, cereal, eggs, bac -45.67\nT[40 chars]4.33' != '****[47 chars] 900.00\nmilk, cereal, eggs, bac -45.67\nT[40 chars]4.33'
*************Food*************
- deposit 900
? ---
+ deposit 900.00
? +++
milk, cereal, eggs, bac -45.67
- Transfer to Entertainme -20
? ---
+ Transfer to Entertainme -20.00
? +++
in this case the error is caused by the decimal part of one deposit of 900 and for a transfer of 20. In my output appears 900 and 20, but in the test suite it says that 900.00 and 20.00 are the valors expected…
…but it is not specified.
how can i solve this problem?
A list of the items in the ledger. Each line should show the description and amount. The first 23 characters of the description should be displayed, then the amount. The amount should be right aligned, contain two decimal places, and display a maximum of 7 characters.
You need to change your format that you print the numbers to show two decimal places