#34222 closed Bug (invalid)
Django unit tests hang when running against a Postgres database
Reported by: | Adrian Garcia | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 4.1 |
Severity: | Normal | Keywords: | |
Cc: | Egor R | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I am trying to get the Django library tests running so I can develop a custom backend and everything works fine with the default SQLite settings file, but when I provide one for Postgres random tests will hang with no error. To debug, I am running the test suite with runtests.py --noinput --parallel=1 -v 2 --settings test_postgres
test_postgres.py:
DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", "NAME": "postgres", "USER": "user", "PASSWORD": "password", "HOST": "127.0.0.1", "PORT": "5432", }, "other": { "ENGINE": "django.db.backends.postgresql", "NAME": "postgres", "USER": "user", "PASSWORD": "password", "HOST": "127.0.0.1", "PORT": "5432", }, } SECRET_KEY = "django_tests_secret_key" # Use a fast hasher to speed up tests. PASSWORD_HASHERS = [ "django.contrib.auth.hashers.MD5PasswordHasher", ] DEFAULT_AUTO_FIELD = "django.db.models.AutoField" USE_TZ = False
Am I doing something wrong, or do these test cases hang for others? I cloned the 4.1.x repo and reset it to 2ff479f to specifically test against Django 4.1.4 and it consistently crashes *after* multiple_database.tests.AuthTestCase
runs. If I get it working, I'll compile a list of test classes I have to skip to get the tests to run through without hanging.
Change History (4)
follow-up: 3 comment:1 by , 23 months ago
comment:2 by , 23 months ago
Cc: | added |
---|
comment:3 by , 23 months ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Replying to Egor R:
You have the same name for "default" and "other" databases, and they should be different. Try changing that and see if that helps.
That solved it, knew it would probably be something incredibly dumb. Now that I've done a little more Googling it looks like I should have just copied the Django Docker Box config instead of writing my own.
It's interesting that there are no checks to see if there are two DB configs for the same database, is there a use case for that?
comment:4 by , 23 months ago
I'm not that deeply involved with the project, so can't answer that. You might want to start a discussion on the Django forum to gauge interest for that.
You have the same name for "default" and "other" databases, and they should be different. Try changing that and see if that helps.