Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.8"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8"]
os: [ubuntu-20.04, windows-latest]
exclude:
- os: windows-latest
Expand All @@ -19,6 +19,8 @@ jobs:
python-version: "3.10"
- os: windows-latest
python-version: "3.11"
- os: windows-latest
python-version: "3.12"
- os: windows-latest
python-version: "pypy3.8"

Expand Down
1 change: 0 additions & 1 deletion docs/code_examples/console_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging

from aioconsole import ainput

from gql import Client, gql
from gql.transport.aiohttp import AIOHTTPTransport

Expand Down
1 change: 0 additions & 1 deletion docs/code_examples/fastapi_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from fastapi import FastAPI, HTTPException
from fastapi.responses import HTMLResponse

from gql import Client, gql
from gql.transport.aiohttp import AIOHTTPTransport

Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

tests_requires = [
"parse==1.15.0",
"pytest==6.2.5",
"pytest-asyncio==0.16.0",
"pytest==7.4.2",
"pytest-asyncio==0.21.1",
"pytest-console-scripts==1.3.1",
"pytest-cov==3.0.0",
"mock==4.0.2",
Expand All @@ -38,7 +38,8 @@
] + tests_requires

install_aiohttp_requires = [
"aiohttp>=3.8.0,<4",
"aiohttp>=3.8.0,<4;python_version<='3.11'",
"aiohttp>=3.9.0b0,<4;python_version>'3.11'",
]

install_requests_requires = [
Expand Down Expand Up @@ -89,6 +90,7 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: PyPy",
],
keywords="api graphql protocol rest relay gql client",
Expand Down
19 changes: 10 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Union

import pytest
import pytest_asyncio

from gql import Client

Expand Down Expand Up @@ -101,13 +102,13 @@ async def go(app, *, port=None, **kwargs): # type: ignore
await servers.pop().close()


@pytest.fixture
@pytest_asyncio.fixture
async def aiohttp_server():
async for server in aiohttp_server_base():
yield server


@pytest.fixture
@pytest_asyncio.fixture
async def ssl_aiohttp_server():
async for server in aiohttp_server_base(with_ssl=True):
yield server
Expand Down Expand Up @@ -203,7 +204,7 @@ async def stop(self):
try:
await asyncio.wait_for(self.server.wait_closed(), timeout=5)
except asyncio.TimeoutError: # pragma: no cover
assert False, "Server failed to stop"
pass

print("Server stopped\n\n\n")

Expand Down Expand Up @@ -349,7 +350,7 @@ async def default_server_handler(ws, path):
return server_handler


@pytest.fixture
@pytest_asyncio.fixture
async def ws_ssl_server(request):
"""Websockets server fixture using SSL.

Expand All @@ -372,7 +373,7 @@ async def ws_ssl_server(request):
await test_server.stop()


@pytest.fixture
@pytest_asyncio.fixture
async def server(request):
"""Fixture used to start a dummy server to test the client behaviour.

Expand All @@ -395,7 +396,7 @@ async def server(request):
await test_server.stop()


@pytest.fixture
@pytest_asyncio.fixture
async def graphqlws_server(request):
"""Fixture used to start a dummy server with the graphql-ws protocol.

Expand Down Expand Up @@ -443,7 +444,7 @@ def process_subprotocol(self, headers, available_subprotocols):
await test_server.stop()


@pytest.fixture
@pytest_asyncio.fixture
async def client_and_server(server):
"""Helper fixture to start a server and a client connected to its port."""

Expand All @@ -460,7 +461,7 @@ async def client_and_server(server):
yield session, server


@pytest.fixture
@pytest_asyncio.fixture
async def client_and_graphqlws_server(graphqlws_server):
"""Helper fixture to start a server with the graphql-ws prototocol
and a client connected to its port."""
Expand All @@ -481,7 +482,7 @@ async def client_and_graphqlws_server(graphqlws_server):
yield session, graphqlws_server


@pytest.fixture
@pytest_asyncio.fixture
async def run_sync_test():
async def run_sync_test_inner(event_loop, server, test_function):
"""This function will run the test in a different Thread.
Expand Down
3 changes: 2 additions & 1 deletion tests/starwars/test_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def test_use_variable_definition_multiple_times(ds):

assert (
print_ast(query)
== """mutation ($badReview: ReviewInput, $episode: Episode, $goodReview: ReviewInput) {
== """mutation \
($badReview: ReviewInput, $episode: Episode, $goodReview: ReviewInput) {
badReview: createReview(review: $badReview, episode: $episode) {
stars
commentary
Expand Down
11 changes: 10 additions & 1 deletion tests/test_appsync_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,16 @@ async def receiving_coro():
print(f"\n Server: Exception received: {e!s}\n")
finally:
print(" Server: waiting for websocket connection to close")
await ws.wait_closed()
try:
await asyncio.wait_for(ws.wait_closed(), 1000 * MS)
except asyncio.TimeoutError:
pass

try:
await asyncio.wait_for(ws.close(), 1000 * MS)
except asyncio.TimeoutError:
pass

print(" Server: connection closed")

return realtime_appsync_server_template
Expand Down
2 changes: 1 addition & 1 deletion tests/test_websocket_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ async def server_with_authentication_in_connection_init_payload(ws, path):
'{"type":"connection_error", "payload": "No Authorization token"}'
)

await ws.wait_closed()
await ws.close()


@pytest.mark.asyncio
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
black,flake8,import-order,mypy,manifest,
py{37,38,39,310,311,py3}
py{37,38,39,310,311,312,py3}

[gh-actions]
python =
Expand All @@ -10,6 +10,7 @@ python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312
pypy-3: pypy3

[testenv]
Expand All @@ -28,7 +29,7 @@ deps = -e.[test]
commands =
pip install -U setuptools
; run "tox -- tests -s" to show output for debugging
py{37,39,310,311,py3}: pytest {posargs:tests}
py{37,39,310,311,312,py3}: pytest {posargs:tests}
py{38}: pytest {posargs:tests --cov-report=term-missing --cov=gql}

[testenv:black]
Expand Down