Opened 11 years ago

Closed 11 years ago

#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

Description

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 by Marc Tamlyn, 11 years ago

Resolution: worksforme
Status: newclosed

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