#19167: When running tests, Django accesses the database referred to in settings
-------------------------------+------------------------------------
Reporter: EvilDMP | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by akaariai):
Here is a proof-of-concept for disabling queries during import time:
https://github.com/akaariai/django/commit/1b99fcee4c0b3782d3136744cfaaccfea1d535e0
- I quickly tested this on different databases using a test project which
does import time "!SomeModel.objects.get(pk=1)" query. Seemed to work.
And, Django's test suite didn't complain on sqlite either.
IMO we should do the disabling of queries. This will only hurt users who
do import time queries when running tests. They will benefit from fixing
their code. If this change isn't possible for them, they can just do
_enable_connections().
The implementation only ensures that the main thread can't run queries
(django.db.connections is thread-local). I wonder if there is any point in
making sure all threads are prevented from running queries...
I don't see any easy way to test this.
--
Ticket URL: <https://code.djangoproject.com/ticket/19167#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 https://groups.google.com/groups/opt_out.