mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Refs #21977 -- Removed SimpleTestCase.urls per deprecation timeline.
This commit is contained in:
parent
5c62887d82
commit
1392aff440
4 changed files with 9 additions and 89 deletions
|
@ -639,7 +639,6 @@ functionality like:
|
|||
|
||||
* The ability to run tests with :ref:`modified settings <overriding-settings>`.
|
||||
* Using the :attr:`~SimpleTestCase.client` :class:`~django.test.Client`.
|
||||
* Custom test-time :attr:`URL maps <SimpleTestCase.urls>`.
|
||||
|
||||
If you need any of the other more complex and heavyweight Django-specific
|
||||
features like:
|
||||
|
@ -1080,39 +1079,12 @@ using multiple databases and set :attr:`multi_db=True
|
|||
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
|
||||
tests can't rely upon the fact that your views will be available at a
|
||||
particular URL.
|
||||
|
||||
In order to provide a reliable URL space for your test,
|
||||
``django.test.*TestCase`` classes provide the ability to customize the URLconf
|
||||
configuration for the duration of the execution of a test suite. If your
|
||||
``*TestCase`` instance defines an ``urls`` attribute, the ``*TestCase`` will use
|
||||
the value of that attribute as the :setting:`ROOT_URLCONF` for the duration
|
||||
of that test.
|
||||
|
||||
For example::
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
class TestMyViews(TestCase):
|
||||
urls = 'myapp.test_urls'
|
||||
|
||||
def test_index_page_view(self):
|
||||
# Here you'd test your view using ``Client``.
|
||||
call_some_test_code()
|
||||
|
||||
This test case will use the contents of ``myapp.test_urls`` as the
|
||||
URLconf for the duration of the test case.
|
||||
particular URL. Decorate your test class or test method with
|
||||
``@override_settings(ROOT_URLCONF=...)`` for URLconf configuration.
|
||||
|
||||
.. _emptying-test-outbox:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue