Skip to content

Commit 14451ef

Browse files
authored
Merge pull request #30 from jdufresne/py2
Remove support for end-of-life Pythons
2 parents cb1c12e + 130af2a commit 14451ef

File tree

8 files changed

+25
-116
lines changed

8 files changed

+25
-116
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ jobs:
3131
strategy:
3232
matrix:
3333
python:
34-
- '2.7'
35-
- '3.5'
3634
- '3.6'
3735
- '3.7'
3836
- '3.8'
3937
- '3.9'
40-
- 'pypy2'
4138
- 'pypy3'
4239

4340
steps:

docs/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
#
31
# Cryptography documentation build configuration file, created by
42
# sphinx-quickstart on Tue Aug 6 19:19:14 2013.
53
#

scripttest.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,18 @@
1616

1717
if sys.platform == 'win32':
1818
def clean_environ(e):
19-
ret = dict(
20-
((str(k), str(v)) for k, v in e.items()))
19+
ret = {
20+
str(k): str(v) for k, v in e.items()}
2121
return ret
2222
else:
2323
def clean_environ(e):
2424
return e
2525

2626

2727
def string(string):
28-
if sys.version_info >= (3,):
29-
if isinstance(string, str):
30-
return string
31-
return str(string, "utf-8")
32-
else:
33-
if isinstance(string, unicode): # noqa
34-
return string
35-
return string.decode('utf-8')
28+
if isinstance(string, str):
29+
return string
30+
return str(string, "utf-8")
3631

3732

3833
# From pathutils by Michael Foord:
@@ -60,7 +55,7 @@ def onerror(func, path, exc_info):
6055
__all__ = ['TestFileEnvironment']
6156

6257

63-
class TestFileEnvironment(object):
58+
class TestFileEnvironment:
6459

6560
"""
6661
This represents an environment in which files will be written, and
@@ -331,7 +326,7 @@ def assert_no_temp(self):
331326
% ', '.join(sorted(names)))
332327

333328

334-
class ProcResult(object):
329+
class ProcResult:
335330

336331
"""
337332
Represents the results of running a command in
@@ -462,7 +457,7 @@ def __str__(self):
462457
return '\n'.join(s)
463458

464459

465-
class FoundFile(object):
460+
class FoundFile:
466461

467462
"""
468463
Represents a single file found as the result of a command.
@@ -536,7 +531,7 @@ def mustcontain(self, s):
536531
assert s in bytes
537532

538533
def __repr__(self):
539-
return '<%s %s:%s>' % (
534+
return '<{} {}:{}>'.format(
540535
self.__class__.__name__,
541536
self.base_path, self.path)
542537

@@ -550,11 +545,8 @@ def __eq__(self, other):
550545
self.size == other.size
551546
)
552547

553-
def __ne__(self, other):
554-
return not self == other
555-
556548

557-
class FoundDir(object):
549+
class FoundDir:
558550

559551
"""
560552
Represents a directory created by a command.
@@ -573,7 +565,7 @@ def __init__(self, base_path, path):
573565
self.mtime = self.stat.st_mtime
574566

