Our company uses a fairly complex Django app (Python 3.6.4) and I’ve written a unit test which passes locally but when pushing into GitHub it’s a no-go. An in memory SQLite DB, we’ve routed this to a SparkDB, which seem to pass, but to get back to point the UT is created (by default) for the tests. When my Travis CI build runs the same tests the tests pass but the test command fails with the following error:
File "/home/travis/virtualenv/python3.6.5/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 301, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: near "SCHEMA": syntax error
The command "python manage.py test --settings=myapp.dev_settings" exited with 1.
One strange thing I notice is that when the tests are run on Travis, it’s says it’s reusing an existing DB and never destroys it after the tests are run:
$ python manage.py test --settings=myapp.dev_settings
Using existing test database for alias ‘default’…
I don’t really get that, because it should be an in memory DB and when I run it locally, a new database is created each time:
Creating test database for alias 'default'...
. . .
Destroying test database for alias 'default'...
My dev_settings.py
file has a sqlite db on the filesystem, but that is only used for running the local development server:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
Travis installs all the dependencies and they match my local environment (I’m fairly sure).
All help appreciated.