Skip to content

Commit

Permalink
Drop support for EOL Python versions (#265)
Browse files Browse the repository at this point in the history
* Drop support for EOL Python versions

* sudo no longer needed https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration

* Remove unittest2 dependency

* Add python_requires and Trove classifiers

* Replace unittest2 with unittest
  • Loading branch information
hugovk committed Apr 9, 2020
1 parent 9659f28 commit 0db6e8f
Show file tree
Hide file tree
Showing 28 changed files with 73 additions and 81 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
@@ -1,5 +1,4 @@
language: python
sudo: false
matrix:
include:
- python: "2.7"
Expand All @@ -12,8 +11,6 @@ matrix:
env: TOX_ENV=py27-oauth2client3
- python: "2.7"
env: TOX_ENV=py27-oauth2client4
- python: "3.4"
env: TOX_ENV=py34-oauth2client4
- python: "3.5"
env: TOX_ENV=py35-oauth2client1
- python: "3.5"
Expand Down
8 changes: 4 additions & 4 deletions apitools/base/protorpclite/descriptor_test.py
Expand Up @@ -18,9 +18,9 @@
"""Tests for apitools.base.protorpclite.descriptor."""
import platform
import types
import unittest

import six
import unittest2

from apitools.base.protorpclite import descriptor
from apitools.base.protorpclite import message_types
Expand Down Expand Up @@ -78,8 +78,8 @@ class NestedEnum(messages.Enum):
described.check_initialized()
self.assertEquals(expected, described)

@unittest2.skipIf('PyPy' in platform.python_implementation(),
'todo: reenable this')
@unittest.skipIf('PyPy' in platform.python_implementation(),
'todo: reenable this')
def testEnumWithItems(self):
class EnumWithItems(messages.Enum):
A = 3
Expand Down Expand Up @@ -512,4 +512,4 @@ def testNoPackage(self):


if __name__ == '__main__':
unittest2.main()
unittest.main()
2 changes: 1 addition & 1 deletion apitools/base/protorpclite/test_util.py
Expand Up @@ -33,10 +33,10 @@
import re
import socket
import types
import unittest

import six
from six.moves import range # pylint: disable=redefined-builtin
import unittest2 as unittest

from apitools.base.protorpclite import message_types
from apitools.base.protorpclite import messages
Expand Down
6 changes: 3 additions & 3 deletions apitools/base/py/base_api_test.py
Expand Up @@ -17,11 +17,11 @@
import datetime
import sys
import contextlib
import unittest

import six
from six.moves import http_client
from six.moves import urllib_parse
import unittest2

from apitools.base.protorpclite import message_types
from apitools.base.protorpclite import messages
Expand Down Expand Up @@ -96,7 +96,7 @@ def __init__(self, client=None):
super(FakeService, self).__init__(client)


class BaseApiTest(unittest2.TestCase):
class BaseApiTest(unittest.TestCase):

def __GetFakeClient(self):
return FakeClient('', credentials=FakeCredentials())
Expand Down Expand Up @@ -331,4 +331,4 @@ def testColonInRelativePath(self):


if __name__ == '__main__':
unittest2.main()
unittest.main()
4 changes: 2 additions & 2 deletions apitools/base/py/batch_test.py
Expand Up @@ -16,12 +16,12 @@
"""Tests for apitools.base.py.batch."""

import textwrap
import unittest

import mock
from six.moves import http_client
from six.moves import range # pylint:disable=redefined-builtin
from six.moves.urllib import parse
import unittest2

from apitools.base.py import batch
from apitools.base.py import exceptions
Expand Down Expand Up @@ -69,7 +69,7 @@ def ProcessHttpResponse(self, _, http_response):
return http_response


class BatchTest(unittest2.TestCase):
class BatchTest(unittest.TestCase):

def assertUrlEqual(self, expected_url, provided_url):

Expand Down
4 changes: 2 additions & 2 deletions apitools/base/py/buffered_stream_test.py
Expand Up @@ -16,15 +16,15 @@
"""Tests for buffered_stream."""

import string
import unittest

import six
import unittest2

from apitools.base.py import buffered_stream
from apitools.base.py import exceptions


class BufferedStreamTest(unittest2.TestCase):
class BufferedStreamTest(unittest.TestCase):

def setUp(self):
self.stream = six.StringIO(string.ascii_letters)
Expand Down
7 changes: 4 additions & 3 deletions apitools/base/py/compression_test.py
Expand Up @@ -16,14 +16,15 @@

"""Tests for compression."""

import unittest

from apitools.base.py import compression
from apitools.base.py import gzip

import six
import unittest2


class CompressionTest(unittest2.TestCase):
class CompressionTest(unittest.TestCase):

def setUp(self):
# Sample highly compressible data (~50MB).
Expand Down Expand Up @@ -98,7 +99,7 @@ def testCompressionIntegrity(self):
self.assertTrue(exhausted)


class StreamingBufferTest(unittest2.TestCase):
class StreamingBufferTest(unittest.TestCase):

def setUp(self):
self.stream = compression.StreamingBuffer()
Expand Down
5 changes: 1 addition & 4 deletions apitools/base/py/credentials_lib.py
Expand Up @@ -17,6 +17,7 @@
"""Common credentials classes and constructors."""
from __future__ import print_function

import argparse
import contextlib
import datetime
import json
Expand Down Expand Up @@ -515,10 +516,6 @@ def _GetRunFlowFlags(args=None):
# since they're bringing their own credentials. So we just allow this
# to fail with an ImportError in those cases.
#
# TODO(craigcitro): Move this import back to the top when we drop
# python 2.6 support (eg when gsutil does).
import argparse

parser = argparse.ArgumentParser(parents=[tools.argparser])
# Get command line argparse flags.
flags, _ = parser.parse_known_args(args=args)
Expand Down
6 changes: 3 additions & 3 deletions apitools/base/py/credentials_lib_test.py
Expand Up @@ -17,10 +17,10 @@
import os.path
import shutil
import tempfile
import unittest

import mock
import six
import unittest2

from apitools.base.py import credentials_lib
from apitools.base.py import util
Expand All @@ -43,7 +43,7 @@ def __call__(self, request_url):
self.fail('Unexpected HTTP request to %s' % request_url)


class CredentialsLibTest(unittest2.TestCase):
class CredentialsLibTest(unittest.TestCase):

def _RunGceAssertionCredentials(
self, service_account_name=None, scopes=None, cache_filename=None):
Expand Down Expand Up @@ -153,7 +153,7 @@ def testGetAdcNone(self):
self.assertIsNone(creds)


class TestGetRunFlowFlags(unittest2.TestCase):
class TestGetRunFlowFlags(unittest.TestCase):

def setUp(self):
self._flags_actual = credentials_lib.FLAGS
Expand Down
5 changes: 2 additions & 3 deletions apitools/base/py/encoding_test.py
Expand Up @@ -17,8 +17,7 @@
import datetime
import json
import sys

import unittest2
import unittest

from apitools.base.protorpclite import message_types
from apitools.base.protorpclite import messages
Expand Down Expand Up @@ -238,7 +237,7 @@ class AdditionalProperty(messages.Message):
'repeated_field', 'repeatedField')


