Resolve test suite
This commit is contained in:
parent
e91b3d40a2
commit
6057da71f3
|
@ -520,6 +520,7 @@ class Sanic(BaseSanic):
|
||||||
ignore_body,
|
ignore_body,
|
||||||
) = self.router.get(request)
|
) = self.router.get(request)
|
||||||
request.name = name
|
request.name = name
|
||||||
|
request._match_info = kwargs
|
||||||
|
|
||||||
if request.stream.request_body and not ignore_body:
|
if request.stream.request_body and not ignore_body:
|
||||||
if self.router.is_stream_handler(request):
|
if self.router.is_stream_handler(request):
|
||||||
|
|
|
@ -58,6 +58,7 @@ class Request:
|
||||||
"_port",
|
"_port",
|
||||||
"_remote_addr",
|
"_remote_addr",
|
||||||
"_socket",
|
"_socket",
|
||||||
|
"_match_info",
|
||||||
"app",
|
"app",
|
||||||
"body",
|
"body",
|
||||||
"conn_info",
|
"conn_info",
|
||||||
|
@ -106,6 +107,7 @@ class Request:
|
||||||
self.uri_template = None
|
self.uri_template = None
|
||||||
self.request_middleware_started = False
|
self.request_middleware_started = False
|
||||||
self._cookies = None
|
self._cookies = None
|
||||||
|
self._match_info = {}
|
||||||
self.stream = None
|
self.stream = None
|
||||||
self.endpoint = None
|
self.endpoint = None
|
||||||
|
|
||||||
|
@ -370,7 +372,7 @@ class Request:
|
||||||
@property
|
@property
|
||||||
def match_info(self):
|
def match_info(self):
|
||||||
"""return matched info after resolving route"""
|
"""return matched info after resolving route"""
|
||||||
return self.app.router.get(self)[2]
|
return self._match_info
|
||||||
|
|
||||||
# Transport properties (obtained from local interface only)
|
# Transport properties (obtained from local interface only)
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ def test_app_route_raise_value_error(app):
|
||||||
|
|
||||||
def test_app_handle_request_handler_is_none(app, monkeypatch):
|
def test_app_handle_request_handler_is_none(app, monkeypatch):
|
||||||
def mockreturn(*args, **kwargs):
|
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.
|
# Not sure how to make app.router.get() return None, so use mock here.
|
||||||
monkeypatch.setattr(app.router, "get", mockreturn)
|
monkeypatch.setattr(app.router, "get", mockreturn)
|
||||||
|
|
|
@ -126,8 +126,9 @@ def test_html_traceback_output_in_debug_mode():
|
||||||
assert response.status == 500
|
assert response.status == 500
|
||||||
soup = BeautifulSoup(response.body, "html.parser")
|
soup = BeautifulSoup(response.body, "html.parser")
|
||||||
html = str(soup)
|
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 "handler_4" in html
|
||||||
assert "foo = bar" in html
|
assert "foo = bar" in html
|
||||||
|
|
||||||
|
@ -151,7 +152,7 @@ def test_chained_exception_handler():
|
||||||
soup = BeautifulSoup(response.body, "html.parser")
|
soup = BeautifulSoup(response.body, "html.parser")
|
||||||
html = str(soup)
|
html = str(soup)
|
||||||
|
|
||||||
assert "response = handler(request, *args, **kwargs)" in html
|
assert "response = handler(request, **kwargs)" in html
|
||||||
assert "handler_6" in html
|
assert "handler_6" in html
|
||||||
assert "foo = 1 / arg" in html
|
assert "foo = 1 / arg" in html
|
||||||
assert "ValueError" in html
|
assert "ValueError" in html
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -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_UJSON=1
|
||||||
{py36,py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UVLOOP=1
|
{py36,py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UVLOOP=1
|
||||||
deps =
|
deps =
|
||||||
sanic-testing==0.1.2
|
sanic-testing
|
||||||
coverage==5.3
|
coverage==5.3
|
||||||
pytest==5.2.1
|
pytest==5.2.1
|
||||||
pytest-cov
|
pytest-cov
|
||||||
|
|
Loading…
Reference in New Issue
Block a user