Opened 13 years ago
Closed 13 years ago
#16857 closed New feature (invalid)
new flush db signal
Reported by: | 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 , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 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 , 13 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
previous comment was from me. I'm reopening.
comment:4 by , 13 years ago
comment:5 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
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