Fix avatar unit tests on django 1.8+

Review Request #8809 — Created March 10, 2017 and submitted

Information

Djblets
release-0.10.x
8871730...

Reviewers

ConfigForms require User.get_profile to exist, but Django has
removed this method in modern versions, causing some test failures.
This patch adds a testcase decorator to re-implement the missing
method when it is not present.

Ran unit tests on Django 1.8 and 1.6: they passed!

Description From Last Updated

This should probably say that it will attach only if User.get_profile doesn't exist, and state that this is the default …

chipx86chipx86

Let's have this do a comparison to make sure User.get_profile is the version this function provides. That'll avoid a potential …

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

    This should probably say that it will attach only if User.get_profile doesn't exist, and state that this is the default on Django 1.7+ unless the consuming app manually adds it.

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

    Let's have this do a comparison to make sure User.get_profile is the version this function provides. That'll avoid a potential problem where an import by the test triggers a code path that adds a project-specific User.get_profile.

  4. 
      
brennie
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/avatars/tests.py
        djblets/testing/decorators.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/avatars/tests.py
        djblets/testing/decorators.py
    
    
  2. 
      
chipx86
  1. Ship It!
  2. 
      
brennie
Review request changed
Status:
Completed
Change Summary:
Pushed to release-0.10.x (4e7397c)
chipx86
  1. On Django 1.8, this is actually raising NotImplementedError in the tests that were failing before.

  2.