kopia lustrzana https://github.com/wagtail/wagtail
Added --postgres argument to runtests.py
Makes running the tests against PostgreSQL a bit easierpull/1914/head
rodzic
a8d3aca007
commit
126761db51
|
@ -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.
|
||||
|
|
12
runtests.py
12
runtests.py
|
@ -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)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue