Add a mixin for writing unit tests with custom models.

Review Request #6245 — Created Aug. 19, 2014 and submitted

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.

Description From Last Updated

Your space got misplaced.

daviddavid
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/testing/testcases.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/testing/testcases.py
    
    
  2. 
      
chipx86
  1. Ugh, hold off.. I hit a bad problem with this.

  2. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/testing/testcases.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/testing/testcases.py
    
    
  2. 
      
david
  1. 
      
  2. djblets/testing/testcases.py (Diff revision 2)
     
     
    Show all issues

    Your space got misplaced.

  3. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (0d5c61f)