Add a mixin for writing unit tests with custom models.

Review Request #6245 — Created Aug. 20, 2014 and submitted — Latest diff uploaded

Information

Djblets
release-0.8.x
152e228...

Reviewers

Django doesn't make it easy to write unit tests that have their own
custom models. The test runner has to add an app with a models.py file
to INSTALLED_APPS, and the models have to live somewhere within that
directory. This is a lot of work, and it's hard to keep things clean
this way.

This introduces a new mixin that can be used to allow a file containing
unit tests to define custom models. The classes that need to use the
models simply define the models within the file, use the mixin, and then
operate on them.

The mixin handles the hard work of sticking the module in
INSTALLED_APPS, loading the module, and also creating a fake 'models'
module to satisfy Django's requirements.

Made use of this in a test suite. The models were synced to the database,
and I was able to test against them.