Update the custom models tests mixin to support Django 1.6, 1.8+.

Review Request #8682 — Created Jan. 30, 2017 and submitted

Information

Djblets
release-0.10.x
8b642f7...

Reviewers

Our TestModelsLoaderMixin, while working fine on Django 1.6, had some
problems on modern versions of Django. Models weren't gaining their
correct app labels and were appearing in two apps at once. We also were
attempting to register models that were imported from other modules
(like User, Site, etc.). Along with this, not all state was properly
cleared.

This change fixes the mixin for Django 1.8 and higher. This gives us
compatibility with Django 1.6 and 1.8 through 1.10. It does not support
Django 1.7 (which Djblets will not officially support anyway), due to
issues in Django 1.7 that were fixed in 1.8 involving ManyToManyFields
not being properly created in the database under these conditions.

Unit tests pass on 1.6, 1.8, 1.9, 1.10.

Description From Last Updated

These definitions aren't needed because they're only used when apps is None.

daviddavid

Do we want to call apps.clear_cache()?

daviddavid

This could be a generator expression instead of a list comprehension.

daviddavid
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 1)
     
     
     
    Show all issues

    These definitions aren't needed because they're only used when apps is None.

    1. What I was aiming for (in this and other changes) is to always have a version of each of these imports we can check for, and to keep lintian checkers from complaining. Pyflakes doesn't seem to care, though.

  3. djblets/testing/testcases.py (Diff revision 1)
     
     
    Show all issues

    Do we want to call apps.clear_cache()?

    1. unset_installed_apps calls this for us.

  4. djblets/testing/testcases.py (Diff revision 1)
     
     
     
     
     
    Show all issues

    This could be a generator expression instead of a list comprehension.

    1. Aiming to keep the return types the same between both versions. get_apps() returns a list.

  5. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/testing/testcases.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/testing/testcases.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (3ebacf7)
Loading...