575567
def __repr__(self):
576-
return '<%s %s:%s>' % (
568+
return '<{} {}:{}>'.format(
577569
self.__class__.__name__,
578570
self.base_path, self.path)
579571

@@ -583,9 +575,6 @@ def __eq__(self, other):
583575

584576
return self.mtime == other.mtime
585577

586-
def __ne__(self, other):
587-
return not self == other
588-
589578

590579
def _space_prefix(pref, full, sep=None, indent=None, include_sep=True):
591580
"""

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,15 @@ def run_tests(self):
2828
'Intended Audience :: Developers',
2929
'License :: OSI Approved :: MIT License',
3030
'Topic :: Software Development :: Testing',
31-
'Programming Language :: Python :: 2',
31+
'Programming Language :: Python',
3232
'Programming Language :: Python :: 3',
33+
'Programming Language :: Python :: 3 :: Only',
34+
'Programming Language :: Python :: 3.6',
35+
'Programming Language :: Python :: 3.7',
36+
'Programming Language :: Python :: 3.8',
37+
'Programming Language :: Python :: 3.9',
38+
'Programming Language :: Python :: Implementation :: CPython',
39+
'Programming Language :: Python :: Implementation :: PyPy',
3340
],
3441
keywords='test unittest doctest command line scripts',
3542
author='Ian Bicking',

tests/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
from __future__ import absolute_import
2-
3-
import pytest
4-
5-
PY2 = pytest.mark.skipif("sys.version_info >= (3, 0)",
6-
reason="Python 3.x only")
7-
PY3 = pytest.mark.skipif("sys.version_info < (3, 0)",
8-
reason="Python 2.x only")

tests/test_string.py

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
3-
4-
import sys
5-
6-
from . import PY2, PY3
7-
81
from scripttest import string
92

103

@@ -13,70 +6,10 @@
136
'funny "Unicode" characters.\n\nJust good ol\' ASCII text.',
147
])
158

16-
if sys.version_info < (3, 0):
17-
utf8_str = ''.join([
18-
'Bj\xc3\xb6rk Gu\xc3\xb0mundsd\xc3\xb3ttir ',
19-
'[\xcb\x88pj\xc5\x93r\xcc\xa5k ',
20-
'\xcb\x88kv\xca\x8f\xc3\xb0m\xca\x8fnts\xcb\x8cto\xca\x8aht\xc9\xaar]',
21-
])
22-
else:
23-
utf8_str = 'Björk Guðmundsdóttir [ˈpjœr̥k ˈkvʏðmʏntsˌtoʊhtɪr]'
24-
25-
26-
# -----------------------------------------
27-
# Python 2 tests
28-
# -----------------------------------------
29-
30-
31-
@PY2
32-
def test_python_2_string_with_ascii_str():
33-
assert isinstance(ascii_str, str)
34-
35-
result = string(ascii_str)
36-
37-
assert isinstance(result, unicode) # noqa
38-
assert result == ascii_str
39-
40-
41-
@PY2
42-
def test_python_2_string_with_utf8_str():
43-
assert isinstance(utf8_str, str)
44-
45-
result = string(utf8_str)
46-
47-
assert isinstance(result, unicode) # noqa
48-
assert result == utf8_str.decode('utf-8')
49-
50-
51-
@PY2
52-
def test_python_2_string_with_ascii_unicode():
53-
ascii_unicode = ascii_str.decode('utf-8')
54-
assert isinstance(ascii_unicode, unicode) # noqa
55-
56-
result = string(ascii_unicode)
57-
58-
assert isinstance(result, unicode) # noqa
59-
assert result == ascii_unicode
60-
61-
62-
@PY2
63-
def test_python_2_string_with_utf8_unicode():
64-
utf8_unicode = utf8_str.decode('utf-8')
65-
assert isinstance(utf8_unicode, unicode) # noqa
66-
67-
result = string(utf8_unicode)
68-
69-
assert isinstance(result, unicode) # noqa
70-
assert result == utf8_unicode
71-
72-
73-
# ------------------------------------------
74-
# Python 3 tests
75-
# ----------------------------------------
9+
utf8_str = 'Björk Guðmundsdóttir [ˈpjœr̥k ˈkvʏðmʏntsˌtoʊhtɪr]'
7610

7711

78-
@PY3
79-
def test_python_3_string_with_ascii_bytes():
12+
def test_string_with_ascii_bytes():
8013
ascii_bytes = ascii_str.encode('utf-8')
8114
assert isinstance(ascii_bytes, bytes)
8215

@@ -86,8 +19,7 @@ def test_python_3_string_with_ascii_bytes():
8619
assert result == ascii_bytes.decode('utf-8')
8720

8821

89-
@PY3
90-
def test_python_3_string_with_utf8_bytes():
22+
def test_string_with_utf8_bytes():
9123
utf8_bytes = utf8_str.encode('utf-8')
9224

9325
assert isinstance(utf8_bytes, bytes)
@@ -98,8 +30,7 @@ def test_python_3_string_with_utf8_bytes():
9830
assert result == utf8_bytes.decode('utf-8')
9931

10032

101-
@PY3
102-
def test_python_3_string_with_ascii_str():
33+
def test_string_with_ascii_str():
10334
assert isinstance(ascii_str, str)
10435

10536
result = string(ascii_str)
@@ -108,8 +39,7 @@ def test_python_3_string_with_ascii_str():
10839
assert result == ascii_str
10940

11041

111-
@PY3
112-
def test_python_3_string_with_utf8_str():
42+
def test_string_with_utf8_str():
11343
assert isinstance(utf8_str, str)
11444

11545
result = string(utf8_str)

tox.ini

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{27,35,36,37,38,39},pypy,pypy3,docs,pep8
2+
envlist = py{36,37,38,39},pypy3,docs,pep8
33

44
[testenv]
55
deps = pytest
@@ -9,15 +9,13 @@ commands = py.test
99
deps =
1010
sphinx
1111
readme_renderer
12-
basepython = python3
1312
commands =
1413
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
1514
sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html
1615
python setup.py check -m -r -s
1716

1817
[testenv:pep8]
1918
deps = flake8
20-
basepython = python2
2119
commands = flake8 scripttest.py tests/ docs/
2220

2321
[flake8]

0 commit comments

Comments
 (0)