Coverage for tests / test_completion / test_completion_complete_rich.py: 100%
29 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
1import os 1abcdefgh
2import subprocess 1abcdefgh
3import sys 1abcdefgh
5from . import example_rich_tags as mod 1abcdefgh
8def test_script(): 1abcdefgh
9 result = subprocess.run( 1abcdefgh
10 [sys.executable, "-m", "coverage", "run", mod.__file__, "create", "DeadPool"],
11 capture_output=True,
12 encoding="utf-8",
13 )
14 assert result.returncode == 0 1abcdefgh
15 assert "Creating user: DeadPool" in result.stdout 1abcdefgh
17 result = subprocess.run( 1abcdefgh
18 [sys.executable, "-m", "coverage", "run", mod.__file__, "delete", "DeadPool"],
19 capture_output=True,
20 encoding="utf-8",
21 )
22 assert result.returncode == 0 1abcdefgh
23 assert "Deleting user: DeadPool" in result.stdout 1abcdefgh
25 result = subprocess.run( 1abcdefgh
26 [sys.executable, "-m", "coverage", "run", mod.__file__, "delete-all"],
27 capture_output=True,
28 encoding="utf-8",
29 )
30 assert result.returncode == 0 1abcdefgh
31 assert "Deleting all users" in result.stdout 1abcdefgh
34def test_completion_complete_subcommand_bash(): 1abcdefgh
35 result = subprocess.run( 1abcdefgh
36 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
37 capture_output=True,
38 encoding="utf-8",
39 env={
40 **os.environ,
41 "_EXAMPLE_RICH_TAGS.PY_COMPLETE": "complete_bash",
42 "COMP_WORDS": "example_rich_tags.py del",
43 "COMP_CWORD": "1",
44 },
45 )
46 assert "delete\ndelete-all" in result.stdout 1abcdefgh
49def test_completion_complete_subcommand_zsh(): 1abcdefgh
50 result = subprocess.run( 1abcdefgh
51 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
52 capture_output=True,
53 encoding="utf-8",
54 env={
55 **os.environ,
56 "_EXAMPLE_RICH_TAGS.PY_COMPLETE": "complete_zsh",
57 "_TYPER_COMPLETE_ARGS": "example_rich_tags.py del",
58 },
59 )
60 assert ( 1abcdefgh
61 """_arguments '*: :(("delete":"Delete a user with USERNAME."\n"""
62 """\"delete-all":"Delete ALL users in the database."))'"""
63 ) in result.stdout
66def test_completion_complete_subcommand_fish(): 1abcdefgh
67 result = subprocess.run( 1abcdefgh
68 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
69 capture_output=True,
70 encoding="utf-8",
71 env={
72 **os.environ,
73 "_EXAMPLE_RICH_TAGS.PY_COMPLETE": "complete_fish",
74 "_TYPER_COMPLETE_ARGS": "example_rich_tags.py del",
75 "_TYPER_COMPLETE_FISH_ACTION": "get-args",
76 },
77 )
78 assert ( 1abcdefgh
79 "delete\tDelete a user with USERNAME.\ndelete-all\tDelete ALL users in the database."
80 in result.stdout
81 )
84def test_completion_complete_subcommand_powershell(): 1abcdefgh
85 result = subprocess.run( 1abcdefgh
86 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
87 capture_output=True,
88 encoding="utf-8",
89 env={
90 **os.environ,
91 "_EXAMPLE_RICH_TAGS.PY_COMPLETE": "complete_powershell",
92 "_TYPER_COMPLETE_ARGS": "example_rich_tags.py del",
93 },
94 )
95 assert ( 1abcdefgh
96 "delete:::Delete a user with USERNAME.\ndelete-all:::Delete ALL users in the database."
97 ) in result.stdout
100def test_completion_complete_subcommand_pwsh(): 1abcdefgh
101 result = subprocess.run( 1abcdefgh
102 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
103 capture_output=True,
104 encoding="utf-8",
105 env={
106 **os.environ,
107 "_EXAMPLE_RICH_TAGS.PY_COMPLETE": "complete_pwsh",
108 "_TYPER_COMPLETE_ARGS": "example_rich_tags.py del",
109 },
110 )
111 assert ( 1abcdefgh
112 "delete:::Delete a user with USERNAME.\ndelete-all:::Delete ALL users in the database."
113 ) in result.stdout