Opened 9 years ago
Closed 9 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)
Changed 9 years ago by
Attachment: | 23620.diff added |
---|
comment:1 Changed 9 years ago by
Owner: | changed from nobody to averybigant |
---|---|
Status: | new → assigned |
comment:2 Changed 9 years ago by
Summary: | Use more specify assertions than assertTrue in tests → Use more specific assertions than assertTrue in tests |
---|
comment:3 Changed 9 years ago by
comment:5 Changed 9 years ago by
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?