use unittest2 on py26 to fix tests

This commit is contained in:
Alan Hamlett 2015-08-11 14:53:35 -07:00
parent 1e2a9b2a44
commit 5bf7b534f2
3 changed files with 20 additions and 10 deletions

View file

@ -1,11 +1,14 @@
language: python language: python
python: python:
- "2.6" - "2.6"
- "2.7" - "2.7"
- "3.3" - "3.3"
- "3.4" - "3.4"
# command to install dependencies # command to install dependencies
install: "pip install -r dev-requirements.txt" install:
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then travis_retry pip install --use-mirrors unittest2; fi
- travis_retry pip install --use-mirrors -r dev-requirements.txt
# command to run tests # command to run tests
script: nosetests script: nosetests
# use new travis-ci container-based infrastructure
sudo: false sudo: false

View file

@ -2,13 +2,18 @@
import logging import logging
import unittest
from wakatime.packages.requests.models import Response from wakatime.packages.requests.models import Response
try: try:
from mock import patch from mock import patch
except: except ImportError:
from unittest.mock import patch from unittest.mock import patch
try:
# Python 2.6
import unittest2 as unittest
except ImportError:
# Python >= 2.7
import unittest
from wakatime.base import main from wakatime.base import main
@ -21,8 +26,8 @@ class BaseTestCase(unittest.TestCase):
logging.disable(logging.CRITICAL) logging.disable(logging.CRITICAL)
def test_help_contents(self, mock_requests): def test_help_contents(self, mock_requests):
args = ['', '--help']
with self.assertRaises(SystemExit): with self.assertRaises(SystemExit):
args = ['', '--help']
retval = main(args) retval = main(args)
self.assertEquals(retval, 0) self.assertEquals(retval, 0)

View file

@ -1,5 +1,7 @@
[tox] [tox]
envlist = py26, py27, py33, py34 envlist = py26
[testenv] [testenv]
deps = -rdev-requirements.txt deps =
-rdev-requirements.txt
py26: unittest2
commands = nosetests commands = nosetests