Testing with Django: stuck at test database creation
Asked Answered
S

1

9

I was having some trouble running tests for my app and I managed to solved them in this previous post.

Now executing python manage.py test does go through without raising any errors, but it gets stuck at database creation:

When the test database doesn't exist it does create as I can see in pgAdmin, but it gets stuck in the process with this message:

Creating test database for alias 'default'...

It is stuck here forever, so when I finish the process manually and run test again, it says the database exists and prompts me to either delete it and create anew, or cancel the process. I type 'yes' and the process is stuck again with this other message:

Destroying old test database 'default'...

With pgAdmin open I can't immediately see any new test_dbname database, but if I close and open it again I can, there test_dbname is, but the test task is just stuck there and doesn't go through...

A workaround to this problem is this solution, disabling migrations. This way it no longer gets stuck at those messages and the default test is run.

.
----------------------------------------------------------------------
Ran 1 test in 0.002s

OK

However, this just seems to be a bad solution and cheating. There must be a good reason migrations are run when running tests so I don't see a good reason to disable them.

Sandusky answered 13/10, 2017 at 13:7 Comment(3)
What type of database are you using?Slusher
@SamBobel I am using PostgreSQLSandusky
Did you run it on high verbosity? It is most likely getting stuck on one of your migrations, and that will tell you which one.Slusher
S
23

Try running python manage.py test --verbosity=2. That'll tell you exactly where it's getting stuck, and you can go from there.

Slusher answered 13/10, 2017 at 20:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.