Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed #21977 -- Deprecated SimpleTestCase.urls in favour of override_settings #2517

Closed
wants to merge 1 commit into from

3 participants

@coder9042

Replaced SimpleTestCase.urls with @override_settings(...).
Added warning in the function.
Updated the docs.

@coder9042

Updated PR as suggested on IRC.
Added test.

Thanks @loic for help.

tests/deprecation/tests.py
((10 lines not shown))
+ """
+ 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 = str(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.")
@loic Collaborator
loic added a note

Missing blank line at the end of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tests/deprecation/tests.py
((6 lines not shown))
+
+ 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 = str(recorded.pop().message)
@loic Collaborator
loic added a note

I'd use force_text() instead, it's safer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/internals/deprecation.txt
@@ -20,6 +20,9 @@ about each item can often be found in the release notes of two versions prior.
* Support for the ``prefix`` argument to
``django.conf.urls.i18n.i18n_patterns()`` will be removed.
+* ``SimpleTestCase.urls`` will be removed in favour of
@timgraham Owner

I think you can remove "in favor of ...." since we usually don't include the upgrade notes in this timeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/releases/1.8.txt
@@ -256,6 +256,14 @@ Updating your code is as simple as ensuring that ``urlpatterns`` is a list of
url('^other/$', views.otherview),
]
+``django.test.SimpleTestCase.urls``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The attribute :attr:`SimpleTestCase.urls <django.test.SimpleTestCase.urls>`
+for specifying URLconf configuration in tests has now been deprecated in
+favour of :func:`~django.test.override_settings`. The attribute will be removed
@timgraham Owner

favour->favor
mention override_settings(ROOT_URLCONF=...) here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
docs/topics/testing/tools.txt
@@ -961,6 +961,10 @@ URLconf configuration
.. attribute:: SimpleTestCase.urls
+.. deprecated:: 1.8
+
+ Use :func:`~django.test.override_settings` for URLconf configuration.
@timgraham Owner

override_settings(ROOT_URLCONF=...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tests/urlpatterns_reverse/tests.py
((5 lines not shown))
def test_404_tried_urls_have_names(self):
"""
Verifies that the list of URLs that come back from a Resolver404
exception contains a list in the right format for printing out in
the DEBUG 404 page with both the patterns and URL names, if available.
"""
- urls = 'urlpatterns_reverse.named_urls'
@timgraham Owner

I think this is just a local variable and not using the deprecation behavior in which case we don't need to change it, correct?

Yes. Changes reverted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham
Owner
$ flake8
./tests/deprecation/tests.py:227:1: E302 expected 2 blank lines, found 1
./tests/deprecation/tests.py:242:80: W291 trailing whitespace
@coder9042

@timgraham
PR updated.
Any other changes required?

@timgraham timgraham commented on the diff
django/test/testcases.py
@@ -202,6 +204,11 @@ def _pre_setup(self):
def _urlconf_setup(self):
set_urlconf(None)
if hasattr(self, 'urls'):
+ warnings.warn(
+ "SimpleTestCase.urls is deprecated and will be removed in"
@timgraham Owner

Just missing spaces at the end of these strings - I've added them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham
Owner

merged in cd914e3.

@timgraham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 338 additions and 295 deletions.
  1. +1 −1  django/contrib/auth/tests/test_context_processors.py
  2. +2 −2 django/contrib/auth/tests/test_decorators.py
  3. +2 −2 django/contrib/auth/tests/test_remote_user.py
  4. +3 −2 django/contrib/auth/tests/test_signals.py
  5. +1 −1  django/contrib/auth/tests/test_templates.py
  6. +3 −3 django/contrib/auth/tests/test_views.py
  7. +1 −1  django/contrib/flatpages/tests/test_csrf.py
  8. +2 −2 django/contrib/flatpages/tests/test_middleware.py
  9. +1 −1  django/contrib/flatpages/tests/test_templatetags.py
  10. +2 −2 django/contrib/flatpages/tests/test_views.py
  11. +1 −1  django/contrib/formtools/tests/tests.py
  12. +5 −3 django/contrib/formtools/tests/wizard/namedwizardtests/tests.py
  13. +4 −3 django/contrib/formtools/tests/wizard/wizardtests/tests.py
  14. +2 −2 django/contrib/gis/tests/geoadmin/tests.py
  15. +2 −3 django/contrib/gis/tests/geoapp/test_feeds.py
  16. +2 −3 django/contrib/gis/tests/geoapp/test_sitemaps.py
  17. +1 −1  django/contrib/messages/tests/base.py
  18. +2 −2 django/contrib/messages/tests/test_mixins.py
  19. +2 −2 django/contrib/sitemaps/tests/base.py
  20. +1 −1  django/contrib/sitemaps/tests/test_https.py
  21. +7 −0 django/test/testcases.py
  22. +2 −0  docs/internals/deprecation.txt
  23. +9 −0 docs/releases/1.8.txt
  24. +5 −0 docs/topics/testing/tools.txt
  25. +3 −3 tests/admin_changelist/tests.py
  26. +4 −4 tests/admin_custom_urls/tests.py
  27. +8 −8 tests/admin_docs/tests.py
  28. +10 −10 tests/admin_inlines/tests.py
  29. +2 −2 tests/admin_scripts/tests.py
  30. +75 −77 tests/admin_views/tests.py
  31. +18 −18 tests/admin_widgets/tests.py
  32. +1 −1  tests/cache/tests.py
  33. +2 −2 tests/conditional_processing/tests.py
  34. +1 −1  tests/contenttypes_tests/tests.py
  35. +2 −3 tests/context_processors/tests.py
  36. +26 −0 tests/deprecation/tests.py
  37. +1 −1  tests/file_storage/tests.py
  38. +1 −2  tests/file_uploads/tests.py
  39. +1 −1  tests/forms_tests/tests/test_widgets.py
  40. +8 −8 tests/generic_inline_admin/tests.py
  41. +3 −3 tests/generic_views/test_base.py
  42. +6 −6 tests/generic_views/test_dates.py
  43. +2 −2 tests/generic_views/test_detail.py
  44. +5 −5 tests/generic_views/test_edit.py
  45. +1 −1  tests/generic_views/test_list.py
  46. +3 −3 tests/handlers/tests.py
  47. +3 −3 tests/i18n/patterns/tests.py
  48. +2 −4 tests/i18n/tests.py
  49. +1 −3 tests/logging_tests/tests.py
  50. +2 −2 tests/middleware/tests.py
  51. +2 −2 tests/middleware_exceptions/tests.py
  52. +2 −2 tests/model_permalink/tests.py
  53. +2 −2 tests/proxy_models/tests.py
  54. +2 −2 tests/resolve_url/tests.py
  55. +1 −1  tests/servers/tests.py
  56. +2 −2 tests/staticfiles_tests/tests.py
  57. +2 −2 tests/syndication_tests/tests.py
  58. +4 −4 tests/template_tests/test_response.py
  59. +1 −1  tests/template_tests/tests.py
  60. +5 −5 tests/test_client/tests.py
  61. +28 −28 tests/test_client_regress/tests.py
  62. +4 −4 tests/test_utils/tests.py
  63. +2 −2 tests/timezones/tests.py
  64. +11 −10 tests/urlpatterns_reverse/tests.py
  65. +1 −1  tests/view_tests/tests/test_csrf.py
  66. +3 −3 tests/view_tests/tests/test_debug.py
  67. +1 −1  tests/view_tests/tests/test_defaults.py
  68. +4 −4 tests/view_tests/tests/test_i18n.py
  69. +2 −2 tests/view_tests/tests/test_json.py
  70. +1 −1  tests/view_tests/tests/test_shortcuts.py
  71. +2 −2 tests/view_tests/tests/test_specials.py
  72. +1 −2  tests/view_tests/tests/test_static.py
  73. +1 −1  tests/wsgi/tests.py
View
2  django/contrib/auth/tests/test_context_processors.py
@@ -66,6 +66,7 @@ def test_permlookupdict_in(self):
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
),
+ ROOT_URLCONF='django.contrib.auth.tests.urls',
USE_TZ=False, # required for loading the fixture
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
)
@@ -73,7 +74,6 @@ class AuthContextProcessorTests(TestCase):
"""
Tests for the ``django.contrib.auth.context_processors.auth`` processor
"""
- urls = 'django.contrib.auth.tests.urls'
fixtures = ['context-processors-users.xml']
@override_settings(
View
4 django/contrib/auth/tests/test_decorators.py
@@ -5,16 +5,16 @@
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
-from django.test import TestCase
+from django.test import TestCase, override_settings
from django.test.client import RequestFactory
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.auth.tests.urls')
class LoginRequiredTestCase(AuthViewsTestCase):
"""
Tests the login_required decorators
"""
- urls = 'django.contrib.auth.tests.urls'
def testCallable(self):
"""
View
4 django/contrib/auth/tests/test_remote_user.py
@@ -6,14 +6,14 @@
from django.contrib.auth.middleware import RemoteUserMiddleware
from django.contrib.auth.models import User
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.test import TestCase
+from django.test import TestCase, override_settings
from django.utils import timezone
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.auth.tests.urls')
class RemoteUserTest(TestCase):
- urls = 'django.contrib.auth.tests.urls'
middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware'
backend = 'django.contrib.auth.backends.RemoteUserBackend'
header = 'REMOTE_USER'
View
5 django/contrib/auth/tests/test_signals.py
@@ -7,9 +7,10 @@
@skipIfCustomUser
-@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(USE_TZ=False,
+ PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='django.contrib.auth.tests.urls')
class SignalTestCase(TestCase):
- urls = 'django.contrib.auth.tests.urls'
fixtures = ['authtestdata.json']
def listener_login(self, user, **kwargs):
View
2  django/contrib/auth/tests/test_templates.py
@@ -15,9 +15,9 @@
@skipIfCustomUser
@override_settings(
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='django.contrib.auth.tests.urls',
)
class AuthTemplateTests(TestCase):
- urls = 'django.contrib.auth.tests.urls'
def test_titles(self):
rf = RequestFactory()
View
6 django/contrib/auth/tests/test_views.py
@@ -41,13 +41,13 @@
),
USE_TZ=False,
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='django.contrib.auth.tests.urls',
)
class AuthViewsTestCase(TestCase):
"""
Helper base class for all the follow test cases.
"""
fixtures = ['authtestdata.json']
- urls = 'django.contrib.auth.tests.urls'
def login(self, password='password'):
response = self.client.post('/login/', {
@@ -86,8 +86,8 @@ def assertURLEqual(self, url, expected, parse_qs=False):
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.auth.urls')
class AuthViewNamedURLTests(AuthViewsTestCase):
- urls = 'django.contrib.auth.urls'
def test_named_urls(self):
"Named URLs should be reversible"
@@ -732,9 +732,9 @@ def test_logout_preserve_language(self):
@skipIfCustomUser
@override_settings(
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='django.contrib.auth.tests.urls_admin',
)
class ChangelistTests(AuthViewsTestCase):
- urls = 'django.contrib.auth.tests.urls_admin'
def setUp(self):
# Make me a superuser before logging in.
View
2  django/contrib/flatpages/tests/test_csrf.py
@@ -15,6 +15,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
),
+ ROOT_URLCONF='django.contrib.flatpages.tests.urls',
CSRF_FAILURE_VIEW='django.views.csrf.csrf_failure',
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(__file__), 'templates'),
@@ -23,7 +24,6 @@
)
class FlatpageCSRFTests(TestCase):
fixtures = ['sample_flatpages', 'example_site']
- urls = 'django.contrib.flatpages.tests.urls'
def setUp(self):
self.client = Client(enforce_csrf_checks=True)
View
4 django/contrib/flatpages/tests/test_middleware.py
@@ -16,6 +16,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
),
+ ROOT_URLCONF='django.contrib.flatpages.tests.urls',
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(__file__), 'templates'),
),
@@ -23,7 +24,6 @@
)
class FlatpageMiddlewareTests(TestCase):
fixtures = ['sample_flatpages', 'example_site']
- urls = 'django.contrib.flatpages.tests.urls'
def test_view_flatpage(self):
"A flatpage can be served through a view, even when the middleware is in use"
@@ -96,6 +96,7 @@ def test_fallback_flatpage_special_chars(self):
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
),
+ ROOT_URLCONF='django.contrib.flatpages.tests.urls',
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(__file__), 'templates'),
),
@@ -103,7 +104,6 @@ def test_fallback_flatpage_special_chars(self):
)
class FlatpageMiddlewareAppendSlashTests(TestCase):
fixtures = ['sample_flatpages', 'example_site']
- urls = 'django.contrib.flatpages.tests.urls'
def test_redirect_view_flatpage(self):
"A flatpage can be served through a view and should add a slash"
View
2  django/contrib/flatpages/tests/test_templatetags.py
@@ -14,6 +14,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
),
+ ROOT_URLCONF='django.contrib.flatpages.tests.urls',
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(__file__), 'templates'),
),
@@ -21,7 +22,6 @@
)
class FlatpageTemplateTagTests(TestCase):
fixtures = ['sample_flatpages']
- urls = 'django.contrib.flatpages.tests.urls'
def test_get_flatpages_tag(self):
"The flatpage template tag retrives unregistered prefixed flatpages by default"
View
4 django/contrib/flatpages/tests/test_views.py
@@ -16,6 +16,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
# no 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
),
+ ROOT_URLCONF='django.contrib.flatpages.tests.urls',
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(__file__), 'templates'),
),
@@ -23,7 +24,6 @@
)
class FlatpageViewTests(TestCase):
fixtures = ['sample_flatpages', 'example_site']
- urls = 'django.contrib.flatpages.tests.urls'
def test_view_flatpage(self):
"A flatpage can be served through a view"
@@ -84,6 +84,7 @@ def test_view_flatpage_special_chars(self):
'django.contrib.messages.middleware.MessageMiddleware',
# no 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
),
+ ROOT_URLCONF='django.contrib.flatpages.tests.urls',
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(__file__), 'templates'),
),
@@ -91,7 +92,6 @@ def test_view_flatpage_special_chars(self):
)
class FlatpageViewAppendSlashTests(TestCase):
fixtures = ['sample_flatpages', 'example_site']
- urls = 'django.contrib.flatpages.tests.urls'
def test_redirect_view_flatpage(self):
"A flatpage can be served through a view and should add a slash"
View
2  django/contrib/formtools/tests/tests.py
@@ -36,9 +36,9 @@ def done(self, request, cleaned_data):
TEMPLATE_DIRS=(
os.path.join(os.path.dirname(upath(__file__)), 'templates'),
),
+ ROOT_URLCONF='django.contrib.formtools.tests.urls',
)
class PreviewTests(TestCase):
- urls = 'django.contrib.formtools.tests.urls'
def setUp(self):
super(PreviewTests, self).setUp()
View
8 django/contrib/formtools/tests/wizard/namedwizardtests/tests.py
@@ -2,7 +2,7 @@
from django.core.urlresolvers import reverse
from django.http import QueryDict
-from django.test import TestCase
+from django.test import TestCase, override_settings
from django.contrib.auth.models import User
from django.contrib.auth.tests.utils import skipIfCustomUser
@@ -13,7 +13,6 @@
class NamedWizardTests(object):
- urls = 'django.contrib.formtools.tests.wizard.namedwizardtests.urls'
def setUp(self):
self.testuser, created = User.objects.get_or_create(username='testuser1')
@@ -283,6 +282,7 @@ def test_form_reset(self):
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.formtools.tests.wizard.namedwizardtests.urls')
class NamedSessionWizardTests(NamedWizardTests, TestCase):
wizard_urlname = 'nwiz_session'
wizard_step_1_data = {
@@ -315,6 +315,7 @@ class NamedSessionWizardTests(NamedWizardTests, TestCase):
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.formtools.tests.wizard.namedwizardtests.urls')
class NamedCookieWizardTests(NamedWizardTests, TestCase):
wizard_urlname = 'nwiz_cookie'
wizard_step_1_data = {
@@ -347,7 +348,6 @@ class NamedCookieWizardTests(NamedWizardTests, TestCase):
class NamedFormTests(object):
- urls = 'django.contrib.formtools.tests.wizard.namedwizardtests.urls'
def test_revalidation(self):
request = get_request()
@@ -376,12 +376,14 @@ def dispatch(self, request, *args, **kwargs):
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.formtools.tests.wizard.namedwizardtests.urls')
class NamedSessionFormTests(NamedFormTests, TestCase):
formwizard_class = TestNamedUrlSessionWizardView
wizard_urlname = 'nwiz_session'
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.formtools.tests.wizard.namedwizardtests.urls')
class NamedCookieFormTests(NamedFormTests, TestCase):
formwizard_class = TestNamedUrlCookieWizardView
wizard_urlname = 'nwiz_cookie'
View
7 django/contrib/formtools/tests/wizard/wizardtests/tests.py
@@ -3,7 +3,7 @@
import os
from django import forms
-from django.test import TestCase
+from django.test import TestCase, override_settings
from django.test.client import RequestFactory
from django.conf import settings
from django.contrib.auth.models import User
@@ -24,7 +24,6 @@ class Meta:
class WizardTests(object):
- urls = 'django.contrib.formtools.tests.wizard.wizardtests.urls'
def setUp(self):
self.testuser, created = User.objects.get_or_create(username='testuser1')
@@ -208,6 +207,7 @@ def test_form_refresh(self):
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.formtools.tests.wizard.wizardtests.urls')
class SessionWizardTests(WizardTests, TestCase):
wizard_url = '/wiz_session/'
wizard_step_1_data = {
@@ -240,6 +240,7 @@ class SessionWizardTests(WizardTests, TestCase):
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.formtools.tests.wizard.wizardtests.urls')
class CookieWizardTests(WizardTests, TestCase):
wizard_url = '/wiz_cookie/'
wizard_step_1_data = {
@@ -272,6 +273,7 @@ class CookieWizardTests(WizardTests, TestCase):
@skipIfCustomUser
+@override_settings(ROOT_URLCONF='django.contrib.formtools.tests.wizard.wizardtests.urls')
class WizardTestKwargs(TestCase):
wizard_url = '/wiz_other_template/'
wizard_step_1_data = {
@@ -301,7 +303,6 @@ class WizardTestKwargs(TestCase):
'cookie_contact_wizard-current_step': 'form4',
}
)
- urls = 'django.contrib.formtools.tests.wizard.wizardtests.urls'
def setUp(self):
self.testuser, created = User.objects.get_or_create(username='testuser1')
View
4 django/contrib/gis/tests/geoadmin/tests.py
@@ -4,7 +4,7 @@
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
-from django.test import TestCase
+from django.test import TestCase, override_settings
if HAS_GEOS and HAS_SPATIAL_DB:
from django.contrib.gis import admin
@@ -14,8 +14,8 @@
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
+@override_settings(ROOT_URLCONF='django.contrib.gis.tests.geoadmin.urls')
class GeoAdminTest(TestCase):
- urls = 'django.contrib.gis.tests.geoadmin.urls'
def test_ensure_geographic_media(self):
geoadmin = admin.site._registry[City]
View
5 django/contrib/gis/tests/geoapp/test_feeds.py
@@ -7,18 +7,17 @@
from django.contrib.sites.models import Site
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
-from django.test import TestCase, modify_settings
+from django.test import TestCase, modify_settings, override_settings
if HAS_GEOS:
from .models import City
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.sites'})
+@override_settings(ROOT_URLCONF='django.contrib.gis.tests.geoapp.urls')
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class GeoFeedTest(TestCase):
- urls = 'django.contrib.gis.tests.geoapp.urls'
-
def setUp(self):
Site(id=settings.SITE_ID, domain="example.com", name="example.com").save()
View
5 django/contrib/gis/tests/geoapp/test_sitemaps.py
@@ -9,18 +9,17 @@
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
from django.contrib.sites.models import Site
-from django.test import TestCase, modify_settings
+from django.test import TestCase, modify_settings, override_settings
if HAS_GEOS:
from .models import City, Country
@modify_settings(INSTALLED_APPS={'append': ['django.contrib.sites', 'django.contrib.sitemaps']})
+@override_settings(ROOT_URLCONF='django.contrib.gis.tests.geoapp.urls')
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class GeoSitemapTest(TestCase):
- urls = 'django.contrib.gis.tests.geoapp.urls'
-
def setUp(self):
super(GeoSitemapTest, self).setUp()
Site(id=settings.SITE_ID, domain="example.com", name="example.com").save()
View
2  django/contrib/messages/tests/base.py
@@ -48,7 +48,6 @@ def disable(self):
class BaseTests(object):
storage_class = default_storage
- urls = 'django.contrib.messages.tests.urls'
levels = {
'debug': constants.DEBUG,
'info': constants.INFO,
@@ -61,6 +60,7 @@ def setUp(self):
self.settings_override = override_settings_tags(
TEMPLATE_DIRS=(),
TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
+ ROOT_URLCONF='django.contrib.messages.tests.urls',
MESSAGE_TAGS='',
MESSAGE_STORAGE='%s.%s' % (self.storage_class.__module__,
self.storage_class.__name__),
View
4 django/contrib/messages/tests/test_mixins.py
@@ -1,10 +1,10 @@
-from django.test import TestCase
+from django.test import TestCase, override_settings
from django.contrib.messages.tests.urls import ContactFormViewWithMsg
from django.core.urlresolvers import reverse
+@override_settings(ROOT_URLCONF='django.contrib.messages.tests.urls')
class SuccessMessageMixinTests(TestCase):
- urls = 'django.contrib.messages.tests.urls'
def test_set_messages_success(self):
author = {'name': 'John Doe',
View
4 django/contrib/sitemaps/tests/base.py
@@ -1,7 +1,7 @@
from django.apps import apps
from django.core.cache import cache
from django.db import models
-from django.test import TestCase
+from django.test import TestCase, override_settings
class TestModel(models.Model):
@@ -17,11 +17,11 @@ def get_absolute_url(self):
return '/testmodel/%s/' % self.id
+@override_settings(ROOT_URLCONF='django.contrib.sitemaps.tests.urls.http')
class SitemapTestsBase(TestCase):
protocol = 'http'
sites_installed = apps.is_installed('django.contrib.sites')
domain = 'example.com' if sites_installed else 'testserver'
- urls = 'django.contrib.sitemaps.tests.urls.http'
def setUp(self):
self.base_url = '%s://%s' % (self.protocol, self.domain)
View
2  django/contrib/sitemaps/tests/test_https.py
@@ -7,9 +7,9 @@
from .base import SitemapTestsBase
+@override_settings(ROOT_URLCONF='django.contrib.sitemaps.tests.urls.https')
class HTTPSSitemapTests(SitemapTestsBase):
protocol = 'https'
- urls = 'django.contrib.sitemaps.tests.urls.https'
def test_secure_sitemap_index(self):
"A secure sitemap index can be rendered"
View
7 django/test/testcases.py
@@ -12,6 +12,7 @@
import sys
import threading
import unittest
+import warnings
from unittest import skipIf # NOQA: Imported here for backward compatibility
from unittest.util import safe_repr
@@ -33,6 +34,7 @@
from django.test.signals import setting_changed, template_rendered
from django.test.utils import (CaptureQueriesContext, ContextList,
override_settings, modify_settings, compare_xml)
+from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text
from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit, urlparse, unquote
@@ -202,6 +204,11 @@ def _pre_setup(self):
def _urlconf_setup(self):
set_urlconf(None)
if hasattr(self, 'urls'):
+ warnings.warn(
+ "SimpleTestCase.urls is deprecated and will be removed in"
@timgraham Owner

Just missing spaces at the end of these strings - I've added them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ "Django 2.0. Use @override_settings(ROOT_URLCONF=...)"
+ "in %s instead." % str(self.__class__.__name__),
+ RemovedInDjango20Warning, stacklevel=2)
self._old_root_urlconf = settings.ROOT_URLCONF
settings.ROOT_URLCONF = self.urls
clear_url_caches()
View
2  docs/internals/deprecation.txt
@@ -20,6 +20,8 @@ about each item can often be found in the release notes of two versions prior.
* Support for the ``prefix`` argument to
``django.conf.urls.i18n.i18n_patterns()`` will be removed.
+* ``SimpleTestCase.urls`` will be removed.
+
.. _deprecation-removed-in-1.9:
1.9
View
9 docs/releases/1.8.txt
@@ -256,6 +256,15 @@ Updating your code is as simple as ensuring that ``urlpatterns`` is a list of
url('^other/$', views.otherview),
]
+``django.test.SimpleTestCase.urls``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The attribute :attr:`SimpleTestCase.urls <django.test.SimpleTestCase.urls>`
+for specifying URLconf configuration in tests has now been deprecated in
+favor of :func:`~django.test.override_settings`. Use
+``@override_settings(ROOT_URLCONF=...)``. The attribute will be removed in
+Django 2.0.
+
``prefix`` argument to :func:`~django.conf.urls.i18n.i18n_patterns`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View
5 docs/topics/testing/tools.txt
@@ -961,6 +961,11 @@ URLconf configuration
.. attribute:: SimpleTestCase.urls
+.. deprecated:: 1.8
+
+ Use ``@override_settings(ROOT_URLCONF=...)`` instead for URLconf
+ configuration.
+
If your application provides views, you may want to include tests that use the
test client to exercise those views. However, an end user is free to deploy the
views in your application at any URL of their choosing. This means that your
View
6 tests/admin_changelist/tests.py
@@ -26,8 +26,8 @@
UnorderedObject, OrderedObject, CustomIdUser)
+@override_settings(ROOT_URLCONF="admin_changelist.urls")
class ChangeListTests(TestCase):
- urls = "admin_changelist.urls"
def setUp(self):
self.factory = RequestFactory()
@@ -664,12 +664,12 @@ def test_get_admin_log_templatetag_custom_user(self):
self.assertEqual(template.render(context), '')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_changelist.urls")
class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_changelist'] + AdminSeleniumWebDriverTestCase.available_apps
fixtures = ['users.json']
- urls = "admin_changelist.urls"
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def test_add_row_selection(self):
View
8 tests/admin_custom_urls/tests.py
@@ -8,7 +8,8 @@
from .models import Action, Person, Car
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_custom_urls.urls',)
class AdminCustomUrlsTest(TestCase):
"""
Remember that:
@@ -16,7 +17,6 @@ class AdminCustomUrlsTest(TestCase):
* The ModelAdmin for Action customizes the add_view URL, it's
'<app name>/<model name>/!add/'
"""
- urls = 'admin_custom_urls.urls'
fixtures = ['users.json', 'actions.json']
def setUp(self):
@@ -83,9 +83,9 @@ def testAdminUrlsNoClash(self):
self.assertContains(response, 'value="path/to/html/document.html"')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_custom_urls.urls',)
class CustomRedirects(TestCase):
- urls = 'admin_custom_urls.urls'
fixtures = ['users.json', 'actions.json']
def setUp(self):
View
16 tests/admin_docs/tests.py
@@ -11,8 +11,8 @@
from .models import Person, Company
+@override_settings(ROOT_URLCONF='admin_docs.urls')
class MiscTests(TestCase):
- urls = 'admin_docs.urls'
def setUp(self):
User.objects.create_superuser('super', None, 'secret')
@@ -30,11 +30,11 @@ def test_no_sites_framework(self):
self.client.get('/admindocs/views/') # should not raise
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_docs.urls')
@unittest.skipUnless(utils.docutils_is_available, "no docutils installed.")
class AdminDocViewTests(TestCase):
fixtures = ['data.xml']
- urls = 'admin_docs.urls'
def setUp(self):
self.client.login(username='super', password='secret')
@@ -104,10 +104,10 @@ def test_missing_docutils(self):
utils.docutils_is_available = True
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_docs.urls')
class XViewMiddlewareTest(TestCase):
fixtures = ['data.xml']
- urls = 'admin_docs.urls'
def test_xview_func(self):
user = User.objects.get(username='super')
@@ -147,8 +147,8 @@ def test_xview_class(self):
@unittest.skipUnless(utils.docutils_is_available, "no docutils installed.")
+@override_settings(ROOT_URLCONF='admin_docs.urls')
class DefaultRoleTest(TestCase):
- urls = 'admin_docs.urls'
def test_parse_rst(self):
"""
@@ -183,7 +183,8 @@ def test_publish_parts(self):
self.assertEqual(parts['fragment'], markup)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_docs.urls')
@unittest.skipUnless(utils.docutils_is_available, "no docutils installed.")
class TestModelDetailView(TestCase):
"""
@@ -191,7 +192,6 @@ class TestModelDetailView(TestCase):
"""
fixtures = ['data.xml']
- urls = 'admin_docs.urls'
def setUp(self):
self.client.login(username='super', password='secret')
View
20 tests/admin_inlines/tests.py
@@ -15,9 +15,9 @@
SomeChildModel)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_inlines.urls")
class TestInline(TestCase):
- urls = "admin_inlines.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -255,9 +255,9 @@ def test_stacked_inline_edit_form_contains_has_original_class(self):
)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_inlines.urls")
class TestInlineMedia(TestCase):
- urls = "admin_inlines.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -294,8 +294,8 @@ def test_all_inline_media(self):
self.assertContains(response, 'my_awesome_inline_scripts.js')
+@override_settings(ROOT_URLCONF="admin_inlines.urls")
class TestInlineAdminForm(TestCase):
- urls = "admin_inlines.urls"
def test_immutable_content_type(self):
"""Regression for #9362
@@ -313,9 +313,9 @@ def test_immutable_content_type(self):
self.assertEqual(iaf.original.content_type, parent_ct)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_inlines.urls")
class TestInlineProtectedOnDelete(TestCase):
- urls = "admin_inlines.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -350,13 +350,13 @@ def test_deleting_inline_with_protected_delete_does_not_validate(self):
% (chapter, foot_note))
+@override_settings(ROOT_URLCONF="admin_inlines.urls")
class TestInlinePermissions(TestCase):
"""
Make sure the admin respects permissions for objects that are edited
inline. Refs #8060.
"""
- urls = "admin_inlines.urls"
def setUp(self):
self.user = User(username='admin')
@@ -546,12 +546,12 @@ def test_inline_change_fk_all_perms(self):
self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_inlines.urls")
class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_inlines'] + AdminSeleniumWebDriverTestCase.available_apps
fixtures = ['admin-views-users.xml']
- urls = "admin_inlines.urls"
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def test_add_stackeds(self):
View
4 tests/admin_scripts/tests.py
@@ -26,7 +26,7 @@
from django.utils.encoding import force_text
from django.utils._os import npath, upath
from django.utils.six import StringIO
-from django.test import LiveServerTestCase, TestCase
+from django.test import LiveServerTestCase, TestCase, override_settings
from django.test.runner import DiscoverRunner
from django.test.utils import str_prefix
@@ -1631,9 +1631,9 @@ def _test(self, args, option_b="'2'"):
self.assertOutput(out, str_prefix("EXECUTE:BaseCommand labels=('testlabel',), options=[('no_color', False), ('option_a', 'x'), ('option_b', %%s), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', %(_)s'1')]") % option_b)
+@override_settings(ROOT_URLCONF='admin_scripts.urls')
class StartProject(LiveServerTestCase, AdminScriptTestCase):
- urls = 'admin_scripts.urls'
available_apps = [
'admin_scripts',
'django.contrib.auth',
View
152 tests/admin_views/tests.py
@@ -64,6 +64,7 @@
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls",
USE_I18N=True, USE_L10N=False, LANGUAGE_CODE='en')
class AdminViewBasicTestCase(TestCase):
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml',
@@ -74,8 +75,6 @@ class AdminViewBasicTestCase(TestCase):
# this test case and changing urlbit.
urlbit = 'admin'
- urls = "admin_views.urls"
-
def setUp(self):
self.client.login(username='super', password='secret')
@@ -747,9 +746,9 @@ def test_filter_with_custom_template(self):
self.assertTemplateUsed(response, 'custom_filter_template.html')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewFormUrlTest(TestCase):
- urls = "admin_views.urls"
fixtures = ["admin-views-users.xml"]
urlbit = "admin3"
@@ -781,12 +780,11 @@ def testInitialDataCanBeOverridden(self):
self.assertContains(response, 'value="overridden_value"')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminJavaScriptTest(TestCase):
fixtures = ['admin-views-users.xml']
- urls = "admin_views.urls"
-
def setUp(self):
self.client.login(username='super', password='secret')
@@ -827,9 +825,9 @@ def test_js_minified_only_if_debug_is_false(self):
self.assertNotContains(response, 'inlines.min.js')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class SaveAsTests(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'admin-views-person.xml']
def setUp(self):
@@ -858,8 +856,8 @@ def test_save_as_display(self):
self.assertEqual(response.context['form_url'], '/test_admin/admin/admin_views/person/add/')
+@override_settings(ROOT_URLCONF="admin_views.urls")
class CustomModelAdminTest(AdminViewBasicTestCase):
- urls = "admin_views.urls"
urlbit = "admin2"
def testCustomAdminSiteLoginForm(self):
@@ -937,11 +935,11 @@ def get_perm(Model, perm):
return Permission.objects.get(content_type=ct, codename=perm)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewPermissionsTest(TestCase):
"""Tests for Admin Views Permissions."""
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -1465,11 +1463,11 @@ def test_shortcut_view_only_available_to_staff(self):
self.assertEqual(response.url, 'http://example.com/dummy/foo/')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewsNoUrlTest(TestCase):
"""Regression test for #17333"""
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -1496,9 +1494,9 @@ def test_no_standard_modeladmin_urls(self):
self.client.get('/test_admin/admin/logout/')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewDeletedObjectsTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'deleted-objects.xml']
def setUp(self):
@@ -1614,9 +1612,9 @@ def test_generic_relations(self):
self.assertContains(response, should_contain)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewStringPrimaryKeyTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'string-primary-key.xml']
def __init__(self, *args):
@@ -1748,12 +1746,12 @@ def test_change_view_history_link(self):
self.assertContains(response, '<a href="%s" class="historylink"' % expected_link)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class SecureViewTests(TestCase):
"""
Test behavior of a view protected by the staff_member_required decorator.
"""
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def tearDown(self):
@@ -1771,9 +1769,9 @@ def test_secure_view_shows_login_if_not_logged_in(self):
self.assertEqual(response.context[REDIRECT_FIELD_NAME], secure_url)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewUnicodeTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-unicode.xml']
def setUp(self):
@@ -1826,9 +1824,9 @@ def testUnicodeDelete(self):
self.assertRedirects(response, '/test_admin/admin/admin_views/book/')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewListEditable(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'admin-views-person.xml']
def setUp(self):
@@ -2203,9 +2201,9 @@ def test_pk_hidden_fields_with_list_display_links(self):
self.assertContains(response, '<th class="field-id"><a href="%s">%d</a></th>' % (link2, story2.id), 1)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminSearchTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users', 'multiple-child-classes',
'admin-views-person']
@@ -2274,9 +2272,9 @@ def test_reset_link(self):
html=True)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminInheritedInlinesTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -2362,9 +2360,9 @@ def testInline(self):
self.assertEqual(Persona.objects.all()[0].accounts.count(), 2)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminActionsTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'admin-views-actions.xml']
def setUp(self):
@@ -2631,9 +2629,9 @@ def test_popup_template_response(self):
self.assertEqual(response.template_name, 'admin/popup_response.html')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class TestCustomChangeList(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
urlbit = 'admin'
@@ -2660,9 +2658,9 @@ def test_custom_changelist(self):
self.assertNotContains(response, 'First Gadget')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class TestInlineNotEditable(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -2680,9 +2678,9 @@ def test(self):
self.assertEqual(response.status_code, 200)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminCustomQuerysetTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -2925,9 +2923,9 @@ def test_history_view_custom_qs(self):
self.assertEqual(self.client.get('/test_admin/admin/admin_views/filteredmanager/2/history/').status_code, 200)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminInlineFileUploadTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'admin-views-actions.xml']
urlbit = 'admin'
@@ -2972,9 +2970,9 @@ def test_inline_file_upload_edit_validation_error_post(self):
self.assertContains(response, b"Currently")
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminInlineTests(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -3291,9 +3289,9 @@ def test_ordered_inline(self):
self.assertEqual(Category.objects.get(id=4).order, 0)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class NeverCacheTests(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml']
def setUp(self):
@@ -3365,9 +3363,9 @@ def testJsi18n(self):
self.assertEqual(get_max_age(response), None)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class PrePopulatedTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -3401,12 +3399,12 @@ def test_prepopulated_maxlength_localized(self):
self.assertContains(response, "maxLength: 1000") # instead of 1,000
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_views'] + AdminSeleniumWebDriverTestCase.available_apps
fixtures = ['admin-views-users.xml']
- urls = "admin_views.urls"
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def test_prepopulated_fields(self):
@@ -3597,9 +3595,9 @@ class SeleniumAdminViewsIETests(SeleniumAdminViewsFirefoxTests):
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class ReadonlyTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -3708,9 +3706,9 @@ def test_readonly_field_overrides(self):
self.assertNotContains(response, "Some help text for the date (with unicode ŠĐĆŽćžšđ)")
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class LimitChoicesToInAdminTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -3735,9 +3733,9 @@ def test_limit_choices_to_as_callable(self):
self.assertNotContains(response, marley.username)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class RawIdFieldsTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -3815,12 +3813,12 @@ def test_limit_choices_to_isnull_true(self):
self.assertContains(response2, "Palin")
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class UserAdminTest(TestCase):
"""
Tests user CRUD functionality.
"""
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -3922,12 +3920,12 @@ def test_form_url_present_in_context(self):
self.assertEqual(response.context['form_url'], 'pony')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class GroupAdminTest(TestCase):
"""
Tests group CRUD functionality.
"""
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -3959,9 +3957,9 @@ def test_group_permission_performance(self):
self.assertEqual(response.status_code, 200)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class CSSTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -4084,9 +4082,9 @@ def test_changelist_field_classes(self):
@unittest.skipUnless(docutils, "no docutils installed.")
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminDocsTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -4127,9 +4125,9 @@ def test_filters(self):
self.assertContains(response, '<li><a href="#built_in-add">add</a></li>', html=True)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class ValidXHTMLTests(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
urlbit = 'admin'
@@ -4152,9 +4150,9 @@ def testLangNamePresent(self):
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls",
USE_THOUSAND_SEPARATOR=True, USE_L10N=True)
class DateHierarchyTests(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -4274,13 +4272,13 @@ def test_multiple_years(self):
self.assert_non_localized_year(response, 2005)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminCustomSaveRelatedTests(TestCase):
"""
Ensure that one can easily customize the way related objects are saved.
Refs #16115.
"""
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -4343,9 +4341,9 @@ def test_should_be_able_to_edit_related_objects_on_changelist_view(self):
self.assertEqual(['Catherine Stone', 'Paul Stone'], children_names)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewLogoutTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -4372,9 +4370,9 @@ def test_client_logout_url_can_be_used_to_login(self):
self.assertContains(response, '<input type="hidden" name="next" value="/test_admin/admin/" />')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminUserMessageTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -4430,9 +4428,9 @@ def test_message_extra_tags(self):
html=True)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminKeepChangeListFiltersTests(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
admin_site = site
@@ -4716,11 +4714,11 @@ class NamespacedAdminKeepChangeListFiltersTests(AdminKeepChangeListFiltersTests)
admin_site = site2
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class TestLabelVisibility(TestCase):
""" #11277 -Labels of hidden fields in admin were not hidden. """
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml']
def setUp(self):
@@ -4757,9 +4755,9 @@ def assert_fieldline_hidden(self, response):
self.assertContains(response, '<div class="form-row hidden')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class AdminViewOnSiteTests(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'admin-views-restaurants.xml']
def setUp(self):
@@ -4878,9 +4876,9 @@ def test_missing_get_absolute_url(self):
self.assertIsNone(model_admin.get_view_on_site_url(Worker()))
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="admin_views.urls")
class InlineAdminViewOnSiteTest(TestCase):
- urls = "admin_views.urls"
fixtures = ['admin-views-users.xml', 'admin-views-restaurants.xml']
def setUp(self):
View
36 tests/admin_widgets/tests.py
@@ -181,10 +181,10 @@ class AdvisorAdmin(admin.ModelAdmin):
self.assertEqual(six.text_type(f.help_text), 'Hold down "Control", or "Command" on a Mac, to select more than one.')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_widgets.urls')
class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
fixtures = ["admin-widgets-users.xml"]
- urls = 'admin_widgets.urls'
def testFilterChoicesByRequestUser(self):
"""
@@ -196,10 +196,10 @@ def testFilterChoicesByRequestUser(self):
self.assertContains(response, "Volkswagon Passat")
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_widgets.urls')
class AdminForeignKeyWidgetChangeList(DjangoTestCase):
fixtures = ["admin-widgets-users.xml"]
- urls = 'admin_widgets.urls'
def setUp(self):
self.client.login(username="super", password="secret")
@@ -212,10 +212,10 @@ def test_changelist_foreignkey(self):
self.assertContains(response, '/auth/user/add/')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_widgets.urls')
class AdminForeignKeyRawIdWidget(DjangoTestCase):
fixtures = ["admin-widgets-users.xml"]
- urls = 'admin_widgets.urls'
def setUp(self):
self.client.login(username="super", password="secret")
@@ -391,8 +391,8 @@ def test_render(self):
)
+@override_settings(ROOT_URLCONF='admin_widgets.urls')
class ForeignKeyRawIdWidgetTest(DjangoTestCase):
- urls = 'admin_widgets.urls'
def test_render(self):
band = models.Band.objects.create(name='Linkin Park')
@@ -465,8 +465,8 @@ def test_proper_manager_for_label_lookup(self):
)
+@override_settings(ROOT_URLCONF='admin_widgets.urls')
class ManyToManyRawIdWidgetTest(DjangoTestCase):
- urls = 'admin_widgets.urls'
def test_render(self):
band = models.Band.objects.create(name='Linkin Park')
@@ -518,12 +518,12 @@ def test_no_can_add_related(self):
self.assertFalse(w.can_add_related)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_widgets.urls')
class DateTimePickerSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
fixtures = ['admin-widgets-users.xml']
- urls = "admin_widgets.urls"
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def test_show_hide_date_time_picker_widgets(self):
@@ -652,11 +652,11 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
@skipIf(pytz is None, "this test requires pytz")
@override_settings(TIME_ZONE='Asia/Singapore')
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_widgets.urls')
class DateTimePickerShortcutsSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
fixtures = ['admin-widgets-users.xml']
- urls = "admin_widgets.urls"
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def test_date_time_picker_shortcuts(self):
@@ -720,12 +720,12 @@ class DateTimePickerShortcutsSeleniumIETests(DateTimePickerShortcutsSeleniumFire
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_widgets.urls')
class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
fixtures = ['admin-widgets-users.xml']
- urls = "admin_widgets.urls"
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def setUp(self):
@@ -964,11 +964,11 @@ class HorizontalVerticalFilterSeleniumIETests(HorizontalVerticalFilterSeleniumFi
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_widgets.urls')
class AdminRawIdWidgetSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
fixtures = ['admin-widgets-users.xml']
- urls = "admin_widgets.urls"
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def setUp(self):
@@ -1055,11 +1055,11 @@ class AdminRawIdWidgetSeleniumIETests(AdminRawIdWidgetSeleniumFirefoxTests):
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF='admin_widgets.urls')
class RelatedFieldWidgetSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
available_apps = ['admin_widgets'] + AdminSeleniumWebDriverTestCase.available_apps
fixtures = ['admin-widgets-users.xml']
- urls = "admin_widgets.urls"
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
def test_foreign_key_using_to_field(self):
View
2  tests/cache/tests.py
@@ -2007,9 +2007,9 @@ def test_with_etag(self):
self.assertTrue(response.has_header('ETag'))
+@override_settings(ROOT_URLCONF="admin_views.urls")
class TestEtagWithAdmin(TestCase):
# See https://code.djangoproject.com/ticket/16003
- urls = "admin_views.urls"
def test_admin(self):
with self.settings(USE_ETAGS=False):
View
4 tests/conditional_processing/tests.py
@@ -3,7 +3,7 @@
from datetime import datetime
-from django.test import TestCase
+from django.test import TestCase, override_settings
FULL_RESPONSE = 'Test conditional get response'
@@ -16,8 +16,8 @@
EXPIRED_ETAG = '7fae4cd4b0f81e7d2914700043aa8ed6'
+@override_settings(ROOT_URLCONF='conditional_processing.urls')
class ConditionalGet(TestCase):
- urls = 'conditional_processing.urls'
def assertFullResponse(self, response, check_last_modified=True, check_etag=True):
self.assertEqual(response.status_code, 200)
View
2  tests/contenttypes_tests/tests.py
@@ -15,9 +15,9 @@
from .models import Author, Article, SchemeIncludedURL
+@override_settings(ROOT_URLCONF='contenttypes_tests.urls')
class ContentTypesViewsTests(TestCase):
fixtures = ['testdata.json']
- urls = 'contenttypes_tests.urls'
def test_shortcut_with_absolute_url(self):
"Can view a shortcut for an Author object that has a get_absolute_url method"
View
5 tests/context_processors/tests.py
@@ -1,16 +1,15 @@
"""
Tests for Django's bundled context processors.
"""
-from django.test import TestCase
+from django.test import TestCase, override_settings
+@override_settings(ROOT_URLCONF='context_processors.urls')
class RequestContextProcessorTests(TestCase):
"""
Tests for the ``django.core.context_processors.request`` processor.
"""
- urls = 'context_processors.urls'
-
def test_request_attributes(self):
"""
Test that the request object is available in the template and that its
View
26 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 @@ def test_deprecated_memoize(self):
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.")
View
2  tests/file_storage/tests.py
@@ -641,13 +641,13 @@ def test_content_saving(self):
self.storage.save('unicode.txt', ContentFile("español"))
+@override_settings(ROOT_URLCONF='file_storage.urls')
class FileLikeObjectTestCase(LiveServerTestCase):
"""
Test file-like objects (#15644).
"""
available_apps = []
- urls = 'file_storage.urls'
def setUp(self):
self.temp_dir = tempfile.mkdtemp()
View
3  tests/file_uploads/tests.py
@@ -27,9 +27,8 @@
UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload')
-@override_settings(MEDIA_ROOT=MEDIA_ROOT)
+@override_settings(MEDIA_ROOT=MEDIA_ROOT, ROOT_URLCONF='file_uploads.urls')
class FileUploadTests(TestCase):
- urls = 'file_uploads.urls'
@classmethod
def setUpClass(cls):
View
2  tests/forms_tests/tests/test_widgets.py
@@ -1112,10 +1112,10 @@ class SplitDateRequiredForm(Form):
self.assertFalse(form.is_valid())
+@override_settings(ROOT_URLCONF='forms_tests.urls')
class LiveWidgetTests(AdminSeleniumWebDriverTestCase):
available_apps = ['forms_tests'] + AdminSeleniumWebDriverTestCase.available_apps
- urls = 'forms_tests.urls'
def test_textarea_trailing_newlines(self):
"""
View
16 tests/generic_inline_admin/tests.py
@@ -18,9 +18,9 @@
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
- TEMPLATE_DEBUG=True)
+ TEMPLATE_DEBUG=True,
+ ROOT_URLCONF="generic_inline_admin.urls")
class GenericAdminViewTest(TestCase):
- urls = "generic_inline_admin.urls"
fixtures = ['users.xml']
def setUp(self):
@@ -130,9 +130,9 @@ def testGenericInlineFormsetFactory(self):
self.assertTrue(formset.get_queryset().ordered)
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
+@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
+ ROOT_URLCONF="generic_inline_admin.urls")
class GenericInlineAdminParametersTest(TestCase):