-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
User Story
As a Django developer,
I want the linter boa restrictor to flag any usage of self.assertRaisesMessage
with an empty string as the expected message,
so that tests enforce meaningful error messages and avoid false positives.
Acceptance Criteria
-
Detection
- The linter must detect calls to
self.assertRaisesMessage
where the second argument is an empty string (""
). - Example (should be flagged):
self.assertRaisesMessage(ValueError, "")
- The linter must detect calls to
-
Non-Detection (Valid Cases)
- Calls where the second argument is a non-empty string must not be flagged.
self.assertRaisesMessage(ValueError, "Invalid input")
- Calls to other
assert*
methods (e.g.,self.assertRaises
,self.assertEqual
) must not be flagged. - Calls to
assertRaisesMessage
outside of Django’sTestCase
context may still be flagged (depending on implementation scope), but only empty strings should trigger the rule.
- Calls where the second argument is a non-empty string must not be flagged.
-
Error Message
- The linter should produce a clear error message such as:
boa restrictor: Do not use assertRaisesMessage with an empty string as the expected message.
- The linter should produce a clear error message such as:
-
Configurability
- The rule must be part of the Django-only ruleset and enabled only when Django checks are active.
-
Fix Guidance
- Documentation or autofix (if supported) should suggest replacing the empty string with either a meaningful message or using
self.assertRaises
if message matching is unnecessary.
- Documentation or autofix (if supported) should suggest replacing the empty string with either a meaningful message or using
Metadata
Metadata
Assignees
Labels
No labels