bright
bright

Reputation: 189

how to test django project

I wrote some test case to test my django project, when I run them in jenkins it always create a default database, I want to test my project with my own database, how to do?

Upvotes: 5

Views: 218

Answers (1)

Austin Phillips
Austin Phillips

Reputation: 15776

Django always expects to have a default database as described in the documentation for the DATABASES setting.

The default tags is simply the name by which you refer to the database, not the name of the database itself. In the documentation example above, even though the database handle is default, the name of the database itself is mydatabase.

When you're testing, it is usual to use a different database than your production database and for this you can use the TEST_NAME specification for the database. The following settings.py shows the names of the databases used during production and unit testing.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'mydatabase',
        'TEST_NAME': 'mytestdatabase'
    }
}

The following link gives some useful information on testing. https://docs.djangoproject.com/en/dev/topics/testing/

Upvotes: 2

Related Questions