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?
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With