class EncodingTest(unittest2.TestCase):
class EncodingTest(unittest.TestCase):

def testCopyProtoMessage(self):
msg = SimpleMessage(field='abc')
Expand Down
4 changes: 2 additions & 2 deletions apitools/base/py/exceptions_test.py
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest2
import unittest

from apitools.base.py import exceptions
from apitools.base.py import http_wrapper
Expand All @@ -24,7 +24,7 @@ def _MakeResponse(status_code):
request_url='http://www.google.com')


class HttpErrorFromResponseTest(unittest2.TestCase):
class HttpErrorFromResponseTest(unittest.TestCase):

"""Tests for exceptions.HttpError.FromResponse."""

Expand Down
5 changes: 2 additions & 3 deletions apitools/base/py/extra_types_test.py
Expand Up @@ -16,16 +16,15 @@
import datetime
import json
import math

import unittest2
import unittest

from apitools.base.protorpclite import messages
from apitools.base.py import encoding
from apitools.base.py import exceptions
from apitools.base.py import extra_types


class ExtraTypesTest(unittest2.TestCase):
class ExtraTypesTest(unittest.TestCase):

def assertRoundTrip(self, value):
if isinstance(value, extra_types._JSON_PROTO_TYPES):
Expand Down
12 changes: 6 additions & 6 deletions apitools/base/py/http_wrapper_test.py
Expand Up @@ -15,10 +15,10 @@

"""Tests for http_wrapper."""
import socket
import unittest

import httplib2
from six.moves import http_client
import unittest2

