Code fails 2 UnitTests

Tell us what’s happening:
Hi. Please can you provide some guidance on why the code linked below fails 2 of the 11 unit tests in the file? As far as I can tell, the format of the table and chart matches the examples given in the read-me file, however the unit tests that fail state that the format of both is incorrect. Thanks!!

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36.

Challenge: Budget App

Link to the challenge:

Welcome to the forums.

Just check your test output. First:

FAIL: test_to_string (test_module.UnitTests)
Traceback (most recent call last):
  File "/home/gray/src/work/fcc-sc-budget/", line 131, in test_to_string
AssertionError: '****[77 chars]s, bac -45.67\nTransfer to Entertainme -20.00\nTotal: 834.33\n' != '****[77 chars]s, bac -45.67\nTransfer to Entertainme -20.00\nTotal: 834.33'
  deposit                 900.00
  milk, cereal, eggs, bac -45.67
  Transfer to Entertainme -20.00
- Total: 834.33
?              -
+ Total: 834.33 : Expected different string representation of object.

In this one, the AssertionError is showing that the actual string has a newline and the expected one doesn’t. It also tries to show you this on the lines beginning with -, ?, and +.

The second is a little trickier. You need to set self.maxDiff to None to see the results, part of which is:

-   0| o  o  o 
+   0| o  o  o  
?              +
-      B  F  E 
+      B  F  E  
?              +

which with coloration, shows that your lines (-) are missing a space compared to the expected lines (+).

1 Like

Thanks Jeremy. I was having trouble understanding the errors in the test outputs. This makes sense.