Resolve linting issues with imports
This commit is contained in:
parent
b2d4132a14
commit
ab706dda7d
|
@ -1,13 +1,15 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from http.cookies import SimpleCookie
|
from http.cookies import SimpleCookie
|
||||||
from inspect import isawaitable
|
from inspect import isawaitable
|
||||||
from typing import Any, Awaitable, Callable, MutableMapping, Union
|
from typing import Any, Awaitable, Callable, MutableMapping, Union
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
from multidict import CIMultiDict
|
from multidict import CIMultiDict
|
||||||
from urllib.parse import quote
|
|
||||||
from sanic.log import logger
|
|
||||||
from sanic.exceptions import InvalidUsage, ServerError
|
from sanic.exceptions import InvalidUsage, ServerError
|
||||||
|
from sanic.log import logger
|
||||||
from sanic.request import Request
|
from sanic.request import Request
|
||||||
from sanic.response import HTTPResponse, StreamingHTTPResponse
|
from sanic.response import HTTPResponse, StreamingHTTPResponse
|
||||||
from sanic.server import StreamBuffer
|
from sanic.server import StreamBuffer
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from sanic.blueprints import Blueprint
|
from sanic.blueprints import Blueprint
|
||||||
from sanic.exceptions import HeaderExpectationFailed
|
from sanic.exceptions import HeaderExpectationFailed
|
||||||
from sanic.request import StreamBuffer
|
from sanic.request import StreamBuffer
|
||||||
|
@ -42,13 +43,15 @@ def test_request_stream_method_view(app):
|
||||||
assert response.text == data
|
assert response.text == data
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("headers, expect_raise_exception", [
|
@pytest.mark.parametrize(
|
||||||
({"EXPECT": "100-continue"}, False),
|
"headers, expect_raise_exception",
|
||||||
({"EXPECT": "100-continue-extra"}, True),
|
[
|
||||||
])
|
({"EXPECT": "100-continue"}, False),
|
||||||
|
({"EXPECT": "100-continue-extra"}, True),
|
||||||
|
],
|
||||||
|
)
|
||||||
def test_request_stream_100_continue(app, headers, expect_raise_exception):
|
def test_request_stream_100_continue(app, headers, expect_raise_exception):
|
||||||
class SimpleView(HTTPMethodView):
|
class SimpleView(HTTPMethodView):
|
||||||
|
|
||||||
@stream_decorator
|
@stream_decorator
|
||||||
async def post(self, request):
|
async def post(self, request):
|
||||||
assert isinstance(request.stream, StreamBuffer)
|
assert isinstance(request.stream, StreamBuffer)
|
||||||
|
@ -65,12 +68,18 @@ def test_request_stream_100_continue(app, headers, expect_raise_exception):
|
||||||
assert app.is_request_stream is True
|
assert app.is_request_stream is True
|
||||||
|
|
||||||
if not expect_raise_exception:
|
if not expect_raise_exception:
|
||||||
request, response = app.test_client.post("/method_view", data=data, headers={"EXPECT": "100-continue"})
|
request, response = app.test_client.post(
|
||||||
|
"/method_view", data=data, headers={"EXPECT": "100-continue"}
|
||||||
|
)
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
assert response.text == data
|
assert response.text == data
|
||||||
else:
|
else:
|
||||||
with pytest.raises(ValueError) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
app.test_client.post("/method_view", data=data, headers={"EXPECT": "100-continue-extra"})
|
app.test_client.post(
|
||||||
|
"/method_view",
|
||||||
|
data=data,
|
||||||
|
headers={"EXPECT": "100-continue-extra"},
|
||||||
|
)
|
||||||
assert "Unknown Expect: 100-continue-extra" in str(e)
|
assert "Unknown Expect: 100-continue-extra" in str(e)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user