Skip to content

chore: Update pytest to 8.3.4 and pytest-asyncio to 0.25.3 #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
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
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ dynamic = ["authors", "classifiers", "dependencies", "description", "entry-point
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "function"
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

tests_requires = [
"parse==1.15.0",
"pytest==7.4.2",
"pytest-asyncio==0.21.1",
"pytest==8.3.4",
"pytest-asyncio==0.25.3",
"pytest-console-scripts==1.4.1",
"pytest-cov==5.0.0",
"vcrpy==7.0.0",
Expand Down
23 changes: 12 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,9 @@ async def client_and_server(server):
# Generate transport to connect to the server fixture
path = "/graphql"
url = f"ws://{server.hostname}:{server.port}{path}"
sample_transport = WebsocketsTransport(url=url)
transport = WebsocketsTransport(url=url)

async with Client(transport=sample_transport) as session:
async with Client(transport=transport) as session:

# Yield both client session and server
yield session, server
Expand All @@ -659,9 +659,9 @@ async def aiohttp_client_and_server(server):
# Generate transport to connect to the server fixture
path = "/graphql"
url = f"ws://{server.hostname}:{server.port}{path}"
sample_transport = AIOHTTPWebsocketsTransport(url=url)
transport = AIOHTTPWebsocketsTransport(url=url)

async with Client(transport=sample_transport) as session:
async with Client(transport=transport) as session:

# Yield both client session and server
yield session, server
Expand All @@ -681,9 +681,9 @@ async def aiohttp_client_and_aiohttp_ws_server(aiohttp_ws_server):
# Generate transport to connect to the server fixture
path = "/graphql"
url = f"ws://{server.hostname}:{server.port}{path}"
sample_transport = AIOHTTPWebsocketsTransport(url=url)
transport = AIOHTTPWebsocketsTransport(url=url)

async with Client(transport=sample_transport) as session:
async with Client(transport=transport) as session:

# Yield both client session and server
yield session, server
Expand All @@ -699,12 +699,12 @@ async def client_and_graphqlws_server(graphqlws_server):
# Generate transport to connect to the server fixture
path = "/graphql"
url = f"ws://{graphqlws_server.hostname}:{graphqlws_server.port}{path}"
sample_transport = WebsocketsTransport(
transport = WebsocketsTransport(
url=url,
subprotocols=[WebsocketsTransport.GRAPHQLWS_SUBPROTOCOL],
)

async with Client(transport=sample_transport) as session:
async with Client(transport=transport) as session:

# Yield both client session and server
yield session, graphqlws_server
Expand All @@ -720,24 +720,25 @@ async def client_and_aiohttp_websocket_graphql_server(graphqlws_server):
# Generate transport to connect to the server fixture
path = "/graphql"
url = f"ws://{graphqlws_server.hostname}:{graphqlws_server.port}{path}"
sample_transport = AIOHTTPWebsocketsTransport(
transport = AIOHTTPWebsocketsTransport(
url=url,
subprotocols=[AIOHTTPWebsocketsTransport.GRAPHQLWS_SUBPROTOCOL],
)

async with Client(transport=sample_transport) as session:
async with Client(transport=transport) as session:

# Yield both client session and server
yield session, graphqlws_server


@pytest_asyncio.fixture
async def run_sync_test():
async def run_sync_test_inner(event_loop, server, test_function):
async def run_sync_test_inner(server, test_function):
"""This function will run the test in a different Thread.

This allows us to run sync code while aiohttp server can still run.
"""
event_loop = asyncio.get_running_loop()
executor = ThreadPoolExecutor(max_workers=2)
test_task = event_loop.run_in_executor(executor, test_function)

Expand Down
28 changes: 13 additions & 15 deletions tests/custom_scalars/test_money.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ async def make_sync_money_transport(aiohttp_server):


@pytest.mark.asyncio
async def test_custom_scalar_in_output_with_transport(event_loop, aiohttp_server):
async def test_custom_scalar_in_output_with_transport(aiohttp_server):

transport = await make_money_transport(aiohttp_server)

Expand All @@ -509,7 +509,7 @@ async def test_custom_scalar_in_output_with_transport(event_loop, aiohttp_server


@pytest.mark.asyncio
async def test_custom_scalar_in_input_query_with_transport(event_loop, aiohttp_server):
async def test_custom_scalar_in_input_query_with_transport(aiohttp_server):

transport = await make_money_transport(aiohttp_server)

Expand All @@ -531,9 +531,7 @@ async def test_custom_scalar_in_input_query_with_transport(event_loop, aiohttp_s


@pytest.mark.asyncio
async def test_custom_scalar_in_input_variable_values_with_transport(
event_loop, aiohttp_server
):
async def test_custom_scalar_in_input_variable_values_with_transport(aiohttp_server):

transport = await make_money_transport(aiohttp_server)

Expand All @@ -556,7 +554,7 @@ async def test_custom_scalar_in_input_variable_values_with_transport(

@pytest.mark.asyncio
async def test_custom_scalar_in_input_variable_values_split_with_transport(
event_loop, aiohttp_server
aiohttp_server,
):

transport = await make_money_transport(aiohttp_server)
Expand All @@ -581,7 +579,7 @@ async def test_custom_scalar_in_input_variable_values_split_with_transport(


@pytest.mark.asyncio
async def test_custom_scalar_serialize_variables(event_loop, aiohttp_server):
async def test_custom_scalar_serialize_variables(aiohttp_server):

transport = await make_money_transport(aiohttp_server)

Expand All @@ -603,7 +601,7 @@ async def test_custom_scalar_serialize_variables(event_loop, aiohttp_server):


@pytest.mark.asyncio
async def test_custom_scalar_serialize_variables_no_schema(event_loop, aiohttp_server):
async def test_custom_scalar_serialize_variables_no_schema(aiohttp_server):

transport = await make_money_transport(aiohttp_server)

Expand All @@ -623,7 +621,7 @@ async def test_custom_scalar_serialize_variables_no_schema(event_loop, aiohttp_s

@pytest.mark.asyncio
async def test_custom_scalar_serialize_variables_schema_from_introspection(
event_loop, aiohttp_server
aiohttp_server,
):

transport = await make_money_transport(aiohttp_server)
Expand Down Expand Up @@ -656,7 +654,7 @@ async def test_custom_scalar_serialize_variables_schema_from_introspection(


@pytest.mark.asyncio
async def test_update_schema_scalars(event_loop, aiohttp_server):
async def test_update_schema_scalars(aiohttp_server):

transport = await make_money_transport(aiohttp_server)

Expand Down Expand Up @@ -735,7 +733,7 @@ def test_update_schema_scalars_scalar_type_is_not_a_scalar_in_schema():
@pytest.mark.asyncio
@pytest.mark.requests
async def test_custom_scalar_serialize_variables_sync_transport(
event_loop, aiohttp_server, run_sync_test
aiohttp_server, run_sync_test
):

server, transport = await make_sync_money_transport(aiohttp_server)
Expand All @@ -754,13 +752,13 @@ def test_code():
print(f"result = {result!r}")
assert result["toEuros"] == 5

await run_sync_test(event_loop, server, test_code)
await run_sync_test(server, test_code)


@pytest.mark.asyncio
@pytest.mark.requests
async def test_custom_scalar_serialize_variables_sync_transport_2(
event_loop, aiohttp_server, run_sync_test
aiohttp_server, run_sync_test
):
server, transport = await make_sync_money_transport(aiohttp_server)

Expand All @@ -783,7 +781,7 @@ def test_code():
assert results[0]["toEuros"] == 5
assert results[1]["toEuros"] == 5

await run_sync_test(event_loop, server, test_code)
await run_sync_test(server, test_code)


def test_serialize_value_with_invalid_type():
Expand Down Expand Up @@ -818,7 +816,7 @@ def test_serialize_value_with_nullable_type():


@pytest.mark.asyncio
async def test_gql_cli_print_schema(event_loop, aiohttp_server, capsys):
async def test_gql_cli_print_schema(aiohttp_server, capsys):

from gql.cli import get_parser, main

Expand Down
2 changes: 1 addition & 1 deletion tests/starwars/test_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@pytest.mark.asyncio
async def test_starwars_introspection_args(event_loop, aiohttp_server):
async def test_starwars_introspection_args(aiohttp_server):

transport = await make_starwars_transport(aiohttp_server)

Expand Down
8 changes: 6 additions & 2 deletions tests/starwars/test_validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import copy

import pytest

from gql import Client, gql
Expand Down Expand Up @@ -62,7 +64,8 @@ def introspection_schema():

@pytest.fixture
def introspection_schema_empty_directives():
introspection = StarWarsIntrospection
# Create a deep copy to avoid modifying the original
introspection = copy.deepcopy(StarWarsIntrospection)

# Simulate an empty dictionary for directives
introspection["__schema"]["directives"] = []
Expand All @@ -72,7 +75,8 @@ def introspection_schema_empty_directives():

@pytest.fixture
def introspection_schema_no_directives():
introspection = StarWarsIntrospection
# Create a deep copy to avoid modifying the original
introspection = copy.deepcopy(StarWarsIntrospection)

# Simulate no directives key
del introspection["__schema"]["directives"]
Expand Down
Loading
Loading