Fix linting for websocket tests

This commit is contained in:
Andrew-Chen-Wang 2020-05-01 11:04:59 -04:00
parent 5381b482ef
commit b04e5f2e1a
2 changed files with 9 additions and 3 deletions

View File

@ -105,8 +105,12 @@ def remove_async_files():
file_names = [
os.path.join("config", "asgi.py"),
os.path.join("{{cookiecutter.project_slug}}", "users", "websocket.py"),
os.path.join("{{cookiecutter.project_slug}}", "users", "tests", "async_server.py"),
os.path.join("{{cookiecutter.project_slug}}", "users", "tests", "test_socket.py"),
os.path.join(
"{{cookiecutter.project_slug}}", "users", "tests", "async_server.py"
),
os.path.join(
"{{cookiecutter.project_slug}}", "users", "tests", "test_socket.py"
),
]
for file_name in file_names:
os.remove(file_name)

View File

@ -4,15 +4,17 @@ https://github.com/encode/uvicorn/blob/master/tests/protocols/test_websocket.py
"""
from asyncio import new_event_loop
from websockets import connect
from {{ cookiecutter.project_slug }}.users.tests.async_server import run_server
from {{cookiecutter.project_slug}}.users.tests.async_server import run_server
def test_accept_connection():
"""
If you want to communicate over HTTP, add live_server fixture
"""
async def open_connection(url):
async with connect(url) as websocket:
return websocket.open