/tests/modeltests/mutually_referential/tests.py
Python | 20 lines | 11 code | 4 blank | 5 comment | 0 complexity | 916c06ab823ce3feaa8a454798d73648 MD5 | raw file
Possible License(s): BSD-3-Clause
1from django.test import TestCase 2from models import Parent, Child 3 4class MutuallyReferentialTests(TestCase): 5 6 def test_mutually_referential(self): 7 # Create a Parent 8 q = Parent(name='Elizabeth') 9 q.save() 10 11 # Create some children 12 c = q.child_set.create(name='Charles') 13 e = q.child_set.create(name='Edward') 14 15 # Set the best child 16 # No assertion require here; if basic assignment and 17 # deletion works, the test passes. 18 q.bestchild = c 19 q.save() 20 q.delete()