summaryrefslogtreecommitdiff
path: root/parts/django/tests/modeltests/empty
diff options
context:
space:
mode:
Diffstat (limited to 'parts/django/tests/modeltests/empty')
-rw-r--r--parts/django/tests/modeltests/empty/__init__.py0
-rw-r--r--parts/django/tests/modeltests/empty/models.py12
-rw-r--r--parts/django/tests/modeltests/empty/tests.py15
3 files changed, 27 insertions, 0 deletions
diff --git a/parts/django/tests/modeltests/empty/__init__.py b/parts/django/tests/modeltests/empty/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/parts/django/tests/modeltests/empty/__init__.py
diff --git a/parts/django/tests/modeltests/empty/models.py b/parts/django/tests/modeltests/empty/models.py
new file mode 100644
index 0000000..a6cdb0a
--- /dev/null
+++ b/parts/django/tests/modeltests/empty/models.py
@@ -0,0 +1,12 @@
+"""
+40. Empty model tests
+
+These test that things behave sensibly for the rare corner-case of a model with
+no fields.
+"""
+
+from django.db import models
+
+
+class Empty(models.Model):
+ pass
diff --git a/parts/django/tests/modeltests/empty/tests.py b/parts/django/tests/modeltests/empty/tests.py
new file mode 100644
index 0000000..01fa1c5
--- /dev/null
+++ b/parts/django/tests/modeltests/empty/tests.py
@@ -0,0 +1,15 @@
+from django.test import TestCase
+
+from models import Empty
+
+
+class EmptyModelTests(TestCase):
+ def test_empty(self):
+ m = Empty()
+ self.assertEqual(m.id, None)
+ m.save()
+ m2 = Empty.objects.create()
+ self.assertEqual(len(Empty.objects.all()), 2)
+ self.assertTrue(m.id is not None)
+ existing = Empty(m.id)
+ existing.save()