Running django test suite for a specific backend driver

How to use the django test suite for testing the compatibility of a backend driver.

Hi @suraj-ora-2020 — Welcome.

In summary, you need to provide a settings file with the DATABASES setting you want to run.

See the contributing guide here for testing other Python versions and database backends, but also the note on using the django-docker-box is worth following.

The default settings are in tests/test_sqlite.py.

So something like the simplest settings for Postgres (running locally) might be:

# Saved as tests/test_postgres.py

from test_sqlite import *  # NOQA

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'USER': 'YOURUSERNAME',
        'PASSWORD': 'YOURPASSWORD',
        'NAME': 'django',
    },
    'other': {
        'ENGINE': 'django.db.backends.postgresql',
        'USER': 'YOURUSERNAME',
        'PASSWORD': 'YOURPASSWORD',
        'NAME': 'django2',
    },
}

Then you’d run that with ./runtests.py --settings=test_postgres

Hopefully that gets you going. :slightly_smiling_face:

2 Likes

Thanks for the reply.
I want to be specific with cx_Oracle.But i am getting error even though i am exporting the path to instantclient.

django.db.utils.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: “dlopen(libclntsh.dylib, 1): image not found”. See https://oracledb.readthedocs.io/en/latest/user_guide/installation.html for help

For Oracle I’d suggest using the django-docker-box. Following the instructions here should work.

Hi @carltongibson . After installing the docker i was going through the steps as suggested in the documentation for oracle but it threw some error.

command → docker-compose run oracle-db
Pulling oracle-db (sath89/oracle-12c:)…
ERROR: pull access denied for sath89/oracle-12c, repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied