0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-25 13:10:14 +01:00
wagtail/tox.ini
David Beitey 67235accfc Improve database settings and docs for tests (#6585)
This change makes several improvements:

* Use in-memory SQLite database for test migrations

  The default database is SQLite but its NAME (which SQLite uses as the
  filename) was `wagtail`, which isn't valid since
  the wagtail codebase already has a `wagtail/` directory.  Trying to
  run migration creation commands
  (https://docs.wagtail.io/en/latest/contributing/developing.html#running-migrations-for-the-test-app-models)
  produced an error:

  django.db.utils.OperationalError: unable to open database file

  because of this conflict.

  This change uses an in-memory database as the default database for
  tests. If DATABASE_NAME were set to a real file name, then
  running the migration command with SQLite creates an empty db with
  this filename on running `django-admin`.

  Other non-SQLite engines continue to use the original `wagtail` name,
  meaning that the `test_wagtail` database gets created just as before.

* Modifies the default values for database USER, PASSWORD, HOST etc to
  being an empty string rather than None, to match Django's
  [defaults](https://docs.djangoproject.com/en/stable/ref/settings/#host).
  This helps avoid any potential issues when Django and database engines
  are expecting this being a string.

* Adds documentation to `developing.rst` regarding installation of
  required database modules and available environment variables for database
  connection customisation

* Normalises the DATABASE_PASSWORD tests environment variable to match
  the name in Django's database settings object
2020-12-09 15:28:44 +00:00

64 lines
2.0 KiB
INI

[tox]
skipsdist = True
usedevelop = True
envlist = py{36,37,38,39}-dj{22,30,31,31stable,master}-{sqlite,postgres,mysql,mssql}-{elasticsearch7,elasticsearch6,elasticsearch5,noelasticsearch}-{customuser,emailuser}-{tz,notz},
[testenv]
install_command = pip install -e ".[testing]" -U {opts} {packages}
commands =
elasticsearch5: coverage run runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch5
elasticsearch6: coverage run runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch6
elasticsearch7: coverage run runtests.py wagtail.search wagtail.documents wagtail.images --elasticsearch7
noelasticsearch: coverage run runtests.py {posargs}
basepython =
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9
deps =
django-sendfile==0.3.6
Embedly
dj22: Django>=2.2,<2.3
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
dj31stable: git+https://github.com/django/django.git@stable/3.1.x#egg=Django
djmaster: git+https://github.com/django/django.git@master#egg=Django
postgres: psycopg2>=2.6
mysql: mysqlclient>=1.4,<2
elasticsearch5: elasticsearch>=5,<6
elasticsearch5: certifi
elasticsearch6: elasticsearch>=6.4.0,<7
elasticsearch6: certifi
elasticsearch7: elasticsearch>=7,<8
elasticsearch7: certifi
setenv =
postgres: DATABASE_ENGINE=django.db.backends.postgresql
mysql: DATABASE_ENGINE=django.db.backends.mysql
mysql: DATABASE_HOST=localhost
mysql: DATABASE_USER=root
sqlite: DATABASE_NAME=wagtail.db
emailuser: USE_EMAIL_USER_MODEL=yes
notz: DISABLE_TIMEZONE=yes
# Specific for Appveyor, see:
# https://www.appveyor.com/docs/services-databases/#sql-server-2016
mssql: DATABASE_ENGINE=sql_server.pyodbc
mssql: DATABASE_HOST=(local)\SQL2016
mssql: DATABASE_NAME=master
mssql: DATABASE_USER=sa
mssql: DATABASE_PASSWORD=Password12!
[testenv:flake8]
basepython=python3.6
deps=flake8>=3.6.0
commands=flake8