'Ensure you can handle circular references'

def test_circular_reference_on_self(self):

    class Person(Document, ):
        name = StringField()
        relations = ListField(ReferenceField('self'))
        def __repr__(self):
            return ('<Person:    %s>' % self.name)
    Person.drop_collection()
    mother = Person(name='Mother')
    daughter = Person(name='Daughter')
    mother.save()
    daughter.save()
    mother.relations.append(daughter)
    mother.save()
    daughter.relations.append(mother)
    daughter.relations.append(daughter)
    daughter.save()
    self.assertEqual('[<Person:    Mother>,    <Person:    Daughter>]', ('%s' % Person.objects()))
