diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2008-06-30 12:34:29 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2008-06-30 12:34:29 +0000 |
| commit | 415bd694f9de8252e8d47bdf3df73cc62ca97728 (patch) | |
| tree | 237fa918225a9cdda54bff352819bb89650dff73 /docs | |
| parent | 61898d86276d236388c66a8f629ff6c3cfe04800 (diff) | |
Fixed #7521 -- Added the ability to customize ROOT_URLCONF for the duration of a TestCase. Thanks to Mark Fargas (telenieko) for his work on this patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7805 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/testing.txt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/testing.txt b/docs/testing.txt index befa6979af..0b18545efb 100644 --- a/docs/testing.txt +++ b/docs/testing.txt @@ -797,6 +797,37 @@ another test, or by the order of test execution. .. _dumpdata documentation: ../django-admin/#dumpdata-appname-appname .. _loaddata documentation: ../django-admin/#loaddata-fixture-fixture +URLconf configuration +~~~~~~~~~~~~~~~~~~~~~ + +**New in Django development version** + +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`` provides 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 ``ROOT_URLCONF`` +for the duration of that test. + +For example:: + + from django.test import TestCase + + class TestMyViews(TestCase): + urls = 'myapp.test_urls' + + def testIndexPageView(self): + # Here you'd test your view using ``Client``. + +This test case will use the contents of ``myapp.test_urls`` as the +URLconf for the duration of the test case. + Emptying the test outbox ~~~~~~~~~~~~~~~~~~~~~~~~ |
