Skip to content
Advertisement

unittest assertionError in python AssertionError: != 200

I’m writing python tests with unittest and requests modules but getting
AssertionError: <Response [200]> != 200

Tests are setup in two functions, test_get and test_post. Test runners starts from Tests class, where the issue is within test2. I’ve tried to assert this also: <Response [200]> also. But getting this Error instead:

JavaScript

For this I am using httpbin and pycharm.

JavaScript

Advertisement

Answer

You’re comparing a response object with a number. They’re not equal.

What you intend is to compare the status code from the response object with a number. Try this:

JavaScript
Advertisement