Skip to content

Commit 16f4a4f

Browse files
committed
tests(conftest): Add asyncio to doctest_namespace fixture
why: Make asyncio module available in doctests without explicit import what: - Add autouse doctest_namespace fixture - Inject asyncio module for use in async doctests
1 parent 8baa9de commit 16f4a4f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from __future__ import annotations
1212

13+
import asyncio
1314
import pathlib
1415
import typing as t
1516

@@ -80,3 +81,14 @@ def fn(
8081
return args, kws
8182

8283
return fn
84+
85+
86+
@pytest.fixture(autouse=True)
87+
def doctest_namespace(doctest_namespace: dict[str, t.Any]) -> dict[str, t.Any]:
88+
"""Inject common fixtures into doctest namespace.
89+
90+
Provides:
91+
- asyncio: The asyncio module for async doctests
92+
"""
93+
doctest_namespace["asyncio"] = asyncio
94+
return doctest_namespace

0 commit comments

Comments
 (0)