diff --git a/.gitignore b/.gitignore index cdd4cff6..3521ba0e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ .coverage .venv/ __pycache__/ +.tox/ diff --git a/.travis.yml b/.travis.yml index 0925a05c..5108aefe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,18 @@ language: python -python: - - "2.7" - - "3.4" - +python: 2.7 +env: + - TOX_ENV=py27-django16 + - TOX_ENV=py27-django17 + - TOX_ENV=py27-django18 + - TOX_ENV=py27-django19 + - TOX_ENV=py34-django17 + - TOX_ENV=py34-django18 + - TOX_ENV=py34-django19 + - TOX_ENV=flake8 install: - - pip install -e . - - pip install $DJANGO - - pip install coverage flake8 mock pyenchant + - pip install tox script: - - export DJANGO_SETTINGS_MODULE=testtinymce.settings - - export PYTHONPATH=$PWD:$PWD/testtinymce:$PYTHONPATH - - flake8 tinymce --ignore=E501,E402 - - coverage run --source=tinymce setup.py test + - tox -e $TOX_ENV after_success: + - pip install coveralls - coveralls -env: - - DJANGO="Django==1.6.11" - - DJANGO="Django==1.7.8" - - DJANGO="Django==1.8.8" - - DJANGO="Django==1.9.2" diff --git a/Makefile b/Makefile index c6b56d89..5dcf695e 100644 --- a/Makefile +++ b/Makefile @@ -16,19 +16,22 @@ $(INSTALL_STAMP): $(PYTHON) setup.py $(VENV)/bin/pip install -Ue . touch $(INSTALL_STAMP) -install-dev: $(INSTALL_STAMP) $(DEV_STAMP) +install-dev: $(INSTALL_STAMP) $(DEV_STAMP) setup.py $(DEV_STAMP): $(PYTHON) - $(VENV)/bin/pip install django flake8 mock pyenchant coverage + $(VENV)/bin/pip install django flake8 mock pyenchant coverage tox touch $(DEV_STAMP) virtualenv: $(PYTHON) $(PYTHON): $(VIRTUALENV) $(VENV) -tests: install-dev +tests-once: install-dev $(VENV)/bin/coverage run --source=tinymce setup.py test $(VENV)/bin/coverage report +tests: install-dev tox.ini + $(VENV)/bin/tox + flake8: install-dev $(VENV)/bin/flake8 tinymce --ignore=E501,E402 diff --git a/tinymce/tests/test_views.py b/tinymce/tests/test_views.py index b681b880..3d8e0bbf 100644 --- a/tinymce/tests/test_views.py +++ b/tinymce/tests/test_views.py @@ -1,6 +1,7 @@ # coding: utf-8 import json +import os from mock import patch, Mock from unittest import skip @@ -10,6 +11,8 @@ from tinymce.views import render_to_image_list +devnull = open(os.devnull, 'w') + class TestViews(TestCase): @@ -72,8 +75,9 @@ def test_spell_check_unknown(self, enchant_mock): 'method': 'test', 'params': ['en', 'test'] }) - response = self.client.post('/tinymce/spellchecker/', - body, content_type='application/json') + with patch('sys.stderr', devnull): + response = self.client.post('/tinymce/spellchecker/', + body, content_type='application/json') result_ok = b'Error running spellchecker' self.assertEqual(200, response.status_code) self.assertEqual('text/html; charset=utf-8', response['Content-Type']) diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..2cf9c4d2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,26 @@ +[tox] +envlist = + py27-django{16,17,18,19}, + py34-django{17,18,19}, + flake8 + +[testenv] +deps = + django16: Django>=1.6,<1.7 + django17: Django>=1.7,<1.8 + django18: Django>=1.8,<1.9 + django19: Django>=1.9,<1.10 + coverage + mock + pyenchant +commands = + python setup.py develop + coverage run --branch --source=tinymce setup.py test + coverage report -m --omit=tinymce/test* + pip freeze + +[testenv:flake8] +deps = + flake8 +commands = + flake8 tinymce --ignore=E501,E402