Skip to content

Commit c0bf574

Browse files
author
Michael Howitz
committed
Add support for Python 3.10.
Drop support for Python 2, and 3.6.
1 parent 73924d3 commit c0bf574

14 files changed

+49
-68
lines changed

.github/workflows/tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
matrix:
1818
config:
1919
# [Python version, tox env]
20-
- ["2.7", "py27"]
21-
- ["3.6", "py36"]
2220
- ["3.7", "py37"]
2321
- ["3.8", "py38"]
24-
- ["pypy3", "pypy3"]
25-
- ["3.8", "coverage"]
22+
- ["3.9", "py39"]
23+
- ["3.10.0-rc.1", "py310"]
24+
- ["pypy-3.7", "pypy3"]
25+
- ["3.9", "coverage"]
2626
runs-on: ubuntu-latest
2727
name: ${{ matrix.config[1] }}
2828
steps:

CHANGES.rst

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
Changelog
22
=========
33

4-
2.1 (unreleased)
4+
3.0 (unreleased)
55
----------------
66

7-
- Migrate to Github.
7+
Backwards incompatible changes
8+
++++++++++++++++++++++++++++++
89

9-
- Test with Python 3.8.
1010
- Change license form ZPL to MIT.
1111

12-
- Stop testing with Python 3.4 and 3.5
12+
- Drop support for Python 2, 3.4, 3.5 and 3.6
1313

14-
- Use Github actions as CI.
14+
Features
15+
++++++++
16+
17+
- Add support for Python 3.8, 3.9 and 3.10 (as of rc.1).
1518

1619

1720
2.0.post1 (2018-11-22)

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bdist_wheel]
2-
universal = 1
2+
universal = 0
33

44
[isort]
55
lines_between_sections = 0

setup.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='gocept.testing',
7-
version='2.1.dev0',
7+
version='3.0.dev0',
88
author='gocept <mail at gocept dot com>',
99
author_email='[email protected]',
1010
url='https://github.com/gocept/gocept.testing',
@@ -18,12 +18,12 @@
1818
'Natural Language :: English',
1919
'Operating System :: OS Independent',
2020
'Programming Language :: Python',
21-
'Programming Language :: Python :: 2',
22-
'Programming Language :: Python :: 2.7',
2321
'Programming Language :: Python :: 3',
24-
'Programming Language :: Python :: 3.6',
22+
'Programming Language :: Python :: 3 :: Only',
2523
'Programming Language :: Python :: 3.7',
2624
'Programming Language :: Python :: 3.8',
25+
'Programming Language :: Python :: 3.9',
26+
'Programming Language :: Python :: 3.10',
2727
'Programming Language :: Python :: Implementation',
2828
'Programming Language :: Python :: Implementation :: CPython',
2929
'Programming Language :: Python :: Implementation :: PyPy',
@@ -44,15 +44,8 @@
4444
license='MIT',
4545
keywords="testing unittest assertions",
4646
namespace_packages=['gocept'],
47+
python_requires='>=3.7',
4748
install_requires=[
4849
'setuptools',
4950
],
50-
extras_require=dict(
51-
test=[
52-
'mock ; python_version<"3.3"',
53-
],
54-
mock=[
55-
'mock ; python_version<"3.3"',
56-
],
57-
),
5851
)

src/gocept/testing/assertion.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import difflib
22
import doctest
3-
import sys
43
import traceback
54

65

76
def text(arg):
8-
if sys.version_info < (3,):
9-
if isinstance(arg, str):
10-
arg = arg.decode('utf-8')
11-
else:
12-
if not isinstance(arg, str):
13-
arg = arg.decode('utf-8')
7+
if not isinstance(arg, str):
8+
arg = arg.decode('utf-8')
149
return arg
1510

1611

@@ -24,7 +19,7 @@ def ellipsis_match(expected, actual):
2419
return doctest._ellipsis_match(norm_expected, norm_actual)
2520

