summaryrefslogtreecommitdiff
path: root/tests/regressiontests/generic_inline_admin
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2009-01-16 02:30:22 +0000
committerKaren Tracey <kmtracey@gmail.com>2009-01-16 02:30:22 +0000
commit344f16e2205a4959ba65d975716a38db77d2061e (patch)
treef87bf6bde5db1a4c566a1b4d44927d4a2ecfc4f6 /tests/regressiontests/generic_inline_admin
parentf9f9d703cfef64766ab5a3d7cb5d79298367f621 (diff)
Fixed #8138 -- Changed django.test.TestCase to rollback tests (when the database supports it) instead of flushing and reloading the database. This can substantially reduce the time it takes to run large test suites.
This change may be slightly backwards incompatible, if existing tests need to test transactional behavior, or if they rely on invalid assumptions or a specific test case ordering. For the first case, django.test.TransactionTestCase should be used. TransactionTestCase is also a quick fix to get around test case errors revealed by the new rollback approach, but a better long-term fix is to correct the test case. See the testing doc for full details. Many thanks to: * Marc Remolt for the initial proposal and implementation. * Luke Plant for initial testing and improving the implementation. * Ramiro Morales for feedback and help with tracking down a mysterious PostgreSQL issue. * Eric Holscher for feedback regarding the effect of the change on the Ellington testsuite. * Russell Keith-Magee for guidance and feedback from beginning to end. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9756 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/generic_inline_admin')
-rw-r--r--tests/regressiontests/generic_inline_admin/tests.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
index e03cc1f2f4..a3ea5fc60b 100644
--- a/tests/regressiontests/generic_inline_admin/tests.py
+++ b/tests/regressiontests/generic_inline_admin/tests.py
@@ -21,8 +21,10 @@ class GenericAdminViewTest(TestCase):
# relies on content type IDs, which will vary depending on what
# other tests have been run), thus we do it here.
e = Episode.objects.create(name='This Week in Django')
+ self.episode_pk = e.pk
m = Media(content_object=e, url='http://example.com/podcast.mp3')
m.save()
+ self.media_pk = m.pk
def tearDown(self):
self.client.logout()
@@ -39,7 +41,7 @@ class GenericAdminViewTest(TestCase):
"""
A smoke test to ensure GET on the change_view works.
"""
- response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/1/')
+ response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk)
self.failUnlessEqual(response.status_code, 200)
def testBasicAddPost(self):
@@ -64,10 +66,11 @@ class GenericAdminViewTest(TestCase):
# inline data
"generic_inline_admin-media-content_type-object_id-TOTAL_FORMS": u"2",
"generic_inline_admin-media-content_type-object_id-INITIAL_FORMS": u"1",
- "generic_inline_admin-media-content_type-object_id-0-id": u"1",
+ "generic_inline_admin-media-content_type-object_id-0-id": u"%d" % self.media_pk,
"generic_inline_admin-media-content_type-object_id-0-url": u"http://example.com/podcast.mp3",
"generic_inline_admin-media-content_type-object_id-1-id": u"",
"generic_inline_admin-media-content_type-object_id-1-url": u"",
}
- response = self.client.post('/generic_inline_admin/admin/generic_inline_admin/episode/1/', post_data)
+ url = '/generic_inline_admin/admin/generic_inline_admin/episode/%d/' % self.episode_pk
+ response = self.client.post(url, post_data)
self.failUnlessEqual(response.status_code, 302) # redirect somewhere