#23421 closed Bug (fixed)
dict get for TEST_SERIALIZE in django.test.runner.setup_databases() always return True
| Reported by: | Guido Kollerie | Owned by: | Tim Graham |
|---|---|---|---|
| Component: | Testing framework | Version: | 1.7 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Given the following in settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
# ....
'TEST_SERIALIZE': False,
}
}
The call serialize=connection.settings_dict.get("TEST_SERIALIZE", True) on line 299 in django.test.runner.setup_databases will always be set to True as TEST_SERIALIZE is somewhere transformed into:
settings_dict = {
'TEST': {
'SERIALIZE`: True,
# ...
},
# ...
}
Hence the key lookup always fails, and get() will use the supplied default value of True. A possible fix will be to rewrite that call to something like:
serialize=connection.settings_dict["TEST"].get("SERIALIZE", True)
Change History (7)
comment:1 by , 11 years ago
| Easy pickings: | unset |
|---|---|
| Severity: | Normal → Release blocker |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 11 years ago
Andrew says, "I think it was meant to be a way to turn off the full serialization of data using loaddata during test runs; however it's useless due to TransactionTestCases, so perhaps should be excised."
Was there a use case where you needed to set it to False?
comment:3 by , 11 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:5 by , 11 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Pull request looks good to me.
comment:6 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Added in [8c12d51e]. Not sure what the intention was, but documenting that it should be set in the test dictionary seems okay. It needs documentation as well.