[Django] #27447: Provide an easy way to test sending of signals

25 views
Skip to first unread message

Django

unread,
Nov 5, 2016, 12:10:33 PM11/5/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
---------------------------------------------+------------------------
Reporter: James Bennett | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: 1.10
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, 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...
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27447>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 5, 2016, 12:14:13 PM11/5/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-----------------------------------+------------------------------------

Reporter: James Bennett | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Josh Smeaton):

* version: 1.10 => master
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:1>

Django

unread,
Nov 5, 2016, 12:29:51 PM11/5/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-------------------------------------+-------------------------------------
Reporter: James Bennett | Owner: James
| Bennett
Type: New feature | Status: assigned

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by James Bennett):

* status: new => assigned
* owner: nobody => James Bennett


--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:2>

Django

unread,
Nov 5, 2016, 4:43:17 PM11/5/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-------------------------------------+-------------------------------------
Reporter: James Bennett | Owner: James
| Bennett
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


Comment:

WIP [https://github.com/django/django/pull/7508 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:3>

Django

unread,
Nov 7, 2016, 7:45:11 PM11/7/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-------------------------------------+-------------------------------------
Reporter: James Bennett | Owner: James
| Bennett
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by James Bennett):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:4>

Django

unread,
Nov 7, 2016, 7:47:33 PM11/7/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-------------------------------------+-------------------------------------
Reporter: James Bennett | Owner: James
| Bennett
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by James Bennett):

* stage: Ready for checkin => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:5>

Django

unread,
Nov 7, 2016, 11:14:18 PM11/7/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-------------------------------------+-------------------------------------
Reporter: James Bennett | Owner: James
| Bennett
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by James Bennett):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:6>

Django

unread,
Nov 8, 2016, 1:13:01 PM11/8/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-------------------------------------+-------------------------------------
Reporter: James Bennett | Owner: James
| Bennett
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_better_patch: 1 => 0


* stage: Ready for checkin => Accepted


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:7>

Django

unread,
Nov 8, 2016, 11:53:16 PM11/8/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-------------------------------------+-------------------------------------
Reporter: James Bennett | Owner: James
| Bennett
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by James Bennett):

* stage: Accepted => Ready for checkin


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:8>

Django

unread,
Nov 10, 2016, 9:59:30 AM11/10/16
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-------------------------------------+-------------------------------------
Reporter: James Bennett | Owner: James
| Bennett
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1

* stage: Ready for checkin => Accepted


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:9>

Django

unread,
Mar 21, 2023, 5:33:40 AM3/21/23
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-----------------------------------+------------------------------------
Reporter: James Bennett | Owner: (none)

Type: New feature | Status: new
Component: Testing framework | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* owner: James Bennett => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:10>

Django

unread,
Mar 18, 2024, 2:58:26 AM3/18/24
to django-...@googlegroups.com
#27447: Provide an easy way to test sending of signals
-----------------------------------+------------------------------------
Reporter: James Bennett | Owner: (none)
Type: New feature | Status: new
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Ülgen Sarıkavak):

* cc: Ülgen Sarıkavak (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/27447#comment:11>
Reply all
Reply to author
Forward
0 new messages