[Django] #29363: Use unittest assertWarns methods instead of warnings.catch_warnings/simplefilter/assertions in the test suite.

5 views
Skip to first unread message

Django

unread,
Apr 25, 2018, 8:04:10 PM4/25/18
to django-...@googlegroups.com
#29363: Use unittest assertWarns methods instead of
warnings.catch_warnings/simplefilter/assertions in the test suite.
------------------------------------------------+------------------------
Reporter: Simon Charette | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 2.0
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 |
------------------------------------------------+------------------------
The `assertWarns` and `assertWarnsRegex` method have been introduced in
Python 3.2 and should remove a lot of boilerplate around warnings testing
in the test suite.

https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertWarns

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

Django

unread,
Apr 25, 2018, 8:04:21 PM4/25/18
to django-...@googlegroups.com
#29363: Use unittest assertWarns methods instead of
warnings.catch_warnings/simplefilter/assertions in the test suite.
-------------------------------------+-------------------------------------

Reporter: Simon Charette | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* easy: 0 => 1


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

Django

unread,
Apr 25, 2018, 11:06:49 PM4/25/18
to django-...@googlegroups.com
#29363: Use unittest assertWarns methods instead of
warnings.catch_warnings/simplefilter/assertions in the test suite.
--------------------------------------+------------------------------------

Reporter: Simon Charette | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

* stage: Unreviewed => Accepted


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

Django

unread,
Apr 27, 2018, 2:45:40 PM4/27/18
to django-...@googlegroups.com
#29363: Use unittest assertWarns methods instead of
warnings.catch_warnings/simplefilter/assertions in the test suite.
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Morgan
Type: | Aubert
Cleanup/optimization | Status: assigned

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

* owner: nobody => Morgan Aubert
* status: new => assigned


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

Django

unread,
Apr 27, 2018, 6:43:00 PM4/27/18
to django-...@googlegroups.com
#29363: Use unittest assertWarns methods instead of
warnings.catch_warnings/simplefilter/assertions in the test suite.
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Morgan
Type: | Aubert
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Morgan Aubert):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/9904 PR]

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

Django

unread,
May 9, 2018, 12:09:17 PM5/9/18
to django-...@googlegroups.com
#29363: Use unittest assertWarns methods instead of
warnings.catch_warnings/simplefilter/assertions in the test suite.
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Morgan
Type: | Aubert
Cleanup/optimization | Status: closed

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"704443acacf0dfbcb1c52df4b260585055754ce7" 704443ac]:
{{{
#!CommitTicketReference repository=""
revision="704443acacf0dfbcb1c52df4b260585055754ce7"
Fixed #29363 -- Added SimpleTestCase.assertWarnsMessage().
}}}

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

Reply all
Reply to author
Forward
0 new messages