From a447e53ba7ed81207eaf19eb22f711388b6ac7ed Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 18 Mar 2015 19:03:43 +0000 Subject: [PATCH 1/5] Run tests with SQLite by default SQLite doesn't require any initial setup and is significantly faster than PostgreSQL Also removed USER/PASSWORD/HOST vars. Postgres users can pass in PGUSER, PGPASSWORD and PGHOST environment variables instead --- wagtail/tests/settings.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/wagtail/tests/settings.py b/wagtail/tests/settings.py index 96d919cbd..03f2d72e8 100644 --- a/wagtail/tests/settings.py +++ b/wagtail/tests/settings.py @@ -11,13 +11,8 @@ MEDIA_URL = '/media/' DATABASES = { 'default': { - 'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.postgresql_psycopg2'), - 'NAME': os.environ.get('DATABASE_NAME', 'wagtaildemo'), - 'TEST_NAME': os.environ.get('DATABASE_NAME', 'test_wagtaildemo'), - 'USER': os.environ.get('DATABASE_USER', 'postgres'), - 'PASSWORD': os.environ.get('DATABASE_PASS', None), - 'HOST': os.environ.get('DATABASE_HOST', None), - 'PORT': os.environ.get('DATABASE_PORT', None), + 'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.sqlite3'), + 'NAME': os.environ.get('DATABASE_NAME', 'wagtail'), } } From bff488d8fb5d27e578781ff28d1a71f2cc437d0c Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 18 Mar 2015 19:05:31 +0000 Subject: [PATCH 2/5] Removed .drone.yml --- .drone.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index c9af87684..000000000 --- a/.drone.yml +++ /dev/null @@ -1,11 +0,0 @@ -image: kaedroho/django-base -env: - - DATABASE_HOST=postgres - - ELASTICSEARCH_URL=http://elasticsearch:9200/ -script: - - pip3.4 install mock python-dateutil pytz elasticsearch - - python3.4 setup.py install - - python3.4 runtests.py -services: - - postgres - - dockerfile/elasticsearch From 55ce9f761e375c3b6d5111157a93e0776ea5797c Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 18 Mar 2015 19:06:15 +0000 Subject: [PATCH 3/5] Added *.swp and /venv to gitignore .swp files are made automatically by vim and are easy to accidentally commit /venv is a very common place to put a virtual environment which we wouldn't want to be committed --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bd904efc9..c8ceb2743 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.swp *.pyc .DS_Store /.coverage @@ -6,3 +7,4 @@ /wagtail.egg-info/ /docs/_build/ /.tox/ +/venv From 23ee87243b64157ae2a658c37a35f92514f45c8d Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 18 Mar 2015 19:13:20 +0000 Subject: [PATCH 4/5] Added Pillow to dev requirements --- requirements-dev.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 166dd353d..d4a4634a4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,9 @@ -# For coverage and PEP8 linting -coverage>=3.7.0 -flake8>=2.2.0 +# Required for running the tests mock>=1.0.0 python-dateutil>=2.2 pytz>=2014.7 +Pillow>=2.7.0 + +# For coverage and PEP8 linting +coverage>=3.7.0 +flake8>=2.2.0 From 5aa6ed2c2a91a709ac256ee63eee981fc71ad3bb Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 18 Mar 2015 19:44:30 +0000 Subject: [PATCH 5/5] Docs for running the tests Fixes #1004 --- docs/howto/contributing.rst | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/docs/howto/contributing.rst b/docs/howto/contributing.rst index 797176997..f43c63d46 100644 --- a/docs/howto/contributing.rst +++ b/docs/howto/contributing.rst @@ -18,6 +18,70 @@ Coding guidelines * Python 2 and 3 compatibility. All contributions should support Python 2 and 3 and we recommend using the `six `_ compatibility library (use the pip version installed as a dependency, not the version bundled with Django). * Tests. Wagtail has a suite of tests, which we are committed to improving and expanding. We run continuous integration at `travis-ci.org/torchbox/wagtail `_ to ensure that no commits or pull requests introduce test failures. If your contributions add functionality to Wagtail, please include the additional tests to cover it; if your contributions alter existing functionality, please update the relevant tests accordingly. +Running the unit tests +~~~~~~~~~~~~~~~~~~~~~~ + +In order to run Wagtail's test suite, you will need to install some dependencies first. We recommend installing these into a virtual environment. + + +**Setting up the virtual environment** + +If you are using Python 3.3 or above, run the following commands in your shell +at the root of the Wagtail repo:: + + pyvenv venv + source venv/bin/activate + python setup.py develop + pip install -r requirements-dev.txt + +For Python 2, you will need to install the ``virtualenv`` package and replace +the first line above with: + + virtualenv venv + +**Running the tests** + +With your virtual environment active, run the following command to run all the +tests:: + + python runtests.py + +**Running only some of the tests** + +At the time of writing, Wagtail has nearly 1000 tests which takes a while to +run. You can run tests for only one part of Wagtail by passing in the path as +an argument to ``runtests.py``:: + + python runtests.py wagtail.wagtailcore + +**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:: + + 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. + +If you need to use a different user, password or host. Use the ``PGUSER``, ``PGPASSWORD`` and ``PGHOST`` environment variables. + +**Testing Elasticsearch** + +To test Elasticsearch, you need to have the ``elasticsearch`` package installed. + +Once installed, Wagtail will attempt to connect to a local instance of +Elasticsearch (``http://localhost:9200``) and use the index ``test_wagtail``. + +If your Elasticsearch instance is located somewhere else, you can set the +``ELASTICSEARCH_URL`` environment variable to point to its location:: + + ELASTICSEARCH_URL=http://my-elasticsearch-instance:9200 python runtests.py + +If you no longer want Wagtail to test against Elasticsearch, uninstall the +``elasticsearch`` package. + Styleguide ~~~~~~~~~~