Create requests-async based TestClient, remove aiohttp dependency, drop Python 3.5
Update all tests to be compatible with requests-async Cleanup testing client changes with black and isort Remove Python 3.5 and other meta doc cleanup rename pyproject and fix pep517 error Add black config to tox.ini Cleanup tests and remove aiohttp tox.ini change for easier development commands Remove aiohttp from changelog and requirements Cleanup imports and Makefile
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import socket
|
||||
|
||||
from sanic.testing import PORT, SanicTestClient
|
||||
from sanic.response import json, text
|
||||
from sanic.testing import PORT, SanicTestClient
|
||||
|
||||
|
||||
# ------------------------------------------------------------ #
|
||||
# UTF-8
|
||||
@@ -9,26 +10,26 @@ from sanic.response import json, text
|
||||
|
||||
|
||||
def test_test_client_port_none(app):
|
||||
@app.get('/get')
|
||||
@app.get("/get")
|
||||
def handler(request):
|
||||
return text('OK')
|
||||
return text("OK")
|
||||
|
||||
test_client = SanicTestClient(app, port=None)
|
||||
|
||||
request, response = test_client.get('/get')
|
||||
assert response.text == 'OK'
|
||||
request, response = test_client.get("/get")
|
||||
assert response.text == "OK"
|
||||
|
||||
request, response = test_client.post('/get')
|
||||
request, response = test_client.post("/get")
|
||||
assert response.status == 405
|
||||
|
||||
|
||||
def test_test_client_port_default(app):
|
||||
@app.get('/get')
|
||||
@app.get("/get")
|
||||
def handler(request):
|
||||
return json(request.transport.get_extra_info('sockname')[1])
|
||||
return json(request.transport.get_extra_info("sockname")[1])
|
||||
|
||||
test_client = SanicTestClient(app)
|
||||
assert test_client.port == PORT
|
||||
|
||||
request, response = test_client.get('/get')
|
||||
request, response = test_client.get("/get")
|
||||
assert response.json == PORT
|
||||
|
||||
Reference in New Issue
Block a user