Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(test): scope the missing-async-plugin guard to async selections
cyh8a3af9036f3e
diff --git a/pyproject.toml b/pyproject.tomlindex 4e534e2fd..be449f1b6 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -157,12 +157,11 @@ extend-ignore = ["E501"][tool.pytest.ini_options]asyncio_mode = "auto"-# Without pytest-asyncio every ``async def`` test fails individually with-# "async def functions are not natively supported", and ``asyncio_mode`` above-# is reported only as an unknown-config warning. That names the tests instead of-# the missing plugin, so a suite run in an environment that never installed the-# dev group looks like a broad product regression. Fail once, up front, instead.-required_plugins = ["pytest-asyncio"]+# The missing-pytest-asyncio guard lives in tests/conftest.py, not in a+# ``required_plugins`` entry here: this table is the rootdir-wide config, and+# that key is enforced before collection, so it would also abort the+# packaged-test and publish jobs that deliberately install only the built+# artifact plus pytest and select synchronous tests only.markers = ["e2e_model_hub: opt-in hermetic Model Hub HTTP and gateway scenarios","integration: tests excluded from the unit shards because they need external infrastructure (Docker + platform tokens) or minutes of real filesystem work",diff --git a/tests/conftest.py b/tests/conftest.pyindex 9ed23a52e..05696ec1c 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -44,6 +44,7 @@ write to ``~/.avibe/`` or legacy ``~/.vibe_remote/``).from __future__ import annotationsimport ast+import inspectimport osimport shutilimport sqlite3@@ -457,3 +458,57 @@ def _reset_show_runtime_manager():show_runtime.set_show_runtime_manager_for_tests(None)except Exception:pass+++def _async_items_missing_plugin(items) -> list:+ """Return the selected items that need pytest-asyncio but would not get it.++ ``anyio``-marked coroutines are excluded: anyio is a runtime dependency, so+ its pytest plugin is present wherever the package installs, and it drives+ those tests itself.+ """+ offenders = []+ for item in items:+ if item.get_closest_marker("anyio") is not None:+ continue+ try:+ func = item.obj+ except Exception:+ # Exotic collectors (doctests, custom items) have no test function.+ continue+ if inspect.iscoroutinefunction(func):+ offenders.append(item)+ return offenders+++def pytest_collection_modifyitems(config, items):+ """Fail once, up front, when async tests are selected without pytest-asyncio.++ ``asyncio_mode = "auto"`` only takes effect when the plugin is installed.+ Without it each of the suite's ~1670 ``async def`` tests fails on its own+ with "async def functions are not natively supported", while the mode+ setting is reported merely as an unknown-config warning. That names the+ tests instead of the one missing dev dependency, so a suite run in an+ environment that never installed the dev group reads as a broad product+ regression -- measured as 10 failures across 2 files after 146s in a+ container whose runtime venv installs only the wheel.++ This is a collection-time check rather than a ``required_plugins`` entry in+ pyproject because that key is a rootdir-wide prerequisite enforced *before*+ collection: it also aborts the packaged-test job (.github/workflows/lint.yml,+ which installs ``dist/*.whl pytest``) and the publish finalizer+ (.github/workflows/publish.yml, ``pip install -e . build pytest``), both of+ which select synchronous tests only and legitimately have no async plugin.+ Keying off the selected items puts the guard on exactly the runs it is for.+ """+ if config.pluginmanager.hasplugin("asyncio"):+ return+ offenders = _async_items_missing_plugin(items)+ if not offenders:+ return+ raise pytest.UsageError(+ f"{len(offenders)} selected tests are 'async def' but pytest-asyncio is "+ 'not installed, so asyncio_mode="auto" is inactive and every one of them '+ "would fail as 'async def functions are not natively supported'. "+ "Install the dev dependency group (uv sync --group dev)."+ )diff --git a/tests/test_conftest_async_plugin_guard.py b/tests/test_conftest_async_plugin_guard.pynew file mode 100644index 000000000..46cb7d4e3--- /dev/null+++ b/tests/test_conftest_async_plugin_guard.py@@ -0,0 +1,114 @@+"""Regression guard: the missing-pytest-asyncio check must stay scoped to the+runs that actually select ``async def`` tests.++The first version of this guard was a ``required_plugins`` entry in the root+``pyproject.toml``. That key is a rootdir-wide prerequisite enforced *before*+collection, so it also aborted the two CI jobs that deliberately install only a+built artifact plus ``pytest`` and select synchronous tests only: the+packaged-test matrix in ``.github/workflows/lint.yml`` and the publish+finalizer in ``.github/workflows/publish.yml`` -- the repository's sole release+finalizer. Both died with "Missing required plugins: pytest-asyncio" before+running a single test.++These tests pin both directions: a synchronous selection with no async plugin+still collects, and an ``async def`` selection with no async plugin fails once,+naming the missing dependency rather than every test that would have failed.+"""++from __future__ import annotations++import subprocess+import sys+from pathlib import Path++import pytest++from tests.conftest import _async_items_missing_plugin++REPO_ROOT = Path(__file__).resolve().parents[1]++# One of the files the packaged-test and publish jobs select. Kept in sync with+# the workflows on purpose: if it ever grows an async test, those jobs need the+# plugin and this guard should not be what tells us.+SYNC_ONLY_CI_SELECTION = "tests/test_memory_distribution.py"+++class _FakeItem:+ def __init__(self, obj, *, anyio: bool = False, raises: bool = False):+ self._obj = obj+ self._anyio = anyio+ self._raises = raises++ @property+ def obj(self):+ if self._raises:+ raise RuntimeError("this collector has no test function")+ return self._obj++ def get_closest_marker(self, name: str):+ return object() if (name == "anyio" and self._anyio) else None+++async def _coroutine_test():+ pass+++def _sync_test():+ pass+++def test_plain_coroutine_items_are_reported() -> None:+ item = _FakeItem(_coroutine_test)+ assert _async_items_missing_plugin([item]) == [item]+++def test_anyio_marked_coroutines_are_not_reported() -> None:+ # anyio is a runtime dependency, so its plugin drives these wherever the+ # package installs -- flagging them would fire in environments that are fine.+ assert _async_items_missing_plugin([_FakeItem(_coroutine_test, anyio=True)]) == []+++def test_synchronous_items_are_not_reported() -> None:+ assert _async_items_missing_plugin([_FakeItem(_sync_test)]) == []+++def test_items_without_a_test_function_are_skipped() -> None:+ # Doctest and custom collectors raise on ``.obj``; the guard must not crash+ # the whole collection over one of them.+ assert _async_items_missing_plugin([_FakeItem(None, raises=True)]) == []+++def _collect(selection: str) -> subprocess.CompletedProcess:+ return subprocess.run(+ [+ sys.executable,+ "-m",+ "pytest",+ "-p",+ "no:asyncio",+ "--collect-only",+ "-q",+ selection,+ ],+ cwd=REPO_ROOT,+ capture_output=True,+ text=True,+ )++[email protected]_real_paths+def test_sync_only_ci_selection_still_collects_without_the_async_plugin() -> None:+ """The exact shape of the packaged-test and publish jobs must stay green."""+ result = _collect(SYNC_ONLY_CI_SELECTION)+ output = result.stdout + result.stderr+ assert result.returncode == 0, output+ assert "pytest-asyncio" not in output++[email protected]_real_paths+def test_async_selection_fails_once_naming_the_missing_plugin() -> None:+ result = _collect("tests/test_claude_agent_sessions.py")+ # pytest writes a UsageError raised from a hook to stderr, not stdout.+ output = result.stdout + result.stderr+ assert result.returncode == pytest.ExitCode.USAGE_ERROR, output+ assert "pytest-asyncio is not installed" in output