Using different database with pytest Using different database with pytest sqlite sqlite

Using different database with pytest


--ds=test_settings is the way to go!

If you dont want to type out --ds=... every time you invoke py.test, you can add a pytest.ini with this contents:

[pytest]DJANGO_SETTINGS_MODULE = test_settings

As a side note: It is good practice to use the same type of database that you use in production when running your tests. pytest-django provides the --reuse-db option to re-use a MySQL/Postgres database between test runs, saving a lot of setup time when running a few tests for projects with lots of models.