Opened 8 years ago

Last modified 8 months ago

#27447 new New feature

Provide an easy way to test sending of signals

Reported by: James Bennett Owned by:
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Ülgen Sarıkavak Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Currently, when writing tests for an application that sends signals, there's no easy built-in way to test the sending of signals.

A simple solution would be to add a context-manager assertion that can check a signal was sent and received keyword arguments with certain names, and then further inspection of the received arguments could be done inside the with block. For example:

with self.AssertSignalSent(some_signal, required_kwargs=['my_kwarg']):
    # ...do stuff...

Change History (9)

comment:1 by Josh Smeaton, 8 years ago

Triage Stage: UnreviewedAccepted
Version: 1.10master

comment:2 by James Bennett, 8 years ago

Owner: changed from nobody to James Bennett
Status: newassigned

comment:3 by Tim Graham, 8 years ago

Has patch: set
Patch needs improvement: set

WIP PR

comment:6 by James Bennett, 8 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Simon Charette, 8 years ago

Patch needs improvement: unset
Triage Stage: Ready for checkinAccepted

The code is looking good. Let's wait for a documentation review from a native speaker.

comment:8 by James Bennett, 8 years ago

Triage Stage: AcceptedReady for checkin

We're now at four other members of -core reviewed, all concerns addressed. Speak now or implement fixes for your critique later.

comment:9 by Tim Graham, 8 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

I left some comments on the PR. When James is finished with the updates, I'll add a commit to the branch that makes use of this assertion in Django's test suite.

comment:10 by Mariusz Felisiak, 20 months ago

Owner: James Bennett removed
Status: assignednew

comment:11 by Ülgen Sarıkavak, 8 months ago

Cc: Ülgen Sarıkavak added
Note: See TracTickets for help on using tickets.
Back to Top