Skip to content
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

Argument(s) {'results', 'exit_code'} are declared in the hookimpl but can not be found in the hookspec #369

Open
nonamethanks opened this issue Mar 2, 2023 · 0 comments

Comments

@nonamethanks
Copy link

nonamethanks commented Mar 2, 2023

The example for after_session hooks from the documentation doesn't work. https://ward.readthedocs.io/en/latest/guide/plugins.html

from typing import Optional, List

from rich.console import RenderResult, Console, ConsoleOptions, ConsoleRenderable
from rich.panel import Panel
from rich.text import Text
from ward.config import Config
from ward.hooks import hook
from ward.models import ExitCode
from ward.testing import TestResult


@hook
def after_session(
    config: Config, results: List[TestResult], exit_code: ExitCode
) -> Optional[ConsoleRenderable]:
    return SummaryPanel(test_results)


class SummaryPanel:
    def __init__(self, results: List[TestResult]):
        self.results = results

    @property
    def time_taken(self):
        return sum(r.test.timer.duration for r in self.results)

    def __rich_console__(
        self, console: Console, console_options: ConsoleOptions
    ) -> RenderResult:
        yield Panel(
            Text(f"Hello from `after_session`! We ran {len(self.results)} tests!")
        )

Even after fixing the stray "test_results" in after_session, this raises

hookimpl definition: after_session(config: ward.config.Config, results: List[ward.testing.TestResult], exit_code: ward.models.ExitCode) -> Optional[rich.console.ConsoleRenderable]
Argument(s) {'results', 'exit_code'} are declared in the hookimpl but can not be found in the hookspec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant