Skip to content
Closed
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
1 change: 1 addition & 0 deletions newsfragments/34.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stop depending on the unmaintained PyPI ``curio`` package in tests; keep curio detection covered with a lightweight stub.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Changelog = "https://sniffio.readthedocs.io/en/latest/history.html"
test = [
"pytest",
"pytest-cov",
"curio",
]
rtd = [
"sphinx >= 1.6.1",
Expand Down
31 changes: 17 additions & 14 deletions sniffio/_tests/test_sniffio.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import sys
import types

import pytest

Expand Down Expand Up @@ -58,27 +58,30 @@ async def this_is_asyncio():
current_async_library()


@pytest.mark.skipif(
sys.version_info >= (3, 12),
reason=
"curio broken on 3.12 (https://github.com/python-trio/sniffio/pull/42)",
)
def test_curio():
import curio
def test_curio_detection_without_installing_curio():
"""Exercise the curio branch without the deprecated PyPI package.

Curio no longer ships releases on PyPI (see issue #34). Runtime support
remains for environments that still vendor curio; this test stubs the
tiny public surface sniffio actually imports.
"""
with pytest.raises(AsyncLibraryNotFoundError):
current_async_library()

ran = []
meta = types.ModuleType("curio.meta")
meta.curio_running = lambda: True
curio = types.ModuleType("curio")
curio.meta = meta

async def this_is_curio():
sys.modules["curio"] = curio
sys.modules["curio.meta"] = meta
try:
assert current_async_library() == "curio"
# Call it a second time to exercise the caching logic
assert current_async_library() == "curio"
ran.append(True)

curio.run(this_is_curio)
assert ran == [True]
finally:
sys.modules.pop("curio.meta", None)
sys.modules.pop("curio", None)

with pytest.raises(AsyncLibraryNotFoundError):
current_async_library()