Merge pull request #3498 from raymond-devries/3445-traceback-for-none

View returned none exception contains endpoint name
This commit is contained in:
David Lord 2020-02-10 13:15:24 -08:00 committed by GitHub
commit a3e4395a42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -2078,9 +2078,9 @@ class Flask(_PackageBoundObject):
# the body must not be None
if rv is None:
raise TypeError(
"The view function did not return a valid response. The"
'The view function for "{}" did not return a valid response. The'
" function either returned None or ended without a return"
" statement."
" statement.".format(request.endpoint)
)
# make sure the body is an instance of the response class

View file

@ -1221,6 +1221,7 @@ def test_response_type_errors():
with pytest.raises(TypeError) as e:
c.get("/none")
assert "returned None" in str(e.value)
assert "from_none" in str(e.value)
with pytest.raises(TypeError) as e:
c.get("/small_tuple")