This is because the ContentType.objects.get_for_model will cache the result. The django.test.TestCase truncates all table after run test method and call django.contrib.auth.management.create_permissions which will call ContentType.objects.get_for_model.

At this time, ContentType.objects.get_for_model won't create new content type data into django_contenttype table, it will get the ContentType object from cache.