Why is Permission table populated in test database, while others aren't (django python)?

Viewed 55

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. pdb

My questions:

  1. Is the Permission table the only prepopulated table? (I have trouble inspecting other tables, because db is in-memory)
  2. 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?
1 Answers

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.

Docs

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

Related