Code in test classes can get access to live database
|Reported by:||Art_S||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When assigning fields in a test case class like this:
from django.test import TestCase class TestClass(TestCase): field = [x for x in DataBaseObject.objects.all()]
The code is actually executed against "normal" database in settings.py, not the one which is temporarily created.
Possible workaround is to use property/lambda syntax.
Change History (3)
comment:1 Changed 6 years ago by russellm
- Resolution set to wontfix
- Status changed from new to closed
comment:2 Changed 6 years ago by Art_S
- Resolution wontfix deleted
- Status changed from closed to reopened