diff --git a/.travis.yml b/.travis.yml index c99d1242..e72e5b64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ sudo: false language: python cache: pip python: - - 2.6 - 2.7 - 3.3 - 3.4 @@ -12,7 +11,6 @@ install: - pip install -r requirements.txt - pip install requests-mock - pip install coveralls - - if [[ $TRAVIS_PYTHON_VERSION == "2.6" ]]; then pip install unittest2; fi script: - coverage run --source=requests_oauthlib -m nose after_success: diff --git a/requests_oauthlib/__init__.py b/requests_oauthlib/__init__.py index 56560ba8..3f20ecbe 100644 --- a/requests_oauthlib/__init__.py +++ b/requests_oauthlib/__init__.py @@ -1,3 +1,5 @@ +import logging + from .oauth1_auth import OAuth1 from .oauth1_session import OAuth1Session from .oauth2_auth import OAuth2 @@ -11,12 +13,4 @@ 'requests-oauthlib expects, please upgrade to 2.0.0 or later.') raise Warning(msg % requests.__version__) -import logging -try: # Python 2.7+ - from logging import NullHandler -except ImportError: - class NullHandler(logging.Handler): - def emit(self, record): - pass - -logging.getLogger('requests_oauthlib').addHandler(NullHandler()) +logging.getLogger('requests_oauthlib').addHandler(logging.NullHandler()) diff --git a/setup.py b/setup.py index ee8dce80..79b7ce12 100644 --- a/setup.py +++ b/setup.py @@ -5,10 +5,8 @@ import sys import re -try: - from setuptools import setup -except ImportError: - from distutils.core import setup +from setuptools import setup + # Get the version version_regex = r'__version__ = ["\']([^"\']*)["\']' @@ -24,20 +22,13 @@ APP_NAME = 'requests-oauthlib' -settings = dict() - - # Publish Helper. if sys.argv[-1] == 'publish': os.system('python setup.py sdist upload') sys.exit() -tests_require = ['mock', 'requests-mock'] -if sys.version_info < (2, 7): # Python 2.6 or lower - tests_require.append('unittest2') - -settings.update( +setup( name=APP_NAME, version=VERSION, description='OAuthlib authentication support for Requests.', @@ -57,7 +48,6 @@ 'License :: OSI Approved :: BSD License', 'Programming Language :: Python', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', @@ -66,8 +56,9 @@ 'Programming Language :: Python :: 3.6', ), zip_safe=False, - tests_require=tests_require, + tests_require=[ + 'mock', + 'requests-mock', + ], test_suite='tests' ) - -setup(**settings) diff --git a/tests/test_compliance_fixes.py b/tests/test_compliance_fixes.py index 8e9ee2df..05722c36 100644 --- a/tests/test_compliance_fixes.py +++ b/tests/test_compliance_fixes.py @@ -1,8 +1,5 @@ from __future__ import unicode_literals -try: - from unittest2 import TestCase -except ImportError: - from unittest import TestCase +from unittest import TestCase import requests import requests_mock diff --git a/tests/test_core.py b/tests/test_core.py index 31ebf2ad..52fd10b6 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -6,10 +6,7 @@ import requests_oauthlib import oauthlib import os.path -try: - from io import StringIO # python 3 -except ImportError: - from StringIO import StringIO # python 2 +from io import StringIO import unittest diff --git a/tests/test_oauth1_session.py b/tests/test_oauth1_session.py index 488062f9..75b24a55 100644 --- a/tests/test_oauth1_session.py +++ b/tests/test_oauth1_session.py @@ -3,15 +3,12 @@ import unittest import sys import requests +from io import StringIO from oauthlib.oauth1 import SIGNATURE_TYPE_QUERY, SIGNATURE_TYPE_BODY from oauthlib.oauth1 import SIGNATURE_RSA, SIGNATURE_PLAINTEXT from requests_oauthlib import OAuth1Session -try: - from StringIO import StringIO -except ImportError: - from io import StringIO try: import cryptography @@ -25,19 +22,6 @@ unicode_type = unicode bytes_type = str -# Monkey patch Python 2.6 unittest -if not hasattr(unittest, 'SkipTest'): - unittest.SkipTest = RuntimeWarning - unittest.TestResult.real_add_error = unittest.TestResult.addError - - def patched_addError(self, test, exc_info): - if exc_info[0] is RuntimeWarning: - print(str(exc_info[1]), end=' ', file=sys.stderr) - return - else: - self.real_add_error(test, exc_info) - unittest.TestResult.addError = patched_addError - TEST_RSA_KEY = ( "-----BEGIN RSA PRIVATE KEY-----\n" diff --git a/tests/test_oauth2_session.py b/tests/test_oauth2_session.py index dbc1b44d..e5892cab 100644 --- a/tests/test_oauth2_session.py +++ b/tests/test_oauth2_session.py @@ -4,10 +4,7 @@ import time from base64 import b64encode from copy import deepcopy -try: - from unittest2 import TestCase -except ImportError: - from unittest import TestCase +from unittest import TestCase from oauthlib.common import urlencode from oauthlib.oauth2 import TokenExpiredError, OAuth2Error diff --git a/tox.ini b/tox.ini index cf640581..fd85408d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26, py27, py33, py34, py35, py36, pypy +envlist = py27, py33, py34, py35, py36, pypy [testenv] deps= @@ -9,12 +9,3 @@ deps= coveralls requests-mock commands= coverage run --source=requests_oauthlib -m nose - -[testenv:py26] -deps= - -r{toxinidir}/requirements.txt - nose - mock - coveralls - unittest2 - requests-mock