diff options
author | Simon Charette <charette.s@gmail.com> | 2015-11-13 15:54:05 -0500 |
---|---|---|
committer | Simon Charette <charette.s@gmail.com> | 2015-11-14 11:33:28 -0500 |
commit | 1c5f4e86bc9c7bae5d5f3830d9cfbb0043297261 (patch) | |
tree | fe79a6afb78716fad02cd0659f336e459b1576b6 /tests/apps | |
parent | d95b22bd56764c71047ec16f628c00c0fd997cfd (diff) | |
download | django-1c5f4e86bc9c7bae5d5f3830d9cfbb0043297261.tar.gz |
Fixed #25745 -- Promoted RuntimeWarnings to errors in the test suite.
Diffstat (limited to 'tests/apps')
-rw-r--r-- | tests/apps/tests.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/tests/apps/tests.py b/tests/apps/tests.py index c226bf5010..9dad3cfb86 100644 --- a/tests/apps/tests.py +++ b/tests/apps/tests.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals import os -import warnings from unittest import skipUnless from django.apps import AppConfig, apps @@ -232,14 +231,13 @@ class AppsTests(SimpleTestCase): body = {} body['Meta'] = type(str("Meta"), tuple(), meta_contents) body['__module__'] = TotallyNormal.__module__ - with warnings.catch_warnings(record=True) as w: + msg = ( + "Model 'apps.southponies' was already registered. " + "Reloading models is not advised as it can lead to inconsistencies, " + "most notably with related models." + ) + with self.assertRaisesMessage(RuntimeWarning, msg): type(str("SouthPonies"), (models.Model,), body) - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) - self.assertEqual(str(w[-1].message), - "Model 'apps.southponies' was already registered. " - "Reloading models is not advised as it can lead to inconsistencies, " - "most notably with related models.") # If it doesn't appear to be a reloaded module then we expect # a RuntimeError. |