#7835: Provide the ability for model definitions that are only availably during
testing
----------------------------------------+-----------------------------------
          Reporter:  russellm           |         Owner:  nobody             
            Status:  new                |     Milestone:                     
         Component:  Testing framework  |       Version:  SVN                
        Resolution:                     |      Keywords:  feature test models
             Stage:  Accepted           |     Has_patch:  0                  
        Needs_docs:  0                  |   Needs_tests:  0                  
Needs_better_patch:  0                  |  
----------------------------------------+-----------------------------------
Comment (by julien):

 A discussion came about on the user-list about this:
 http://groups.google.com/group/django-
 users/browse_thread/thread/559aa0a2d074a7b5

 I wrote a patch based on Russell's feedback. The proposed API is as
 follows:

 {{{
 class MyMetaTest(TestCase):
     installed_apps = ['fakeapp','otherapp']
     extra_apps = ('yetanotherapp',)

     def test_stuff(self):
       ...
 }}}

  * `installed_apps` and `extra_apps` can either be tuple or a list. They
 can coexist or be used individually.

  * `installed_apps` overrides the settings INSTALLED_APPS.

  * `extra_apps` adds the given apps either to INSTALLED_APPS or to
 `installed_apps` if it also exists.

 Now, responding specifically to Russell's remarks:

 "Obviously, the test applications need to be:
  1. Added to INSTALLED APPS and the app cache on startup
  2. Installed in the app cache before the syncdb caused by the pre-test
 database flush takes effect. You shouldn't need to manually invoke syncdb.
  3. Removed from INSTALLED_APPS and the app cache on teardown"


 My answers below:
  1. Done
  2. Done, but I think `syncdb` still needs to be invoked to create the
 extra tables, otherwise `flush` will raise an exception saying it cannot
 find those tables.
  3. INSTALLED_APPS is properly restored, but I could not find a way to
 unload the apps from the cache. Should an extra method be written in the
 AppStore class (`unload_app()` and/or `unregister_models()`)?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7835#comment:4>
Django <http://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 post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to