An exception is being raised for any response that is not a 2xx or 3xx status code.
You assert that it is being raised instead:
def test_MainPage_post(self):
with self.assertRaises(webtest.AppError) as exc:
response = self.testapp.post('/')
self.assertTrue(str(exc).startswith('Bad response: 405')
Alternatively, set expect_errors
to True
:
def test_MainPage_post(self):
response = self.testapp.post('/', expect_errors=True)
self.assertEqual(response.status_int, 405)
or tell the post
method to expect a 405:
def test_MainPage_post(self):
response = self.testapp.post('/', status=405)
where AppError
would be raised if the response status was not a 405. status
here can be a list or tuple of statuses as well.