diff -r a427ac897106 tests/modeltests/delete/sub/__init__.py
diff -r a427ac897106 tests/modeltests/delete/sub/models.py
-
|
+
|
|
| 1 | from django.db import models |
| 2 | from django.contrib.contenttypes.models import ContentType |
| 3 | |
| 4 | class TestModel(models.Model): |
| 5 | fk = models.ForeignKey(ContentType) |
diff -r a427ac897106 tests/modeltests/delete/tests.py
a
|
b
|
|
| 1 | from django.conf import settings |
1 | 2 | from django.db import models, IntegrityError |
2 | 3 | from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature |
3 | 4 | |
… |
… |
|
251 | 252 | |
252 | 253 | r.delete() |
253 | 254 | self.assertEqual(HiddenUserProfile.objects.count(), 0) |
| 255 | |
| 256 | |
| 257 | class ContentTypeDeleteTests(TestCase): |
| 258 | def setUp(self): |
| 259 | from sub.models import * |
| 260 | self.old_installed_apps = settings.INSTALLED_APPS |
| 261 | settings.INSTALLED_APPS = ['django.contrib.contenttypes'] |
| 262 | super(ContentTypeDeleteTests, self).setUp() |
| 263 | |
| 264 | def test_deletion(self): |
| 265 | from django.contrib.contenttypes import management, models |
| 266 | # YIKES YIKES |
| 267 | del models.ContentType._meta._related_objects_cache |
| 268 | models.ContentType.objects.all().delete() |
| 269 | |
| 270 | def tearDown(self): |
| 271 | settings.INSTALLED_APPS = self.old_installed_apps |
| 272 | super(ContentTypeDeleteTests, self).tearDown() |
| 273 | |
| 274 | |