Tool: PEP8 Style Checker Processed Files: djblets/testing/testcases.py Tool: Pyflakes Processed Files: djblets/testing/testcases.py
Add a mixin for writing unit tests with custom models.
Review Request #6245 — Created Aug. 19, 2014 and submitted
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 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.
Your space got misplaced.
Ugh, hold off.. I hit a bad problem with this.
Tool: Pyflakes Processed Files: djblets/testing/testcases.py Tool: PEP8 Style Checker Processed Files: djblets/testing/testcases.py