Merge branch 'main' into zhiwei/bp-copy

This commit is contained in:
Zhiwei
2021-07-07 01:01:35 -07:00
committed by GitHub
22 changed files with 324 additions and 202 deletions

View File

@@ -1,6 +1,4 @@
from crypt import methods
from sanic import text
from sanic import Sanic, text
from sanic.constants import HTTP_METHODS, HTTPMethod
@@ -14,7 +12,7 @@ def test_string_compat():
assert HTTPMethod.GET.upper() == "GET"
def test_use_in_routes(app):
def test_use_in_routes(app: Sanic):
@app.route("/", methods=[HTTPMethod.GET, HTTPMethod.POST])
def handler(_):
return text("It works")

View File

@@ -224,7 +224,6 @@ def non_chunked_streaming_app(app):
sample_streaming_fn,
headers={"Content-Length": "7"},
content_type="text/csv",
chunked=False,
)
return app
@@ -251,11 +250,7 @@ async def test_chunked_streaming_returns_correct_content_asgi(streaming_app):
def test_non_chunked_streaming_adds_correct_headers(non_chunked_streaming_app):
with pytest.warns(UserWarning) as record:
request, response = non_chunked_streaming_app.test_client.get("/")
assert len(record) == 1
assert "removed in v21.6" in record[0].message.args[0]
request, response = non_chunked_streaming_app.test_client.get("/")
assert "Transfer-Encoding" not in response.headers
assert response.headers["Content-Type"] == "text/csv"