Resolve test suite

This commit is contained in:
Adam Hopkins 2021-02-15 13:45:29 +02:00
parent e91b3d40a2
commit 6057da71f3
5 changed files with 9 additions and 5 deletions

View File

@ -520,6 +520,7 @@ class Sanic(BaseSanic):
ignore_body,
) = self.router.get(request)
request.name = name
request._match_info = kwargs
if request.stream.request_body and not ignore_body:
if self.router.is_stream_handler(request):

View File

@ -58,6 +58,7 @@ class Request:
"_port",
"_remote_addr",
"_socket",
"_match_info",
"app",
"body",
"conn_info",
@ -106,6 +107,7 @@ class Request:
self.uri_template = None
self.request_middleware_started = False
self._cookies = None
self._match_info = {}
self.stream = None
self.endpoint = None
@ -370,7 +372,7 @@ class Request:
@property
def match_info(self):
"""return matched info after resolving route"""
return self.app.router.get(self)[2]
return self._match_info
# Transport properties (obtained from local interface only)

View File

@ -118,7 +118,7 @@ def test_app_route_raise_value_error(app):
def test_app_handle_request_handler_is_none(app, monkeypatch):
def mockreturn(*args, **kwargs):
return None, [], {}, "", "", None, False
return None, {}, "", "", False
# Not sure how to make app.router.get() return None, so use mock here.
monkeypatch.setattr(app.router, "get", mockreturn)

View File

@ -126,8 +126,9 @@ def test_html_traceback_output_in_debug_mode():
assert response.status == 500
soup = BeautifulSoup(response.body, "html.parser")
html = str(soup)
print(html)
assert "response = handler(request, *args, **kwargs)" in html
assert "response = handler(request, **kwargs)" in html
assert "handler_4" in html
assert "foo = bar" in html
@ -151,7 +152,7 @@ def test_chained_exception_handler():
soup = BeautifulSoup(response.body, "html.parser")
html = str(soup)
assert "response = handler(request, *args, **kwargs)" in html
assert "response = handler(request, **kwargs)" in html
assert "handler_6" in html
assert "foo = 1 / arg" in html
assert "ValueError" in html

View File

@ -7,7 +7,7 @@ setenv =
{py36,py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UJSON=1
{py36,py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UVLOOP=1
deps =
sanic-testing==0.1.2
sanic-testing
coverage==5.3
pytest==5.2.1
pytest-cov