1. from django.test import TestCase
    
  2. 
    
  3. from .models import Parent
    
  4. 
    
  5. 
    
  6. class MutuallyReferentialTests(TestCase):
    
  7.     def test_mutually_referential(self):
    
  8.         # Create a Parent
    
  9.         q = Parent(name="Elizabeth")
    
  10.         q.save()
    
  11. 
    
  12.         # Create some children
    
  13.         c = q.child_set.create(name="Charles")
    
  14.         q.child_set.create(name="Edward")
    
  15. 
    
  16.         # Set the best child
    
  17.         # No assertion require here; if basic assignment and
    
  18.         # deletion works, the test passes.
    
  19.         q.bestchild = c
    
  20.         q.save()
    
  21.         q.delete()