#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: 0 | decision needed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by akaariai):
You could assert there is just one thread running post-tests, but that
places the assumption that there is no valid usage of additional
background threads when running tests. Maybe this is fine. If not, how
about:
- When setting up the tests, record all running threads:
pre_test_threads = set(t.name for t in threading.enumerate())
- When tests have ran, check that there are no new threads compared to
the pre-test set. If there are, call .join(timeout=1.0) on the threads. If
they have not exited after the timeout, do not change the settings for the
connections & destroy the databaseses. Error out.
This change would break tests for users who leave threads running knowing
the threads are not doing anything. Is that a problem? Should there be a
hook (or signal) you can use to setup/remove threads pre/post tests have
ran?
--
Ticket URL: <https://code.djangoproject.com/ticket/10868#comment:9>
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.