On Sunday, April 9, 2017 at 3:24:42 PM UTC+2, Josh Smeaton wrote:
>
> We throw lots of ValueErrors and TypeErrors rather than creating new 
> exception types all over the place. There's definitely an argument to be 
> made that different exception types can be created. But I know that I've 
> definitely run afoul of believing I was testing one error (assertRaises) 
> when I wasn't. A different ValueError was being caught and the test was 
> incorrectly passing. I would prefer assertRaises[Message|Regex] for 
> verifying the location of the error (not the exact string) where it makes 
> sense, and a simple assertRaises where the behaviour is immediately clear.
>

There are quite a lot of these calls. I noticed that tests don't always 
inherit from django.test.TestCase and thus assertRaisesMessage is not 
available.
I'm not sure if this PR should be exhaustive. I've added the message to all 
instances of some exceptions, but TypeError/ValueError (as highlighted by 
Josh Smeaton) are all over the place.

While working at this, I noticed this inconsistency (I think the same check 
should be in the base-backend).
https://github.com/django/django/blob/master/django/db/backends/sqlite3/operations.py#L262-L263
https://github.com/django/django/blob/master/tests/expressions/tests.py#L1164-L1166

~ Mads

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/7ffd9419-d593-41c3-aff9-5128059a0cb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to