Skip to content

Fix misleading test assertion in test_cli.py: replace pytest.raises(Exception) around assert with direct exit_code check #359

Description

@coderabbitai

Summary

In numbast/src/numbast/experimental/mlir/tools/tests/test_cli.py (lines 82–83), the test test_cli_yml_invalid_inputs uses the following anti-pattern:

with pytest.raises(Exception):
    assert result.exit_code == 0

This passes by catching the AssertionError raised when the exit code is non-zero, which can mask actual failures (e.g., the CLI crashing with an unexpected exception rather than returning a non-zero exit code for the expected reason).

Suggested Fix

Replace the block with direct assertions:

assert result.exit_code != 0
assert result.exception is not None

References

Requested by @isVoid.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions