#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):
Maybe it would be better to write these lines:
{{{
self.connection = backend.DatabaseWrapper(
settings_dict,
alias='__destroy_test_db__',
allow_thread_sharing=False)
self._destroy_test_db(test_database_name, verbosity)
}}}
As just
{{{
newconn = backend.DatabaseWrapper(...)
newconn.ops._destroy_test_db(test_database_name, verbosity)
}}}
The coding in the patch breaks the symmetrical linking between DBWrapper
and Ops. If you go from DBWrapper to Ops and then back to the connection
again, you don't actually end up into the same DBWrapper (or:
ops.connection.ops != ops). While that isn't critical at all, it might
cause a surprise some day.
But in any case the basic approach seems now correct. It is simple and
should prevent accidental access to production DB. It is easy to override
the default behavior by a custom `TestRunner`. So, I am +1 to commit of
this. It would be nice to test this somehow, even if the test can not be
included in the test suite. I try to see if I have time to write a small
custom testproject testing threads sharing etc this weekend.
--
Ticket URL: <https://code.djangoproject.com/ticket/10868#comment:21>
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.