Skip to content

Commit fdc3b28

Browse files
authored
chore: Update pytest to 8.3.4 and pytest-asyncio to 0.25.3 (#537)
1 parent a150161 commit fdc3b28

31 files changed

+397
-533
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ dynamic = ["authors", "classifiers", "dependencies", "description", "entry-point
77
[build-system]
88
requires = ["setuptools"]
99
build-backend = "setuptools.build_meta"
10+
11+
[tool.pytest.ini_options]
12+
asyncio_default_fixture_loop_scope = "function"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
tests_requires = [
1717
"parse==1.15.0",
18-
"pytest==7.4.2",
19-
"pytest-asyncio==0.21.1",
18+
"pytest==8.3.4",
19+
"pytest-asyncio==0.25.3",
2020
"pytest-console-scripts==1.4.1",
2121
"pytest-cov==5.0.0",
2222
"vcrpy==7.0.0",

tests/conftest.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,9 @@ async def client_and_server(server):
639639
# Generate transport to connect to the server fixture
640640
path = "/graphql"
641641
url = f"ws://{server.hostname}:{server.port}{path}"
642-
sample_transport = WebsocketsTransport(url=url)
642+
transport = WebsocketsTransport(url=url)
643643

644-
async with Client(transport=sample_transport) as session:
644+
async with Client(transport=transport) as session:
645645

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

664-
async with Client(transport=sample_transport) as session:
664+
async with Client(transport=transport) as session:
665665

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

686-
async with Client(transport=sample_transport) as session:
686+
async with Client(transport=transport) as session:
687687

688688
# Yield both client session and server
689689
yield session, server
@@ -699,12 +699,12 @@ async def client_and_graphqlws_server(graphqlws_server):
699699
# Generate transport to connect to the server fixture
700700
path = "/graphql"
701701
url = f"ws://{graphqlws_server.hostname}:{graphqlws_server.port}{path}"
702-
sample_transport = WebsocketsTransport(
702+
transport = WebsocketsTransport(
703703
url=url,
704704
subprotocols=[WebsocketsTransport.GRAPHQLWS_SUBPROTOCOL],
705705
)
706706

707-
async with Client(transport=sample_transport) as session:
707+
async with Client(transport=transport) as session:
708708

709709
# Yield both client session and server
710710
yield session, graphqlws_server
@@ -720,24 +720,25 @@ async def client_and_aiohttp_websocket_graphql_server(graphqlws_server):
720720
# Generate transport to connect to the server fixture
721721
path = "/graphql"
722722
url = f"ws://{graphqlws_server.hostname}:{graphqlws_server.port}{path}"
723-
sample_transport = AIOHTTPWebsocketsTransport(
723+
transport = AIOHTTPWebsocketsTransport(
724724
url=url,
725725
subprotocols=[AIOHTTPWebsocketsTransport.GRAPHQLWS_SUBPROTOCOL],
726726
)
727727

728-
async with Client(transport=sample_transport) as session:
728+
async with Client(transport=transport) as session:
729729

730730
# Yield both client session and server
731731
yield session, graphqlws_server
732732

733733

734734
@pytest_asyncio.fixture
735735
async def run_sync_test():
736-
async def run_sync_test_inner(event_loop, server, test_function):
736+
async def run_sync_test_inner(server, test_function):
737737
"""This function will run the test in a different Thread.
738738
739739
This allows us to run sync code while aiohttp server can still run.
740740
"""
741+
event_loop = asyncio.get_running_loop()
741742
executor = ThreadPoolExecutor(max_workers=2)
742743
test_task = event_loop.run_in_executor(executor, test_function)
743744

tests/custom_scalars/test_money.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ async def make_sync_money_transport(aiohttp_server):
491491

492492

493493
@pytest.mark.asyncio
494-
async def test_custom_scalar_in_output_with_transport(event_loop, aiohttp_server):
494+
async def test_custom_scalar_in_output_with_transport(aiohttp_server):
495495

496496
transport = await make_money_transport(aiohttp_server)
497497

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

510510

511511
@pytest.mark.asyncio
512-
async def test_custom_scalar_in_input_query_with_transport(event_loop, aiohttp_server):
512+
async def test_custom_scalar_in_input_query_with_transport(aiohttp_server):
513513

514514
transport = await make_money_transport(aiohttp_server)
515515

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

532532

533533
@pytest.mark.asyncio
534-
async def test_custom_scalar_in_input_variable_values_with_transport(
535-
event_loop, aiohttp_server
536-
):
534+
async def test_custom_scalar_in_input_variable_values_with_transport(aiohttp_server):
537535

538536
transport = await make_money_transport(aiohttp_server)
539537

@@ -556,7 +554,7 @@ async def test_custom_scalar_in_input_variable_values_with_transport(
556554

557555
@pytest.mark.asyncio
558556
async def test_custom_scalar_in_input_variable_values_split_with_transport(
559-
event_loop, aiohttp_server
557+
aiohttp_server,
560558
):
561559

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

582580

583581
@pytest.mark.asyncio
584-
async def test_custom_scalar_serialize_variables(event_loop, aiohttp_server):
582+
async def test_custom_scalar_serialize_variables(aiohttp_server):
585583

586584
transport = await make_money_transport(aiohttp_server)
587585

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

604602

605603
@pytest.mark.asyncio
606-
async def test_custom_scalar_serialize_variables_no_schema(event_loop, aiohttp_server):
604+
async def test_custom_scalar_serialize_variables_no_schema(aiohttp_server):
607605

608606
transport = await make_money_transport(aiohttp_server)
609607

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

624622
@pytest.mark.asyncio
625623
async def test_custom_scalar_serialize_variables_schema_from_introspection(
626-
event_loop, aiohttp_server
624+
aiohttp_server,
627625
):
628626

629627
transport = await make_money_transport(aiohttp_server)
@@ -656,7 +654,7 @@ async def test_custom_scalar_serialize_variables_schema_from_introspection(
656654

657655

658656
@pytest.mark.asyncio
659-
async def test_update_schema_scalars(event_loop, aiohttp_server):
657+
async def test_update_schema_scalars(aiohttp_server):
660658

661659
transport = await make_money_transport(aiohttp_server)
662660

@@ -735,7 +733,7 @@ def test_update_schema_scalars_scalar_type_is_not_a_scalar_in_schema():
735733
@pytest.mark.asyncio
736734
@pytest.mark.requests
737735
async def test_custom_scalar_serialize_variables_sync_transport(
738-
event_loop, aiohttp_server, run_sync_test
736+
aiohttp_server, run_sync_test
739737
):
740738

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

757-
await run_sync_test(event_loop, server, test_code)
755+
await run_sync_test(server, test_code)
758756

759757

760758
@pytest.mark.asyncio
761759
@pytest.mark.requests
762760
async def test_custom_scalar_serialize_variables_sync_transport_2(
763-
event_loop, aiohttp_server, run_sync_test
761+
aiohttp_server, run_sync_test
764762
):
765763
server, transport = await make_sync_money_transport(aiohttp_server)
766764

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

786-
await run_sync_test(event_loop, server, test_code)
784+
await run_sync_test(server, test_code)
787785

788786

789787
def test_serialize_value_with_invalid_type():
@@ -818,7 +816,7 @@ def test_serialize_value_with_nullable_type():
818816

819817

820818
@pytest.mark.asyncio
821-
async def test_gql_cli_print_schema(event_loop, aiohttp_server, capsys):
819+
async def test_gql_cli_print_schema(aiohttp_server, capsys):
822820

823821
from gql.cli import get_parser, main
824822

tests/starwars/test_introspection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
@pytest.mark.asyncio
13-
async def test_starwars_introspection_args(event_loop, aiohttp_server):
13+
async def test_starwars_introspection_args(aiohttp_server):
1414

1515
transport = await make_starwars_transport(aiohttp_server)
1616

tests/starwars/test_validation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import copy
2+
13
import pytest
24

35
from gql import Client, gql
@@ -62,7 +64,8 @@ def introspection_schema():
6264

6365
@pytest.fixture
6466
def introspection_schema_empty_directives():
65-
introspection = StarWarsIntrospection
67+
# Create a deep copy to avoid modifying the original
68+
introspection = copy.deepcopy(StarWarsIntrospection)
6669

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

7376
@pytest.fixture
7477
def introspection_schema_no_directives():
75-
introspection = StarWarsIntrospection
78+
# Create a deep copy to avoid modifying the original
79+
introspection = copy.deepcopy(StarWarsIntrospection)
7680

7781
# Simulate no directives key
7882
del introspection["__schema"]["directives"]

0 commit comments

Comments
 (0)