Skip to content

Commit be7ef24

Browse files
committed
properly support python 3.14
1 parent 9d59507 commit be7ef24

5 files changed

Lines changed: 22 additions & 12 deletions

File tree

.github/workflows/test-suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1818

1919
steps:
2020
- uses: "actions/checkout@v4"

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ classifiers = [
2525
"Programming Language :: Python :: 3.11",
2626
"Programming Language :: Python :: 3.12",
2727
"Programming Language :: Python :: 3.13",
28+
"Programming Language :: Python :: 3.14",
2829
"Topic :: Internet :: WWW/HTTP",
2930
]
3031
dependencies = [
@@ -82,7 +83,7 @@ test = [
8283
"trio==0.31.0",
8384
"trio-typing==0.10.0",
8485
"trustme==1.2.1",
85-
"uvicorn==0.35.0",
86+
"uvicorn==0.38.0",
8687
]
8788
docs = [
8889
"mkdocs==1.6.1",

tests/conftest.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,9 @@ def install_signal_handlers(self) -> None:
235235
async def serve(self, sockets=None):
236236
self.restart_requested = asyncio.Event()
237237

238-
loop = asyncio.get_event_loop()
239238
tasks = {
240-
loop.create_task(super().serve(sockets=sockets)),
241-
loop.create_task(self.watch_restarts()),
239+
asyncio.create_task(super().serve(sockets=sockets)),
240+
asyncio.create_task(self.watch_restarts()),
242241
}
243242
await asyncio.wait(tasks)
244243

@@ -269,7 +268,15 @@ async def watch_restarts(self) -> None: # pragma: no cover
269268

270269

271270
def serve_in_thread(server: TestServer) -> typing.Iterator[TestServer]:
272-
thread = threading.Thread(target=server.run)
271+
def run_server() -> None:
272+
loop = asyncio.new_event_loop()
273+
asyncio.set_event_loop(loop)
274+
try:
275+
loop.run_until_complete(server.serve()) # type: ignore
276+
finally:
277+
loop.close()
278+
279+
thread = threading.Thread(target=run_server)
273280
thread.start()
274281
try:
275282
while not server.started:
@@ -282,6 +289,6 @@ def serve_in_thread(server: TestServer) -> typing.Iterator[TestServer]:
282289

283290
@pytest.fixture(scope="session")
284291
def server() -> typing.Iterator[TestServer]:
285-
config = Config(app=app, lifespan="off", loop="asyncio")
292+
config = Config(app=app, lifespan="off")
286293
server = TestServer(config=config)
287294
yield from serve_in_thread(server)

tests/test_timeouts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ async def test_read_timeout(server):
1212
await client.get(server.url.copy_with(path="/slow_response"))
1313

1414

15+
# TODO: Fix ResourceWarning in this test for Python>=3.14
16+
@pytest.mark.filterwarnings("ignore::ResourceWarning")
1517
@pytest.mark.anyio
1618
async def test_write_timeout(server):
1719
timeout = httpx.Timeout(None, write=1e-6)

uv.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)