#21979 closed Uncategorized (worksforme)

Inconsistent test results for same test run twice

Reported by: schrinaw@… Owned by: nobody
Component: Testing framework Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Please see this for a minimal project replicating the issue: https://github.com/aschriner/django_bug_demo

Please see this for a description of the problem: http://stackoverflow.com/questions/21631596/

Change History (1)

comment:1 Changed 20 months ago by mjtamlyn

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

The documentation you need to read is the following: https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#the-contenttypemanager

In short, ContentType.objects.get_for_model() caches itself - a use case with a OneToOneField to ContentType is relatively unusual, and I don't think we need to change anything. Your test case should be fixed by adding ContentType.objects.clear_cache() in a tearDown method. I don't think it would be wise for us to automatically call this on all test teardowns, because it probably saves a bunch of test run time in some circumstances.

Note: See TracTickets for help on using tickets.
Back to Top