Added --postgres argument to runtests.py

Makes running the tests against PostgreSQL a bit easier
pull/1914/head
Karl Hobley 2015-11-09 12:04:50 +00:00
rodzic a8d3aca007
commit 126761db51
2 zmienionych plików z 22 dodań i 10 usunięć

Wyświetl plik

@ -71,17 +71,23 @@ an argument to ``runtests.py``::
**Testing against PostgreSQL**
By default, Wagtail tests against SQLite. If you need to test against a
different database, set the ``DATABASE_ENGINE`` environment variable to the
name of the Django database backend to test against::
By default, Wagtail tests against SQLite. You can switch to using PostgreSQL by
using the ``--postgres`` argument::
DATABASE_ENGINE=django.db.backends.postgresql_psycopg2 python runtests.py
This will create a new database called ``test_wagtail`` in PostgreSQL and run
the tests against it.
python runtests.py --postgres
If you need to use a different user, password or host. Use the ``PGUSER``, ``PGPASSWORD`` and ``PGHOST`` environment variables.
**Testing against a different database**
If you need to test against a different database, set the ``DATABASE_ENGINE``
environment variable to the name of the Django database backend to test against::
DATABASE_ENGINE=django.db.backends.mysql python runtests.py
This will create a new database called ``test_wagtail`` in MySQL and run
the tests against it.
**Testing Elasticsearch**
To test Elasticsearch, you need to have the ``elasticsearch`` package installed.

Wyświetl plik

@ -1,4 +1,5 @@
#!/usr/bin/env python
import sys
import os
import shutil
@ -6,8 +7,6 @@ import warnings
from django.core.management import execute_from_command_line
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT
os.environ['DJANGO_SETTINGS_MODULE'] = 'wagtail.tests.settings'
@ -17,10 +16,17 @@ def runtests():
warnings.simplefilter('default', DeprecationWarning)
warnings.simplefilter('default', PendingDeprecationWarning)
argv = sys.argv[:1] + ['test'] + sys.argv[1:]
args = sys.argv[1:]
if '--postgres' in args:
os.environ['DATABASE_ENGINE'] = 'django.db.backends.postgresql_psycopg2'
args.remove('--postgres')
argv = sys.argv[:1] + ['test'] + args
try:
execute_from_command_line(argv)
finally:
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT
shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)