Coverage for tests / unit / cli_utils / command_chainer / conftest.py: 90%

20 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Shared fixtures for CommandChainer tests.""" 

2 

3from __future__ import annotations 

4 

5import click 

6import pytest 

7 

8 

9@pytest.fixture 

10def mock_group() -> click.Group: 

11 """Create a mock Click group with test commands. 

12 

13 Returns: 

14 click.Group: A Click group with fmt, chk, and tst commands. 

15 """ 

16 

17 @click.group() 

18 def cli() -> None: 

19 """Test CLI group.""" 

20 pass 

21 

22 @cli.command(name="fmt") 

23 @click.argument("paths", nargs=-1) 

24 def fmt_cmd(paths: tuple[str, ...]) -> int: 

25 """Format command. 

26 

27 Args: 

28 paths: Paths to format. 

29 

30 Returns: 

31 int: Exit code (always 0). 

32 """ 

33 return 0 

34 

35 @cli.command(name="chk") 

36 @click.argument("paths", nargs=-1) 

37 def chk_cmd(paths: tuple[str, ...]) -> int: 

38 """Check command. 

39 

40 Args: 

41 paths: Paths to check. 

42 

43 Returns: 

44 int: Exit code (always 0). 

45 """ 

46 return 0 

47 

48 @cli.command(name="tst") 

49 def tst_cmd() -> int: 

50 """Test command. 

51 

52 Returns: 

53 int: Exit code (always 0). 

54 """ 

55 return 0 

56 

57 return cli