Opened 10 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)

23620.diff (2.9 KB ) - added by Tim Graham 10 years ago.

Download all attachments as: .zip

Change History (6)

by Tim Graham, 10 years ago

Attachment: 23620.diff added

comment:1 by averybigant, 10 years ago

Owner: changed from nobody to averybigant
Status: newassigned

comment:2 by Huu Nguyen, 9 years ago

Summary: Use more specify assertions than assertTrue in testsUse more specific assertions than assertTrue in tests

comment:3 by Berker Peksag, 9 years ago

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?

comment:4 by Tim Graham, 9 years ago

You can include those changes as part of this ticket, thanks.

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In f7969b0920c403118656f6bfec58d6454d79ef1a:

Fixed #23620 -- Used more specific assertions in the Django test suite.

Note: See TracTickets for help on using tickets.
Back to Top