Skip to content

Commit 374b265

Browse files
authored
Drop Python 2 support (#64)
Python 2 is long obsolete, and cannot be CI tested in any reasonable way. Make official the current defacto situation.
1 parent eacbc80 commit 374b265

File tree

18 files changed

+97
-124
lines changed

18 files changed

+97
-124
lines changed

INSTALL.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ Installing Test Repository
44
Run time dependencies
55
~~~~~~~~~~~~~~~~~~~~~
66

7-
* Either:
8-
+ Python 2: version 2.7 or newer
9-
+ Python 3: version 3.4 or newer
7+
* Python 3: version 3.4 or newer
108

119
* subunit (0.0.18 or newer).
1210

NEWS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
testrepository release notes
33
############################
44

5+
0.0.22
6+
++++++
7+
8+
CHANGES
9+
-------
10+
11+
* Drop Python 2 support. (Colin Watson)
12+
513
0.0.21
614
++++++
715

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ classifiers = [
1010
"License :: OSI Approved :: Apache Software License",
1111
"License :: OSI Approved :: BSD License",
1212
"Operating System :: OS Independent",
13-
"Programming Language :: Python :: 2",
1413
"Programming Language :: Python :: 3",
1514
"Programming Language :: Python",
1615
"Topic :: Software Development :: Quality Assurance",

testrepository/arguments/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
import sys
3333

34-
from testtools.compat import reraise
35-
3634

3735
class AbstractArgument(object):
3836
"""A argument that a command may need.
@@ -101,7 +99,7 @@ def parse(self, argv):
10199
break
102100
if count < self.minimum_count:
103101
if error is not None:
104-
reraise(error[0], error[1], error[2])
102+
raise error[1].with_traceback(error[2])
105103
raise ValueError('not enough arguments present/matched in %s' % argv)
106104
del argv[:count]
107105
return result

testrepository/commands/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import sys
3939

4040
import subunit
41-
from testtools.compat import _u
4241

4342
from testrepository.repository import file
4443

@@ -204,8 +203,8 @@ def get_command_parser(cmd):
204203
parser = OptionParser()
205204
for option in cmd.options:
206205
parser.add_option(option)
207-
usage = _u('%%prog %(cmd)s [options] %(args)s\n\n%(help)s') % {
208-
'args': _u(' ').join(map(lambda x:x.summary(), cmd.args)),
206+
usage = '%%prog %(cmd)s [options] %(args)s\n\n%(help)s' % {
207+
'args': ' '.join(map(lambda x:x.summary(), cmd.args)),
209208
'cmd': getattr(cmd, 'name', cmd),
210209
'help': getdoc(cmd),
211210
}

testrepository/commands/list_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from io import BytesIO
1818

1919
from testtools import TestResult
20-
from testtools.compat import _b
2120

2221
from testrepository.arguments.doubledash import DoubledashArgument
2322
from testrepository.arguments.string import StringArgument

testrepository/commands/run.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from testtools import (
2525
TestByTestResult,
2626
)
27-
from testtools.compat import _b
2827

2928
from testrepository.arguments.doubledash import DoubledashArgument
3029
from testrepository.arguments.string import StringArgument
@@ -36,7 +35,7 @@
3635
from testrepository.testlist import parse_list
3736

3837

39-
LINEFEED = _b('\n')[0]
38+
LINEFEED = b'\n'[0]
4039

4140

4241
class ReturnCodeToSubunit(object):
@@ -74,7 +73,7 @@ def _append_return_code_as_test(self):
7473
# line. V2 needs to start on any fresh utf8 character border
7574
# - which is not guaranteed in an arbitrary stream endpoint, so
7675
# injecting a \n gives us such a guarantee.
77-
self.source.write(_b('\n'))
76+
self.source.write(b'\n')
7877
stream = subunit.StreamResultToBytes(self.source)
7978
stream.status(test_id='process-returncode', test_status='fail',
8079
file_name='traceback', mime_type='text/plain;charset=utf8',
@@ -84,7 +83,7 @@ def _append_return_code_as_test(self):
8483

8584
def read(self, count=-1):
8685
if count == 0:
87-
return _b('')
86+
return b''
8887
result = self.source.read(count)
8988
if result:
9089
self.lastoutput = result[-1]

testrepository/repository/file.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import subunit.v2
2929
from subunit import TestProtocolClient
3030
import testtools
31-
from testtools.compat import _b
3231

3332
from testrepository.repository import (
3433
AbstractRepository,
@@ -123,7 +122,7 @@ def get_failing(self):
123122
except IOError:
124123
err = sys.exc_info()[1]
125124
if err.errno == errno.ENOENT:
126-
run_subunit_content = _b('')
125+
run_subunit_content = b''
127126
else:
128127
raise
129128
return _DiskRun(None, run_subunit_content)

testrepository/testlist.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,19 @@
1919
from subunit import ByteStreamToStreamResult
2020
from testtools.testresult.doubles import StreamResult
2121

22-
from testtools.compat import _b, _u
23-
2422

2523
def write_list(stream, test_ids):
2624
"""Write test_ids out to stream.
2725
2826
:param stream: A file-like object.
2927
:param test_ids: An iterable of test ids.
3028
"""
31-
# May need utf8 explicitly?
32-
stream.write(_b('\n'.join(list(test_ids) + [''])))
29+
stream.write(('\n'.join(list(test_ids) + [''])).encode('utf8'))
3330

3431

3532
def parse_list(list_bytes):
3633
"""Parse list_bytes into a list of test ids."""
37-
return [id.strip() for id in list_bytes.decode('utf8').split(_u('\n'))
34+
return [id.strip() for id in list_bytes.decode('utf8').split('\n')
3835
if id.strip()]
3936

4037

testrepository/tests/commands/test_failing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from subunit.v2 import ByteStreamToStreamResult
2121
import testtools
22-
from testtools.compat import _b
2322
from testtools.matchers import (
2423
DocTestMatches,
2524
Equals,
@@ -110,7 +109,7 @@ def test_with_subunit_no_failures_exit_0(self):
110109
self.assertEqual(0, cmd.execute())
111110
self.assertEqual(1, len(ui.outputs))
112111
self.assertEqual('stream', ui.outputs[0][0])
113-
self.assertThat(ui.outputs[0][1], Equals(_b('')))
112+
self.assertThat(ui.outputs[0][1], Equals(b''))
114113

115114
def test_with_list_shows_list_of_tests(self):
116115
ui, cmd = self.get_test_ui_and_cmd(options=[('list', True)])

0 commit comments

Comments
 (0)