Skip to content

Async fixture support #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions sphinx_autofixture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ def __init__(self) -> None:
#: If it is, the scope of the fixture.
self.scope = "function"

def visit_FunctionDef(self, node: ast.FunctionDef) -> None: # noqa: D102
def _visit(self, node: Union[ast.FunctionDef, ast.AsyncFunctionDef]) -> None: # noqa: D102
if node.decorator_list:
for deco in node.decorator_list:

if isinstance(deco, ast.Call):
keywords: Dict[Optional[str], ast.expr] = {k.arg: k.value for k in deco.keywords}

Expand Down Expand Up @@ -95,6 +94,12 @@ def visit_FunctionDef(self, node: ast.FunctionDef) -> None: # noqa: D102
else: # pragma: no cover
raise NotImplementedError(str(type(deco)))

def visit_FunctionDef(self, node: ast.FunctionDef) -> None: # noqa: D102
self._visit(node)

def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None: # noqa: D102
self._visit(node)


def is_fixture(function: Union[FunctionType, MethodType]) -> Tuple[bool, Optional[str]]:
"""
Expand Down