diff --git a/newsfragments/34.bugfix.rst b/newsfragments/34.bugfix.rst new file mode 100644 index 0000000..2018b38 --- /dev/null +++ b/newsfragments/34.bugfix.rst @@ -0,0 +1 @@ +Stop depending on the unmaintained PyPI ``curio`` package in tests; keep curio detection covered with a lightweight stub. diff --git a/pyproject.toml b/pyproject.toml index cd73b2a..4824f25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,6 @@ Changelog = "https://sniffio.readthedocs.io/en/latest/history.html" test = [ "pytest", "pytest-cov", - "curio", ] rtd = [ "sphinx >= 1.6.1", diff --git a/sniffio/_tests/test_sniffio.py b/sniffio/_tests/test_sniffio.py index 02945a9..cc466a2 100644 --- a/sniffio/_tests/test_sniffio.py +++ b/sniffio/_tests/test_sniffio.py @@ -1,5 +1,5 @@ -import os import sys +import types import pytest @@ -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()