Opened 3 years ago

Closed 3 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


Please see this for a minimal project replicating the issue:

Please see this for a description of the problem:

Change History (1)

comment:1 Changed 3 years ago by Marc Tamlyn

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: worksforme
Status: newclosed

The documentation you need to read is the following:

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