#24714: Tidy up usage of assertEqual in tests
-------------------------------------+-------------------------------------
Reporter: alasdairnicol | Owner:
Type: | alasdairnicol
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by alasdairnicol:
Old description:
> There are a few places in the tests where we are using self.assertEqual
> that could be more idiomatic.
>
> {{{
> self.assertEqual(None, x) # prefer self.assertIsNone(x)
> self.assertEqual(True, x in y) # prefer self.assertIn(x, y)
>
> self.assertEqual(True, x) # self.assertTrue(x) may be appropriate, but
> care is needed because it will pass for truthy values
> self.assertEqual(False, x) # prefer self.assertFalse(x) may be
> appropriate, but care is needed because it will pass for falsey values
> self.assertEqual(True, x == y) # prefer self.assertEqual(x, y)
> }}}
>
> I found these using the following greps
>
> {{{
> grep -rI assertEqual.True
> grep -rI assertEqual.False
> grep -rI assertEqual.None
> }}}
>
> This is a similar tidy up to #23620
New description:
There are a few places in the tests where we are using self.assertEqual
that could be more idiomatic.
{{{
self.assertEqual(None, x) # prefer self.assertIsNone(x)
self.assertEqual(True, x in y) # prefer self.assertIn(x, y)
self.assertEqual(True, x) # self.assertTrue(x) may be appropriate, but
care is needed because it will pass for truthy values
self.assertEqual(False, x) # self.assertFalse(x) may be appropriate, but
care is needed because it will pass for falsey values
self.assertEqual(True, x == y) # prefer self.assertEqual(x, y)
}}}
I found these using the following greps
{{{
grep -rI assertEqual.True
grep -rI assertEqual.False
grep -rI assertEqual.None
}}}
This is a similar tidy up to #23620
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24714#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/071.c28915db08823811966013ea8d9e9c8a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.