Fix avatar unit tests on django 1.8+

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

Barret Rennie
Djblets
release-0.10.x
8871730...
djblets

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!

  • 0
  • 0
  • 2
  • 0
  • 2
Description From Last Updated
Review Bot
  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. 
      
Christian Hammond
  1. 
      
  2. djblets/testing/decorators.py (Diff revision 1)
     
     
     
     

    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)
     
     
     

    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. 
      
Barret Rennie
Review Bot
  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. 
      
Christian Hammond
  1. Ship It!
  2. 
      
Barret Rennie
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (4e7397c)
Christian Hammond
  1. On Django 1.8, this is actually raising NotImplementedError in the tests that were failing before.

  2. 
      
Loading...