'Make sure that the content type cache (see ContentTypeManager)
works correctly. Lookups for a particular content type -- by model, ID
or natural key -- should hit the database only on the first lookup.'

def test_lookup_cache(self):

    with self.assertNumQueries(1):
        ContentType.objects.get_for_model(ContentType)
    with self.assertNumQueries(0):
        ct = ContentType.objects.get_for_model(ContentType)
    with self.assertNumQueries(0):
        ContentType.objects.get_for_id(ct.id)
    with self.assertNumQueries(0):
        ContentType.objects.get_by_natural_key(u'contenttypes', u'contenttype')
    ContentType.objects.clear_cache()
    with self.assertNumQueries(1):
        ContentType.objects.get_for_model(ContentType)
    ContentType.objects.clear_cache()
    with self.assertNumQueries(1):
        ContentType.objects.get_by_natural_key(u'contenttypes', u'contenttype')
    with self.assertNumQueries(0):
        ContentType.objects.get_by_natural_key(u'contenttypes', u'contenttype')
