At DUTH this year I opened a ticket to add test-case assertions checking whether (or not) a signal was sent:
https://code.djangoproject.com/ticket/27447 And corresponding PR: https://github.com/django/django/pull/7508 The PR has gotten bogged down in API design discussion, so I'd like to hash that out here in hopes of landing this in time for 1.11 feature freeze. The patch currently provides two assertions: * assertSignalSent takes a signal and optionally a list of expected keyword arguments. It passes if the signal was sent and all expected arguments were present, and fails if the signal was not sent, or an expected argument was missing. It also functions as a context manager, allowing inspection of the values of the arguments (which are difficult to cleanly specify in the call signature of the assertion). * assertSignalNotSent takes a signal and passes if the signal is not sent, and fails if it was. The current discussion is mostly over the case of wanting assertSignalSent to also be able to distinguish how many *times* the signal was sent, perhaps assert a particular number of sends, and inspect each one individually. 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). -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CAL13Cg_w7nMaVqZ2dbh%3DcgqwG_c%3DGZxja4qPyDR_7_px-VrM%3DA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