from mock import patch

Expand Down Expand Up @@ -57,16 +57,16 @@ def length(self):
return 1


class HttpWrapperTest(unittest2.TestCase):
class HttpWrapperTest(unittest.TestCase):

def testRequestBodyUsesLengthProperty(self):
http_wrapper.Request(body=RaisesExceptionOnLen())

def testRequestBodyWithLen(self):
http_wrapper.Request(body='burrito')

@unittest2.skipIf(not _TOKEN_REFRESH_STATUS_AVAILABLE,
'oauth2client<1.5 lacks HttpAccessTokenRefreshError.')
@unittest.skipIf(not _TOKEN_REFRESH_STATUS_AVAILABLE,
'oauth2client<1.5 lacks HttpAccessTokenRefreshError.')
def testExceptionHandlerHttpAccessTokenError(self):
exception_arg = HttpAccessTokenRefreshError(status=503)
retry_args = http_wrapper.ExceptionRetryArgs(
Expand All @@ -80,8 +80,8 @@ def testExceptionHandlerHttpAccessTokenError(self):
http_wrapper.HandleExceptionsAndRebuildHttpConnections(
retry_args)

@unittest2.skipIf(not _TOKEN_REFRESH_STATUS_AVAILABLE,
'oauth2client<1.5 lacks HttpAccessTokenRefreshError.')
@unittest.skipIf(not _TOKEN_REFRESH_STATUS_AVAILABLE,
'oauth2client<1.5 lacks HttpAccessTokenRefreshError.')
def testExceptionHandlerHttpAccessTokenErrorRaises(self):
exception_arg = HttpAccessTokenRefreshError(status=200)
retry_args = http_wrapper.ExceptionRetryArgs(
Expand Down
8 changes: 4 additions & 4 deletions apitools/base/py/list_pager_test.py
Expand Up @@ -15,7 +15,7 @@

"""Tests for list_pager."""

import unittest2
import unittest

from apitools.base.py import list_pager
from apitools.base.py.testing import mock
Expand All @@ -34,7 +34,7 @@ def __init__(self):
self.c = 'ccc'


class GetterSetterTest(unittest2.TestCase):
class GetterSetterTest(unittest.TestCase):

def testGetattrNested(self):
o = Example()
Expand All @@ -53,7 +53,7 @@ def testSetattrNested(self):
self.assertEqual(o.c, 'CCC')


class ListPagerTest(unittest2.TestCase):
class ListPagerTest(unittest.TestCase):

def _AssertInstanceSequence(self, results, n):
counter = 0
Expand Down Expand Up @@ -295,7 +295,7 @@ def Custom_Getter(message, attribute):
self.assertEquals(1, len(custom_getter_called))


class ListPagerAttributeTest(unittest2.TestCase):
class ListPagerAttributeTest(unittest.TestCase):

def setUp(self):
self.mocked_client = mock.Client(iam_client.IamV1)
Expand Down
4 changes: 2 additions & 2 deletions apitools/base/py/stream_slice_test.py
Expand Up @@ -16,15 +16,15 @@
"""Tests for stream_slice."""

import string
import unittest

import six
import unittest2

from apitools.base.py import exceptions
from apitools.base.py import stream_slice


class StreamSliceTest(unittest2.TestCase):
class StreamSliceTest(unittest.TestCase):

def setUp(self):
self.stream = six.StringIO(string.ascii_letters)
Expand Down
7 changes: 4 additions & 3 deletions apitools/base/py/testing/mock_test.py
Expand Up @@ -15,8 +15,9 @@

"""Tests for apitools.base.py.testing.mock."""

import unittest

import httplib2
import unittest2
import six

from apitools.base.protorpclite import messages
Expand All @@ -42,7 +43,7 @@ class CustomException(Exception):
pass


class MockTest(unittest2.TestCase):
class MockTest(unittest.TestCase):

def testMockFusionBasic(self):
with mock.Client(fusiontables.FusiontablesV1) as client_class:
Expand Down Expand Up @@ -252,7 +253,7 @@ class _NestedNestedMessage(messages.Message):
nested = messages.MessageField(_NestedMessage, 1)


class UtilTest(unittest2.TestCase):
class UtilTest(unittest.TestCase):

def testMessagesEqual(self):
self.assertFalse(mock._MessagesEqual(
Expand Down

0 comments on commit 0db6e8f

Please sign in to comment.