Coverage for pytest_beehave/reporter.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2026-04-21 04:49 +0000

1"""Terminal reporting for pytest-beehave actions.""" 

2 

3from __future__ import annotations 

4 

5from typing import Protocol 

6 

7from pytest_beehave.bootstrap import BootstrapResult 

8 

9 

10class TerminalWriterProtocol(Protocol): 

11 """Protocol for a terminal writer.""" 

12 

13 def line(self, text: str = "") -> None: # pragma: no cover 

14 """Write a line to the terminal.""" 

15 ... 

16 

17 

18def report_bootstrap(writer: TerminalWriterProtocol, result: BootstrapResult) -> None: 

19 """Report bootstrap actions to the terminal. 

20 

21 Args: 

22 writer: Terminal writer to write to. 

23 result: The bootstrap result. 

24 """ 

25 for name in result.created_subfolders: 

26 writer.line(f"[beehave] MKDIR {name}/") 

27 for path in result.migrated_files: 

28 writer.line(f"[beehave] MIGRATE {path}") 

29 for warning in result.collision_warnings: 

30 writer.line(f"[beehave] WARNING {warning}") 

31 

32 

33def report_id_write_back(writer: TerminalWriterProtocol, errors: list[str]) -> None: 

34 """Report ID write-back errors to the terminal. 

35 

36 Args: 

37 writer: Terminal writer to write to. 

38 errors: List of error strings from assign_ids. 

39 """ 

40 for error in errors: 

41 writer.line(f"[beehave] ERROR: {error}") 

42 

43 

44def report_sync_actions(writer: TerminalWriterProtocol, actions: list[str]) -> None: 

45 """Report sync actions to the terminal. 

46 

47 Args: 

48 writer: Terminal writer to write to. 

49 actions: List of action description strings. 

50 """ 

51 for action in actions: 

52 writer.line(f"[beehave] {action}")