﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30927	Use assertWarnsMessage() in the example of deprecation warnings.	André Ericson	André Ericson	"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."	Cleanup/optimization	closed	Documentation	2.2	Normal	fixed			Accepted	1	0	0	0	0	0
