Hello,

On 3 Jan 2017, at 09:16, James Bennett <ubernost...@gmail.com> wrote:

> Personally I'm against trying to do this in assertSignalSent, and would argue 
> for a separate assertSignalSentMultiple if that use case is deemed important 
> enough; coming up with a unified API that cleanly handles both the case of a 
> signal send/inspection *and* also the case of multiple send/multiple 
> inspection, seems like it would be more complicated than it needs to be (and 
> having the assertion support two different behaviors for those cases seems 
> doubly so).


I agree that this sounds complicated and is better left out of scope for now.

To minimize cognitive load, we could mirror the unittest.mock APIs that perform 
the same function for mock calls. It provides:

- assert_called_with: succeeds if there’s at least one call and most recent 
call was made with the provided arguments
- assert_called_once_with: succeeds if there’s exactly one call and it was made 
with the provided arguments
- assert_any_call: succeeds if there’s at least one call with the provided 
arguments

assertSignalSent could work like assert_called_with. Later we can implement 
assertSignalSentOnce or other variants if needed.

If you prefer the semantics of assert_called_once_with or assert_any_call, 
that’s fine as well.

Regarding arguments, since signal receivers must accept **kwargs (that’s a 
document requirement), I think it’s acceptable for assertSignalSent to ignore 
unexpected arguments.

Best regards,

-- 
Aymeric.

-- 
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/65CC5742-C49E-4E14-81B7-B6F6FDA85E01%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to