Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Assertion Failure 200 != 302

Hi there. I'm having a somewhat confusing error where when I run app_tests.py, I'm getting:

..F........
======================================================================
FAIL: test_taco_create (__main__.TacoViewsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "app_tests.py", line 144, in test_taco_create
    self.assertEqual(rv.status_code, 302)
AssertionError: 200 != 302

----------------------------------------------------------------------
Ran 11 tests in 3.974s

FAILED (failures=1)

What exactly does this error mean? I'm not sure what the rv.status_code represents (let alone 200 vs 302). Any tips for interpreting the error would be greatly appreciated. Thanks!

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,468 Points

The test suite assigns the result of its HttpRequests (from self.app.post()) to the variable named rv (response value?). The status_code of the response is in the attribute rv.status_code. This test is expecting an HTTP 302 (redirect) status_code, but is instead getting an [HTTP 200](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200] (OK).

After you "create a taco" are you using a redirect to send back the "index" view?

Oh I wasn't. That totally fixed it. Thank you!