Django test api code : Got an error creating the test database: database "test_postgres" already exists

Viewed 353

I made test code for my APIs(Django web framework).

It ran with no errors about 3 hours ago(It is not first time running test codes(more than 1k times))

How should I debug?? Im using macOS.

directory is my_project/order_api/tests/test_order1.py

I ran the code by clicking arrow in test_order1.py file.

This is DATABASE setting

DATABASES = {
"default": {
    "ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.postgresql"),
    "NAME": os.environ.get("SQL_DATABASE", "postgres"),
    "USER": os.environ["SQL_USER"],
    "PASSWORD": os.environ["SQL_PASSWORD"],
    "HOST": os.environ["SQL_HOST"],
    "PORT": os.environ["SQL_PORT"],
    },
}

This is Error Message

Creating test database for alias 'default'...
Got an error creating the test database: database "test_postgres" already exists

Type 'yes' if you would like to try deleting the test database 'test_postgres', or 'no' to cancel: 

yes


Destroying old test database for alias 'default'...
Got an error recreating the test database: database "test_postgres" is being accessed by other users
DETAIL:  There is 1 other session using the database.
0 Answers
Related