#25188: inconsistent escaping in assertRaisesMessage test output
-------------------------------------+-------------------------------------
Reporter: cjerdonek | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.8
Severity: Normal | Resolution:
Keywords: assertRaisesMessage | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by cjerdonek):
Since only a plain string comparison is needed, is there a reason the
method needs to be using `assertRaisesRegex`? For example, couldn't the
implementation bypass `assertRaisesRegex` and go something like this?
(This is just an idea so shouldn't be taken as is.)
{{{#!python
@contextmanager
def assertRaisesMessage(self, expected_exception, expected_message):
with self.assertRaises(expected_exception) as cm:
yield
err = cm.exception
self.assertEqual(str(err), expected_message)
}}}
An implementation like this would have the further advantage that in the
case of a string mismatch the test output would show ''where'' the strings
differ by using unittest's `assertEqual`, which is better equipped for
this and has this added functionality.
--
Ticket URL: <https://code.djangoproject.com/ticket/25188#comment:2>
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/067.f34df05ef3d324a3bd8e210f59e3ec53%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.