Opened 11 years ago
Closed 11 years ago
#21979 closed Uncategorized (worksforme)
Inconsistent test results for same test run twice
Reported by: | 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/
Note:
See TracTickets
for help on using tickets.
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 aOneToOneField
toContentType
is relatively unusual, and I don't think we need to change anything. Your test case should be fixed by addingContentType.objects.clear_cache()
in atearDown
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.