Code

Ticket #15654: test.diff

File test.diff, 1.7 KB (added by apollo13, 3 years ago)
Line 
1diff -r a427ac897106 tests/modeltests/delete/sub/__init__.py
2--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
3+++ b/tests/modeltests/delete/sub/__init__.py   Sun Mar 20 04:36:54 2011 +0100
4@@ -0,0 +1,1 @@
5+# __init__.py
6diff -r a427ac897106 tests/modeltests/delete/sub/models.py
7--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
8+++ b/tests/modeltests/delete/sub/models.py     Sun Mar 20 04:36:54 2011 +0100
9@@ -0,0 +1,5 @@
10+from django.db import models
11+from django.contrib.contenttypes.models import ContentType
12+
13+class TestModel(models.Model):
14+    fk = models.ForeignKey(ContentType)
15diff -r a427ac897106 tests/modeltests/delete/tests.py
16--- a/tests/modeltests/delete/tests.py  Sat Mar 19 02:42:40 2011 +0000
17+++ b/tests/modeltests/delete/tests.py  Sun Mar 20 04:36:54 2011 +0100
18@@ -1,3 +1,4 @@
19+from django.conf import settings
20 from django.db import models, IntegrityError
21 from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
22 
23@@ -251,3 +252,23 @@
24 
25         r.delete()
26         self.assertEqual(HiddenUserProfile.objects.count(), 0)
27+
28+
29+class ContentTypeDeleteTests(TestCase):
30+    def setUp(self):
31+        from sub.models import *
32+        self.old_installed_apps = settings.INSTALLED_APPS
33+        settings.INSTALLED_APPS = ['django.contrib.contenttypes']
34+        super(ContentTypeDeleteTests, self).setUp()
35+
36+    def test_deletion(self):
37+        from django.contrib.contenttypes import management, models
38+        # YIKES YIKES
39+        del models.ContentType._meta._related_objects_cache
40+        models.ContentType.objects.all().delete()
41+
42+    def tearDown(self):
43+        settings.INSTALLED_APPS = self.old_installed_apps
44+        super(ContentTypeDeleteTests, self).tearDown()
45+
46+