Skip to content

Commit

Permalink
Configure tox to be able to run tests locally.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Feb 26, 2016
1 parent 3110780 commit cf93090
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.coverage
.venv/
__pycache__/
.tox/
29 changes: 13 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions tinymce/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf-8

import json
import os
from mock import patch, Mock
from unittest import skip

Expand All @@ -10,6 +11,8 @@

from tinymce.views import render_to_image_list

devnull = open(os.devnull, 'w')


class TestViews(TestCase):

Expand Down Expand Up @@ -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'])
Expand Down
26 changes: 26 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cf93090

Please sign in to comment.