diff options
author | Anubhav Joshi <anubhav9042@gmail.com> | 2014-04-05 11:34:46 +0530 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2014-04-06 17:33:43 -0400 |
commit | cd914e31c9a889f18c50c15b4f6ee4959624001f (patch) | |
tree | 291036036473baaf6de621f66a6198ed4bc12451 /tests/deprecation | |
parent | d2f4553d705951ca8043d687f9493c559f494a0c (diff) | |
download | django-cd914e31c9a889f18c50c15b4f6ee4959624001f.tar.gz |
Fixed #21977 -- Deprecated SimpleTestCase.urls
Diffstat (limited to 'tests/deprecation')
-rw-r--r-- | tests/deprecation/tests.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py index 4d69963cfc..185971dffa 100644 --- a/tests/deprecation/tests.py +++ b/tests/deprecation/tests.py @@ -1,10 +1,13 @@ from __future__ import unicode_literals +import os +import unittest import warnings from django.test import SimpleTestCase, RequestFactory, override_settings from django.utils import six, translation from django.utils.deprecation import RenameMethodsBase +from django.utils.encoding import force_text from django.utils.functional import memoize @@ -220,3 +223,26 @@ class DeprecatingMemoizeTest(SimpleTestCase): self.assertEqual(msg, 'memoize wrapper is deprecated and will be removed in Django ' '1.9. Use django.utils.lru_cache instead.') + + +class DeprecatingSimpleTestCaseUrls(unittest.TestCase): + + def test_deprecation(self): + """ + Ensure the correct warning is raised when SimpleTestCase.urls is used. + """ + class TempTestCase(SimpleTestCase): + urls = 'tests.urls' + + def test(self): + pass + + with warnings.catch_warnings(record=True) as recorded: + suite = unittest.TestLoader().loadTestsFromTestCase(TempTestCase) + with open(os.devnull, 'w') as devnull: + unittest.TextTestRunner(stream=devnull, verbosity=2).run(suite) + msg = force_text(recorded.pop().message) + self.assertEqual(msg, + "SimpleTestCase.urls is deprecated and will be removed in " + "Django 2.0. Use @override_settings(ROOT_URLCONF=...) " + "in TempTestCase instead.") |