Code

Opened 3 years ago

Closed 3 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.

Attachments (0)

Change History (5)

comment:1 Changed 3 years ago by ptone

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to 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

comment:2 Changed 3 years ago by anonymous

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 Changed 3 years ago by michaelritsema@…

  • Resolution invalid deleted
  • Status changed from closed to reopened

previous comment was from me. I'm reopening.

comment:4 Changed 3 years ago by aaugustin

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

comment:5 Changed 3 years ago by michaelritsema@…

  • Resolution set to invalid
  • Status changed from reopened to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.