Relation does not exist when running unit tests

Hello everyone!

I am having a problem with my unit tests. When running python manage.py test, I am getting the error:
“relation “auth_user” does not exist”.

I have manually checked my postgres database and the table is there, makemigrations and migrate are normally creating each table.

In a desperate attempt, I have tried dropping the user and database from postgres, creating them from new and migrating again. All goes alright but when running python manage.py test I get that error.

For context, the postgres database and connection all works as expected with all the right permissions and privileges.

For those stumbling upon this thread, I have resolved the issue.

The problem was a third party library that required migrations but did not ship with migration files. Because of this, makemigrations was not automatically catching that application and creating migration files, so the test database could not properly run migrations.

I found this out in the more verbose stacktrace using python manage.py test -v 3