#10868: _destroy_test_db exposes the production database to possibly destructive
actions from the unit tests
-------------------------------------+-------------------------------------
     Reporter:  ovidiu               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Testing framework    |                  Version:
     Severity:  Release blocker      |               Resolution:
     Keywords:  django.test          |             Triage Stage:  Design
    Has patch:  1                    |  decision needed
  Needs tests:  0                    |      Needs documentation:  0
Easy pickings:  0                    |  Patch needs improvement:  0
                                     |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by akaariai):

 - Why do the settings_dict.copy(), set old_name for the mirrors? If the
 connection settings are not going to be restored, then why restore them
 for the main thread? The same goes for the else branch in the if destroy:
 ... else.
   - This is going to be hard to test. I don't know how the test runner is
 tested...
   - I don't think there is anything to do for thread-shared DBWrappers.
 Except, maybe this idea would work:

 Why not create a new DBWrapper just for dropping the test database? This
 way the connection is guaranteed to not be shared, and it is guaranteed
 that the changes do not need reverting (as you don't touch anything in
 django.db.connections at all). So, all in all, it might be possible that
 teardown_databases() could be this:
 {{{
 for connection, old_name, destroy in old_names:
     if destroy:
         connection.creation.destroy_test_db(old_name, self.verbosity)
 }}}
 And connection.creation.destroy_test_db would instantiate a totally new
 DBWrapper connecting to old_name for test database teardown.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/10868#comment:19>
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 post to this group, send email to [email protected].
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