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)

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

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by Tim Graham

Attachment: 23620.diff added

comment:1 Changed 9 years ago by averybigant

Owner: changed from nobody to averybigant
Status: newassigned

comment:2 Changed 9 years ago by Huu Nguyen

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

comment:3 Changed 9 years ago by Berker Peksag

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 Changed 9 years ago by Tim Graham

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

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

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