Possible test error of the Budget App (Python certificate)

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! :slight_smile:

" 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.


Agreed. That smells like global variable abuse might be the core issue.

1 Like

hey there!
in the next project, “Polygon Area Calculator”, maybe also there is something wrong…

"unable to read .replit:
unable to decode .replit: toml: cannot load TOML value of type map[string]interface {} into a Go string “”

… this is what appears in the Replit’s console when press the Run button.

pd. sorry if it was something wrong with my computing equipment, but i think i should write something about it

Don’t do this by the way. Changing the tests so that you pass is totally cheating.

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

It is cheating to submit a project with a modified test suite.

You can look at or change the tests when debugging, but the final submission must have an unmodified test suite.

1 Like

yes, @JeremyLT , you are right… :frowning:
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.

1 Like

thank you for your time and sorry for the inconvenience caused.

i’ve openned the project again, with the original test suite :sweat_smile:, 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'
- 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

1 Like

ouch, man! :see_no_evil:
thanks again for your reading and time… i promise next project i’ll read it very very slow and carefully :grimacing: :sweat_smile: :face_with_raised_eyebrow:

nice project, nice people :smiling_face_with_three_hearts:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.