diff --git a/.travis.yml b/.travis.yml index 466bd40c0..fa70d3d03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,5 @@ language: python python: - "2.6" - "2.7" -install: - - pip install -r requirements.txt --use-mirrors - - python extras/scripts/create_local_settings.py -script: - - export DJANGO_SETTINGS_MODULE=tests.settings - - coverage run ./manage.py test tests && coverage report -m - - pep8 --max-line-length=150 --exclude="urls.py," --statistics openslides - - pep8 --max-line-length=150 --statistics tests +install: "pip install -r requirements.txt --use-mirrors" +script: "fab travis_ci" diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 000000000..7bbee78c9 --- /dev/null +++ b/fabfile.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" + Fabric file for OpenSlides developers. + + :copyright: 2011–2013 by OpenSlides team, see AUTHORS. + :license: GNU GPL, see LICENSE for more details. +""" + +import os +import webbrowser + +from fabric.api import local +from fabric.contrib import django + + +def test(module='tests'): + """ + Runs all unit tests for OpenSlides using coverage. The settings file + in the tests directory is used, therefor the environment + variable DJANGO_SETTINGS_MODULE is set to 'tests.settings'. + """ + django.settings_module('tests.settings') + local('coverage run ./manage.py test %s' % module) + + +def coverage(): + """ + Runs all tests and builds the coverage html files. The index of these + files is opened in the end. + """ + test() + local('coverage html') + webbrowser.open(os.path.join(os.path.dirname(__file__), 'htmlcov', 'index.html')) + + +def pep8(): + """ + Checks for PEP 8 errors in openslides and in tests. + """ + local('pep8 --max-line-length=150 --exclude="urls.py," --statistics openslides') + local('pep8 --max-line-length=150 --statistics tests') + + +def prepare_commit(): + """ + Does everything before a commit should be done. At the moment it + does the same as travis_ci() + """ + travis_ci() + + +def travis_ci(): + """ + Command that is run by Travis CI. + """ + test() + pep8() diff --git a/requirements.txt b/requirements.txt index b513b8588..6b8b536c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ reportlab==2.7 tornado==3.0.1 # required for travis +Fabric==1.6.0 coverage==3.6 django-discover-runner==0.3 pep8==1.4.5