From 5bf7b534f2c4f4c877ab9dd61a667d09a756023e Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Tue, 11 Aug 2015 14:53:35 -0700 Subject: [PATCH] use unittest2 on py26 to fix tests --- .travis.yml | 13 ++++++++----- tests/test_wakatime_base.py | 11 ++++++++--- tox.ini | 6 ++++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4523592..71cb471 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,14 @@ language: python python: - - "2.6" - - "2.7" - - "3.3" - - "3.4" + - "2.6" + - "2.7" + - "3.3" + - "3.4" # 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 script: nosetests +# use new travis-ci container-based infrastructure sudo: false diff --git a/tests/test_wakatime_base.py b/tests/test_wakatime_base.py index f6fac2b..29588d1 100644 --- a/tests/test_wakatime_base.py +++ b/tests/test_wakatime_base.py @@ -2,13 +2,18 @@ import logging -import unittest from wakatime.packages.requests.models import Response try: from mock import patch -except: +except ImportError: 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 @@ -21,8 +26,8 @@ class BaseTestCase(unittest.TestCase): logging.disable(logging.CRITICAL) def test_help_contents(self, mock_requests): + args = ['', '--help'] with self.assertRaises(SystemExit): - args = ['', '--help'] retval = main(args) self.assertEquals(retval, 0) diff --git a/tox.ini b/tox.ini index e2d7ac5..1a3e5db 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,7 @@ [tox] -envlist = py26, py27, py33, py34 +envlist = py26 [testenv] -deps = -rdev-requirements.txt +deps = + -rdev-requirements.txt + py26: unittest2 commands = nosetests