While playing around with django testing I noticed that Permission
table in test database is not empty (like, for example, User
and tables of models defined by me) - it has all permissions from the real table.
My questions:
- Is the
Permission
table the only prepopulated table? (I have trouble inspecting other tables, because db is in-memory) - Where is it prepopulated (I also couldn't find)? Upon setting up test suit? Or just before executing each test method? Or maybe added to queryset everytime it is requested?
CodePudding user response:
Permissions are created when you run manage.py migrate
, there is a signal handler that listens to the post_migrate
signal and creates these permissions for every new model.
The ContentType table will also be populated in a similar manner
When you run your tests, your test DB will have your migrations applied to it