forked from flashinfer-ai/flashinfer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_cmd_helpers.py
More file actions
29 lines (22 loc) · 914 Bytes
/
cli_cmd_helpers.py
File metadata and controls
29 lines (22 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from click.testing import CliRunner
from flashinfer.__main__ import cli
def _test_cmd_helper(cmd: list[str]):
"""
Helper for command tests
"""
runner = CliRunner()
result = runner.invoke(cli, cmd)
assert result.exit_code == 0, result.output
return result.output
def _assert_output_contains_all(output, *expected_strings):
"""Assert that output contains all expected strings."""
missing = [s for s in expected_strings if s not in output]
assert not missing, (
f"Missing strings in output: {missing}\n\nActual output:\n{output}"
)
def _assert_output_contains_any(output, *expected_strings):
"""Assert that output contains at least one of the expected strings."""
found = any(s in output for s in expected_strings)
assert found, (
f"None of the expected strings were found in output: {expected_strings}\n\nActual output:\n{output}"
)