Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#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


Given the following in

    '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 Tim Graham, 10 years ago

Easy pickings: unset
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

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.

comment:2 by Tim Graham, 10 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 Tim Graham, 10 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned

comment:4 by Tim Graham, 10 years ago

Has patch: set

I found how the option could be useful: PR

comment:5 by Markus Holtermann, 10 years ago

Triage Stage: AcceptedReady for checkin

Pull request looks good to me.

comment:6 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In a4f23eba2e690f1331fe35d6f29af42899e80395:

Fixed #23421 -- Corrected TEST SERIALIZE setting.

Thanks gkoller for the report.

comment:7 by Tim Graham <timograham@…>, 10 years ago

In 02aa3e30e9cb8e5be5c33082c3548e2a6e1b91cb:

[1.7.x] Fixed #23421 -- Corrected TEST SERIALIZE setting.

Thanks gkoller for the report and Markus Holtermann for review.

Note: See TracTickets for help on using tickets.
Back to Top