Patch to enable in-memory testing of Django applications
|Reported by:||crankycoder@…||Owned by:||adrian|
|Component:||Database layer (models, ORM)||Version:|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, Django doesn't have a nice way of unit-testing individual applications quickly it takes a long time to drop/recreate the backing database. There are a number of scripts on the web that *almost* let you replace the database with a SQLite in-memory database, but it doesn't work in all cases due to some tricky import problems in Django.
Basically - after the MR branch was merged, the following idiom crept into a lot of the Django code:
from django.db import connection
Unfortunately, in Python, that means that every module that invokes that line will create a module local reference to the connection. If the db module is reloaded with a sqlite in-memory database, all of the caller of "from django.db import connection" will *not* get the new database connection.
I have a patch for Django that will let you cleanly replace the django.db module in one shot.
Change History (9)
comment:4 Changed 9 years ago by adrian
- Resolution set to wontfix
- Status changed from new to closed
- Type set to defect