def test_handled_unhandled_exception(exception_app):
 (request, response) = sanic_endpoint_test(exception_app, uri='/divide_by_zero')
 assert (response.status == 500)
 soup = BeautifulSoup(response.body, 'html.parser')
 assert (soup.h1.text == 'Internal Server Error')
 message = ' '.join(soup.p.text.split())
 assert (message == 'The server encountered an internal error and cannot complete your request.')

def test_handled_unhandled_exception ( exception_app ) : ( request , response ) = sanic_endpoint_test ( exception_app , uri = '/divide_by_zero' ) assert ( response . status == 500 ) soup = BeautifulSoup ( response . body , 'html.parser' ) assert ( soup . h1 . text == 'Internal Server Error' ) message = ' ' . join ( soup . p . text . split ( ) ) assert ( message == 'The server encountered an internal error and cannot complete your request.' )
test that an exception not built into sanic is handled .