Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add fix and test for 'triton' with no args #89

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/triton_cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,10 @@ def parse_args(argv=None):

argv_ = argv if argv is not None else sys.argv[1:]
# Add special argparse handling for passthrough to genai-perf CLI
if argv_[0] == "profile":
if len(argv_) > 1 and argv_[0] == "profile":
args, unknown_args = parser.parse_known_args(argv_)
args = add_unknown_args_to_args(args, unknown_args)
else:
args = parser.parse_args(argv_)

return args
11 changes: 11 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@


class TestRepo:
def test_noargs(self):
# Test that running 'triton' with no args will fail with a parsing error
# NOTE: pytest needs to be run with `--capture=sys` to read the output,
# so just assert the error code and exception type for now.
args = []
with pytest.raises(SystemExit) as excinfo:
TritonCommands._run_and_capture_stdout(args)

# argparse returns code 2 for error / missing arguments
assert excinfo.value.code == 2

@pytest.mark.parametrize("repo", TEST_REPOS)
def test_clear(self, repo):
TritonCommands._clear(repo)
Expand Down
Loading