Reputation: 1192
When I run my unit test using Django-pytest I keep getting the following error.
django.db.utils.OperationalError: (1045, "Access denied for user 'ruach'@'localhost' (using password: YES)")
. I am using an sqlite database locally which requires no password and using the decorator @pytest.mark.django_db
to read back inserted values in the database so I am unsure what else could be causing this.
I have run unit tests successfully in the past with the configuration so I am puzzled as to what is causing test runner to be denied access.
settings.py
...
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
tests.py
@pytest.mark.django_db
def test_create_and_save_invoices():
...
Upvotes: 1
Views: 1127
Reputation: 499
Something else (perhaps a python manage.py runserver
command) is probably using your db.sqlite3
file mentioned in your settings.py
.
Make sure you don't have any running commands, and try deleting your db.sqlite3
file just to be sure.
Once your tests are working again, isolate them from your dev environment by creating a custom settings module that uses a different database file.
Upvotes: 0