[Django] #30927: Simplify example of test of deprecation warning.

5 views
Skip to first unread message

Django

unread,
Oct 29, 2019, 3:17:53 PM10/29/19
to django-...@googlegroups.com
#30927: Simplify example of test of deprecation warning.
-----------------------------------------+------------------------
Reporter: André Ericson | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 2.2
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 |
-----------------------------------------+------------------------
When adding deprecation warnings it's very likely that the documentation
(https://docs.djangoproject.com/en/2.2/internals/contributing/writing-code
/submitting-patches/#deprecating-a-feature) will be followed and the
example of the test for the assertion will be copied.


{{{
import warnings

def test_foo_deprecation_warning(self):
with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter('always') # prevent warnings from appearing
as errors
# invoke deprecated behavior

self.assertEqual(len(warns), 1)
msg = str(warns[0].message)
self.assertEqual(msg, 'Expected deprecation message')
}}}


This could be simplified as suggested here:
https://github.com/django/django/pull/11905#discussion_r334984986

My suggestion is that we change the documentation to avoid unnecessary
extra work.

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

Django

unread,
Oct 29, 2019, 3:18:07 PM10/29/19
to django-...@googlegroups.com
#30927: Simplify example of test of deprecation warning.
-------------------------------+-----------------------------------------
Reporter: André Ericson | Owner: André Ericson
Type: Uncategorized | Status: assigned
Component: Documentation | Version: 2.2
Severity: Normal | Resolution:

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

* owner: nobody => André Ericson
* status: new => assigned


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

Django

unread,
Oct 29, 2019, 3:26:53 PM10/29/19
to django-...@googlegroups.com
#30927: Simplify the example for the test of deprecation warnings.

-------------------------------+-----------------------------------------
Reporter: André Ericson | Owner: André Ericson
Type: Uncategorized | Status: assigned
Component: Documentation | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------

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

Django

unread,
Oct 30, 2019, 7:25:57 AM10/30/19
to django-...@googlegroups.com
#30927: Use assertWarnsMessage() in the example of deprecation warnings.
-------------------------------------+-------------------------------------

Reporter: André Ericson | Owner: André
Type: | Ericson
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 2.2
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 felixxm):

* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


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

Django

unread,
Oct 30, 2019, 7:28:35 AM10/30/19
to django-...@googlegroups.com
#30927: Use assertWarnsMessage() in the example of deprecation warnings.
-------------------------------------+-------------------------------------
Reporter: André Ericson | Owner: André
Type: | Ericson
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 2.2

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 felixxm):

* has_patch: 0 => 1


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

Django

unread,
Oct 30, 2019, 8:53:21 AM10/30/19
to django-...@googlegroups.com
#30927: Use assertWarnsMessage() in the example of deprecation warnings.
-------------------------------------+-------------------------------------
Reporter: André Ericson | Owner: André
Type: | Ericson
Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.2
Severity: Normal | Resolution: fixed
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 Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"54a7b021125d23a248e70ba17bf8b10bc8619234" 54a7b021]:
{{{
#!CommitTicketReference repository=""
revision="54a7b021125d23a248e70ba17bf8b10bc8619234"
Fixed #30927 -- Simplified an example of test for the deprecation warning
with assertWarnsMessage().
}}}

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

Django

unread,
Oct 30, 2019, 8:53:49 AM10/30/19
to django-...@googlegroups.com
#30927: Use assertWarnsMessage() in the example of deprecation warnings.
-------------------------------------+-------------------------------------
Reporter: André Ericson | Owner: André
Type: | Ericson
Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.2

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"3c5f8313c21f095feca8c44207e768fe0adfa0fa" 3c5f8313]:
{{{
#!CommitTicketReference repository=""
revision="3c5f8313c21f095feca8c44207e768fe0adfa0fa"
[3.0.x] Fixed #30927 -- Simplified an example of test for the deprecation
warning with assertWarnsMessage().

Backport of 54a7b021125d23a248e70ba17bf8b10bc8619234 from master
}}}

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

Django

unread,
Oct 30, 2019, 8:54:17 AM10/30/19
to django-...@googlegroups.com
#30927: Use assertWarnsMessage() in the example of deprecation warnings.
-------------------------------------+-------------------------------------
Reporter: André Ericson | Owner: André
Type: | Ericson
Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.2

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"972eef6b9060aee4a092bedee38a7775fbbe5d0b" 972eef6b]:
{{{
#!CommitTicketReference repository=""
revision="972eef6b9060aee4a092bedee38a7775fbbe5d0b"
[2.2.x] Fixed #30927 -- Simplified an example of test for the deprecation
warning with assertWarnsMessage().

Backport of 54a7b021125d23a248e70ba17bf8b10bc8619234 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages