Help with the Budget App in Scientific Computing with Python

I can’t find the difference between the unit test test_create_spend_chart and my implementation of it.

#-##-##-##-##-# Unit Test  #-##-##-##-##-#

Percentage spent by category
100|          
 90|          
 80|          
 70|    o     
 60|    o     
 50|    o     
 40|    o     
 30|    o     
 20|    o  o  
 10|    o  o  
  0| o  o  o  
    ----------
     B  F  E  
     u  o  n  
     s  o  t  
     i  d  e  
     n     r  
     e     t  
     s     a  
     s     i  
           n  
           m  
           e  
           n  
           t  
#-##-##-##-##-# End Unit Test  #-##-##-##-##-#

#-##-##-##-##-# My Implementation  #-##-##-##-##-#

Percentage spent by category
100|         
 90|         
 80|         
 70|    o    
 60|    o    
 50|    o    
 40|    o    
 30|    o    
 20|    o  o 
 10|    o  o 
  0| o  o  o 
    ----------
     B  F  E 
     u  o  n 
     s  o  t 
     i  d  e 
     n     r 
     e     t 
     s     a 
     s     i 
           n 
           m 
           e 
           n 
           t
#-##-##-##-##-# End My Implementation  #-##-##-##-##-#

bad blockquotes, sorry about that

#-##-##-##-##-# Unit Test  #-##-##-##-##-#

Percentage spent by category
100|          
 90|          
 80|          
 70|    o     
 60|    o     
 50|    o     
 40|    o     
 30|    o     
 20|    o  o  
 10|    o  o  
  0| o  o  o  
    ----------
     B  F  E  
     u  o  n  
     s  o  t  
     i  d  e  
     n     r  
     e     t  
     s     a  
     s     i  
           n  
           m  
           e  
           n  
           t  
#-##-##-##-##-# End Unit Test  #-##-##-##-##-#

#-##-##-##-##-# My Implementation  #-##-##-##-##-#

Percentage spent by category
100|         
 90|         
 80|         
 70|    o    
 60|    o    
 50|    o    
 40|    o    
 30|    o    
 20|    o  o 
 10|    o  o 
  0| o  o  o 
    ----------
     B  F  E 
     u  o  n 
     s  o  t 
     i  d  e 
     n     r 
     e     t 
     s     a 
     s     i 
           n 
           m 
           e 
           n 
           t
#-##-##-##-##-# End My Implementation  #-##-##-##-##-#

It would help if you provided a link to your code and the actual diff provided by the test suite, but it looks like you have the wrong number of spaces at the end of each line.

======================================================================
FAIL: test_create_spend_chart (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/budget-app/test_module.py", line 94, in test_create_spend_chart
    self.assertEqual(actual, expected, 'Expected different chart representation. Check that all spacing is exact.')
AssertionError: 'Perc[34 chars]     \n 90|         \n 80|         \n 70|    o[315 chars]   t' != 'Perc[34 chars]      \n 90|          \n 80|          \n 70|  [340 chars] t  '
Diff is 1246 characters long. Set self.maxDiff to None to see it. : Expected different chart representation. Check that all spacing is exact.

----------------------------------------------------------------------
Ran 11 tests in 0.009s

FAILED (failures=1)

A link to the code.

That’s rude of the test suite.

+  0| o  o  o 
-  0| o  o  o  

If I manually recreate a line of what the diff would be, it looks like your lines are one space too short.

1 Like

All right, thanks for the help.
Do you know of a way to contact the freeCodeCamp staff? I would like to prevent this issue in the future for other people.

1 Like

I’m not sure what you mean by ‘prevent this issue’? What do you have in mind? You could make a suggestion as a GitHub Issue.

1 Like

‘Issue’ being that a missing space at the end of a line is considered a mistake by the system. I don’t understand it. Thanks for all your help though!

1 Like

It’s part of the spec for the problem. If we diff your string and the output, we have to have character for character agreement. I don’t know how we could easily check for an arbitrary number of spaces after each line.

I think they tried to warn about this in the test suite:

I understand. It just annoyed me because I couldn’t understand the issue. Thanks again for your help and for explaining all my questions.

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