How do you make Django load a sqlite3 db file into memory when running unittests, instead of generating a new database and initializing schema from scratch?
I have some large JSON fixtures that take a while for Django to load for each test. A workaround I'm imagining is to generate a "template" sqlite3 database, load all schema and fixtures into that, and then simply use that for each unittest, bypassing all fixture loading. Obviously, I would have to update this template whenever I change my schema or fixtures, but that's an acceptable tradeoff if it means each unittest will take seconds instead of minutes to run.
I've accomplished the first step, generated the template database, by: * specifying the db filename in the 'TEST_NAME' database settings field * running a specific unittest that does nothing, so Django will only generate schema and load fixtures * monkeypatched django.test.running.DiscoverRunner.teardown_databases to do nothing, so I can retrieve the db file and save it as my database template
But now I'm stuck on how to get Django to use this file. If I keep the file as my TEST_NAME parameter, Django will simply delete it and regenerate it...but also continue to write it to the filesystem, making it almost 10x slower than the in-memory Sqlite3 database.