#21164: get_user_model() does not handle custom user models for testing purposes
-----------------------------------+---------------------------------------
     Reporter:  raymond.penners@…  |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  contrib.auth       |                  Version:  1.6-alpha-1
     Severity:  Release blocker    |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  1                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+---------------------------------------

Comment (by russellm):

 @carljm Re #7835: I agree that the documented behavior (CustomAuth being
 installed simply by virtue of being in the test suite) is a side effect,
 not strictly intended behavior. The purpose of that ticket came from my
 original work with schema evolution -- I was looking for ways to introduce
 a model for the purpose of a single test, and then reset that model at the
 end of the test (or reset the model *at* the end of the test to validate
 that the database matched what I expected). The key factor here is that a
 test case needed to be able to say "I need this model X to be in the app
 cache", and have that be the case fo a single test run. I wouldn't have
 expected models to exist simply by virtue of being in the test directory.

 To that end, an alternate approach to this ticket would be to require
 users to put:
 {{{
 from django.contrib.auth.tests.test_custom_user import CustomUser
 }}}
 at the top of the test that requires auth.CustomUser. This would cause an
 explicit loading of the required User model, and because of
 Meta:app_label, it will appear in the auth app as expected. The
 alternative it so get every app with a dependency on User to ship with a
 "CustomUser" that is a replica of the stub provided by contrib.auth, which
 seems like a waste of effort to me.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21164#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/084.2eea043dba0a72fd054bf0155b5a78b6%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to