Opened 13 years ago

Closed 13 years ago

#16857 closed New feature (invalid)

new flush db signal

Reported by: michaelritsema@… Owned by: nobody
Component: Core (Management commands) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It would be nice to be able to distinguish between a flush db and a syncdb during testing. I use the post_syncdb trigger to load data, it seems odd that I have to do this twice at the beginning of testing. I can't find anyway to distinguish between the two.

Change History (5)

comment:1 by Preston Holmes, 13 years ago

Resolution: invalid
Status: newclosed

are you testing the args in the signal - it is sent once per app.

Since flush is supposed to mimic syncdb fully - you should not be able to distinguish between them. The emit_post_sync_signal is only called once inside flush - so at this point, in the absence of a clearer description, I'll assume that you are hooking up your test loader to just the syncdb signal, and it is firing for each app (if I'm wrong, reopen with a clearer description of what is happening).

Also note that there is a hook for loading test specific fixtures:

https://docs.djangoproject.com/en/dev/topics/testing/#fixture-loading

comment:2 by anonymous, 13 years ago

Django tests uses the create_test_db function. This function does a syncdb followed by a flush. Because I load data based on the post_sync_signal, my data seeding routines are getting called twice. A solution to my problem would be to pass the load_initial_data variable through the post_sync_signal event. This way I can skip my special data seeding routines during this step much like the framework skips its SQL fixture loading.

I could submit a patch myself if you agree.

comment:3 by michaelritsema@…, 13 years ago

Resolution: invalid
Status: closedreopened

previous comment was from me. I'm reopening.

comment:4 by Aymeric Augustin, 13 years ago

Note that the behavior of post_syncdb and flush was recently clarified in the docs, see r16874 and r16877.

comment:5 by michaelritsema@…, 13 years ago

Resolution: invalid
Status: reopenedclosed
Note: See TracTickets for help on using tickets.
Back to Top