2621

27-
class Ellipsis(object):
22+
class Ellipsis:
2823
"""Assertion helper that provides doctest-style ellipsis matching.
2924
3025
Inherit from this class in additition to unittest.TestCase.
@@ -47,7 +42,7 @@ def assertNotEllipsis(self, expected, actual):
4742
'Value unexpectedly matches expression %r.' % expected)
4843

4944

50-
class Exceptions(object):
45+
class Exceptions:
5146

5247
def assertNothingRaised(self, callable=None, *args, **kw):
5348
context = AssertNothingRaisedContext(self)
@@ -57,7 +52,7 @@ def assertNothingRaised(self, callable=None, *args, **kw):
5752
callable(*args, **kw)
5853

5954

60-
class AssertNothingRaisedContext(object):
55+
class AssertNothingRaisedContext:
6156

6257
def __init__(self, test_case):
6358
self.failureException = test_case.failureException
@@ -76,16 +71,16 @@ def __exit__(self, exc_type, exc_value, tb):
7671
# message, since we're printing that ourselves
7772
stack = ''.join(
7873
traceback.format_exception(exc_type, exc_value, tb)[1:-1])
79-
text = message + stack + 'Unexpected %s: %s' % (exc_name, exc_value)
74+
text = message + stack + f'Unexpected {exc_name}: {exc_value}'
8075
raise self.failureException(text)
8176

8277

83-
class String(object):
78+
class String:
8479

8580
def assertStartsWith(self, needle, haystack):
8681
if not haystack.startswith(needle):
87-
self.fail('%r does not start with %r.' % (haystack, needle))
82+
self.fail(f'{haystack!r} does not start with {needle!r}.')
8883

8984
def assertEndsWith(self, needle, haystack):
9085
if not haystack.endswith(needle):
91-
self.fail('%r does not end with %r.' % (haystack, needle))
86+
self.fail(f'{haystack!r} does not end with {needle!r}.')

src/gocept/testing/fixture.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import tempfile
33

44

5-
class TempDir(object):
5+
class TempDir:
66
"""Offer a temporary directory."""
77

88
def setUp(self):
9-
super(TempDir, self).setUp()
9+
super().setUp()
1010
self.tmpdir = tempfile.mkdtemp()
1111

1212
def tearDown(self):
13-
super(TempDir, self).tearDown()
13+
super().tearDown()
1414
shutil.rmtree(self.tmpdir)

src/gocept/testing/mock.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
from __future__ import absolute_import
1+
from unittest import mock
22

33

4-
try:
5-
from unittest import mock
6-
except ImportError:
7-
import mock
8-
9-
10-
class Patches(object):
4+
class Patches:
115

126
def __init__(self):
137
self.patches = []
@@ -33,7 +27,7 @@ def reset(self):
3327
self.patches[:] = []
3428

3529

36-
class Assertions(object):
30+
class Assertions:
3731

3832
def assertCalledWith(self, mock, *args, **kw):
3933
return mock.assert_called_with(*args, **kw)
@@ -45,12 +39,12 @@ def __get__(self, instance, class_):
4539
return self()
4640

4741

48-
class PatchHelper(object):
42+
class PatchHelper:
4943

5044
def setUp(self):
51-
super(PatchHelper, self).setUp()
45+
super().setUp()
5246
self.patches = Patches()
5347

5448
def tearDown(self):
5549
self.patches.reset()
56-
super(PatchHelper, self).tearDown()
50+
super().tearDown()

src/gocept/testing/mtime.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os.path
44

55

6-
class Newer(object):
6+
class Newer:
77

88
source_ext = NotImplemented
99
target_ext = NotImplemented
@@ -33,13 +33,13 @@ def _check_files_in_list(self, path, names):
3333

3434
self.assertTrue(
3535
os.path.exists(target_path),
36-
"%s does not exist.\n%s" % (target_filename, self.message))
36+
f"{target_filename} does not exist.\n{self.message}")
3737
target_mtime = os.path.getmtime(target_path)
3838
file_mtime = os.path.getmtime(filepath)
3939
delta = file_mtime - target_mtime
4040
self.assertTrue(
4141
delta < self.delta,
42-
"%s is out of date: %s (%s) > %s (%s), Delta: %s.\n%s" % (
42+
"{} is out of date: {} ({}) > {} ({}), Delta: {}.\n{}".format(
4343
target_path, self.to_str(file_mtime), filename,
4444
self.to_str(target_mtime), target_filename,
4545
delta, self.message))

src/gocept/testing/patch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import contextlib
22

33

4-
class Patches(object):
4+
class Patches:
55
# XXX Maybe this should be a context manager, too.
66

77
def __init__(self):

src/gocept/testing/tests/test_assertion.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# coding: utf-8
21
import gocept.testing.assertion
32
import sys
43
import unittest
@@ -27,12 +26,12 @@ def test_unicode_matches_utf8(self):
2726
# helpful for zope.testbrowser
2827
with self.assertNothingRaised():
2928
self.assertEllipsis(
30-
u'...bar...', u'föö bar baz'.encode('utf-8'))
29+
'...bar...', 'föö bar baz'.encode())
3130

3231
def test_utf8_matches_unicode(self):
3332
with self.assertNothingRaised():
3433
self.assertEllipsis(
35-
u'...bar...'.encode('utf-8'), u'föö bar baz')
34+
b'...bar...', 'föö bar baz')
3635

3736
def test_inverse_assertion(self):
3837
with self.assertNothingRaised():

src/gocept/testing/tests/test_fixture.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class TempDirTest(gocept.testing.fixture.TempDir, unittest.TestCase):
77
"""Testing ..fixture.TempDir."""
88

99
def setUp(self):
10-
super(TempDirTest, self).setUp()
10+
super().setUp()
1111
with open(os.path.join(self.tmpdir, 'foo'), 'w') as f:
1212
f.write('bar')
1313

src/gocept/testing/tests/test_mock.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import absolute_import
21
from gocept.testing.mock import mock
32
import gocept.testing.mock
43
import sys
@@ -73,7 +72,7 @@ def test_should_delegate_to_mock_method(self):
7372
self.assertCalledWith(dummy, True)
7473

7574

76-
class Dummy(object):
75+
class Dummy:
7776

7877
@property
7978
def foo(self):
@@ -97,7 +96,7 @@ class PatchHelperTests(gocept.testing.mock.PatchHelper, unittest.TestCase):
9796
def setUp(self):
9897
"""Has patches after setup."""
9998
assert hasattr(self, 'patches') is False
100-
super(PatchHelperTests, self).setUp()
99+
super().setUp()
101100
assert hasattr(self, 'patches') is True
102101
self.foo = mock.sentinel.foo
103102
self.bar = mock.sentinel.bar
@@ -114,5 +113,5 @@ def tearDown(self):
114113
# still the same as in test
115114
assert self.bar == self.subject.foo
116115
# it was re-setted.
117-
super(PatchHelperTests, self).tearDown()
116+
super().tearDown()
118117
assert self.foo == self.subject.foo

src/gocept/testing/tests/test_patch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_changes_attribute_and_resets(self):
1616
self.assertEqual(mock.sentinel.foo, subject.foo)
1717

1818
def test_callable_attribute_called_and_reset(self):
19-
class Dummy(object):
19+
class Dummy:
2020
def foo(self, arg):
2121
self.arg = arg
2222

tox.ini

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
[tox]
22
envlist =
3-
py27,
4-
py35,
5-
py36,
63
py37,
74
py38,
8-
pypy,
5+
py39,
6+
py310,
97
pypy3,
108
coverage,
119
minversion = 1.6

0 commit comments

Comments
 (0)