#33278: Use a custom exception type with django.test.testcases._DatabaseFailure
------------------------------------------------+------------------------
               Reporter:  Daniel Hahler         |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Testing framework     |        Version:  3.2
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 Currently an `AssertionError` with a message is used in case of blocked DB
 operations:
 {{{
 class _DatabaseFailure:
     def __init__(self, wrapped, message):
         self.wrapped = wrapped
         self.message = message

     def __call__(self):
         raise AssertionError(self.message)
 }}}
 
([https://github.com/django/django/blob/dfa1145a22042dcf9e504a5a7edd5557e3e0d07c/django/test/testcases.py#L142-L148
 source])

 Using a custom/distinctive exception type would allow for better catching
 and handling of this.
 Currently you would have to parse its {{{message}}} and/or look at the
 stack trace to see if it's this specific error, or a "normal" assertion
 error from a test.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33278>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.7441c1f30954ac502060b9c3814f9ab7%40djangoproject.com.

Reply via email to