#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:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+------------------------------------

Comment (by cjerdonek):

 What about something like this?

 {{{#!python
 @contextmanager
 def _assert_raises_message_cm(self, expected_exception, expected_message):
     with self.assertRaises(expected_exception) as cm:
         yield cm
     err = cm.exception
     self.assertEqual(str(err), expected_message)

 def assertRaisesMessage(self, expected_exception, expected_message,
 _callable=None, *args, **kwargs):
     cm = self._assert_raises_message_cm(expected_exception,
 expected_message)
     if _callable is None:
         # Then return the context manager.
         return cm
     # Otherwise, call the callable inside the context manager.
     with cm:
         _callable(*args, **kwargs)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25188#comment:4>
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.f44426b29a9e95d614dcde803937d649%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to