Budget app (.F...FFF...)

There are some bugs in my code:
https://replit.com/@ayratmsk/boilerplate-budget-app#budget.py

I don’t know what order has code from tests and yet struggling find my problems

======================================================================
FAIL: test_create_spend_chart (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-budget-app/test_module.py", line 102, 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|     [316 chars]  t ' != 'Perc[34 chars]      \n 90|          \n 80|          \n 70|  [340 chars] t  '
  Percentage spent by category
- 100|         
+ 100|          
?              +
-  90|         
+  90|          
?              +
-  80|         
+  80|          
?              +
-  70|         
+  70|    o     
?         +
-  60|    o    
+  60|    o     
?              +
-  50|    o    
+  50|    o     
?              +
-  40|    o    
+  40|    o     
?              +
-  30|    o    
+  30|    o     
?              +
-  20|    o  o 
+  20|    o  o  
?              +
-  10|    o  o 
+  10|    o  o  
?              +
-   0| o  o  o 
+   0| o  o  o  
?              +
      ----------
-      B  F  E 
+      B  F  E  
?              +
-      u  o  n 
+      u  o  n  
?              +
-      s  o  t 
+      s  o  t  
?              +
-      i  d  e 
+      i  d  e  
?              +
-      n     r 
+      n     r  
?              +
-      e     t 
+      e     t  
?              +
-      s     a 
+      s     a  
?              +
-      s     i 
+      s     i  
?              +
-            n 
+            n  
?              +
-            m 
+            m  
?              +
-            e 
+            e  
?              +
-            n 
+            n  
?              +
-            t +            t  ?              +
 : Expected different chart representation. Check that all spacing is exact.

======================================================================
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
?                            +++
  Total: 834.33 : Expected different string representation of object.

======================================================================
FAIL: test_transfer (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-budget-app/test_module.py", line 59, in test_transfer
    self.assertEqual(good_transfer, True, 'Expected `transfer` method to return `True`.')
AssertionError: None != True : Expected `transfer` method to return `True`.

======================================================================
FAIL: test_transfer_no_funds (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-budget-app/test_module.py", line 83, in test_transfer_no_funds
    self.assertEqual(good_transfer, False, 'Expected `transfer` method to return `False`.')
AssertionError: None != False : Expected `transfer` method to return `False`.

----------------------------------------------------------------------
Ran 11 tests in 0.017s
1 Like

Please post the error messages. Thanks


Edit: you have a few issues

  1. spaces at the end of lines in the chart

  2. bar heights in the chart

  3. integer vs decimal representation

The red lines what was expected and the green what was found instead.

Thank you.
But why “Transfer to Entertainment” 20 instead 20.00 become an error?
There is an example in Food output “Transfer to Clothing” 50.00

Oh I can see now: you mismatch red and green lines meanings ))

Woops, yeah, my explanation was backwards

Just a hint: The Traceback shows both the file and the line where the error occured. This line is from the test_module.py and as you can see, it checks the actual output (yours) against the expected (how it should look like) - hence the first line is your output and the second the expected.

There might be some projects where the two are switched.

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