summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob <tienrobertnguyenn@gmail.com>2019-05-12 20:58:35 +1000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-05-13 07:25:42 +0200
commitc231a75112d8a06e1a776ef97f28a3be1b343047 (patch)
treec62d201b2f85ed6cf368c6a7455307be7bec0759 /tests
parent330638b89f14e1fb06e9d313ccc9768ae167c53f (diff)
Fixed #30436 -- Added check that on_delete is callable in ForeignKey and OneToOneField.
Diffstat (limited to 'tests')
-rw-r--r--tests/delete/tests.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/delete/tests.py b/tests/delete/tests.py
index 6b1cd3675b..505fd843d7 100644
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -21,6 +21,13 @@ class OnDeleteTests(TestCase):
a.auto.delete()
self.assertFalse(A.objects.filter(name='auto').exists())
+ def test_non_callable(self):
+ msg = 'on_delete must be callable.'
+ with self.assertRaisesMessage(TypeError, msg):
+ models.ForeignKey('self', on_delete=None)
+ with self.assertRaisesMessage(TypeError, msg):
+ models.OneToOneField('self', on_delete=None)
+
def test_auto_nullable(self):
a = create_a('auto_nullable')
a.auto_nullable.delete()