Opened 10 years ago
Closed 10 years ago
#23620 closed Cleanup/optimization (fixed)
Use more specific assertions than assertTrue in tests
Reported by: | Tim Graham | Owned by: | averybigant |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
We should change things like self.assertTrue(fetched.active_translation.title == 'Otsikko')
to use assertEqual
and things like self.assertTrue('id' in form.fields)
to use assertIn
. Attaching an initial patch. I used grep -rI "assertTrue" * | grep ==
to find instances that need changing.
Attachments (1)
Change History (6)
by , 10 years ago
Attachment: | 23620.diff added |
---|
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 10 years ago
Summary: | Use more specify assertions than assertTrue in tests → Use more specific assertions than assertTrue in tests |
---|
comment:3 by , 10 years ago
comment:5 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
https://github.com/django/django/pull/3432
Should I create a new ticket for
assertFalse(a == b)
,assertFalse(a != b)
,assertFalse("foo" in a)
etc. instances?