#12530: Code in test classes can get access to live database
----------------------------------------+-----------------------------------
Reporter: Art_S | Owner: nobody
Status: closed | Milestone:
Component: Testing framework | Version: 1.1
Resolution: wontfix | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
----------------------------------------+-----------------------------------
Changes (by russellm):
* status: new => closed
* resolution: => wontfix
Comment:
I acknowledge that this is a problem, but there really isn't anything we
can do. A field defined like that will be instantiated when the class is
loaded, which occurs before the test framework has a chance to redirect
the database that is in use.
The other solution that you don't mention (and the solution that makes
more sense to me anyway) is to set up the field in the setUp() method.
During the call to setUp(), the test database will be in place. As an
added bonus, setUp() is called at the start of every test run,
guaranteeing that you won't have any artefact leakage between tests (i.e.,
test_1 modifies self.field, affecting the outcome of test_2).
Marking wontfix because there isn't really a fix, and the workaround is
preferable to the problematic syntax.
--
Ticket URL: <http://code.djangoproject.com/ticket/12530#comment:1>
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 [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.