ward
ward copied to clipboard
Argument(s) {'results', 'exit_code'} are declared in the hookimpl but can not be found in the hookspec
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