Skip to content

Commit 4c1d7a0

Browse files
committed
Re-add Python 2.7 support.
Note: the only reason support was re-added, because no change to the actual code was needed, only to the tests. It is intended as temporary, and may (will) be removed at any time.
1 parent 21accd1 commit 4c1d7a0

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
# set them as "X" (without the ".0"), which is undefined in tox.ini.
2525

2626
# Sphinx 1.4 added support for Python 3.5
27+
- sphinx: 1.4
28+
python: 2.7
2729
- sphinx: 1.4
2830
python: 3.5
2931
- sphinx: '2.0'
@@ -32,6 +34,8 @@ jobs:
3234
- sphinx: 1.5
3335
python: 3.6
3436
# Sphinx 1.8 added support for Python 3.7 and 3.8
37+
- sphinx: 1.8
38+
python: 2.7
3539
- sphinx: 1.8
3640
python: 3.8
3741
# Sphinx 2.4 added support for Python 3.9

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@
3636
'Intended Audience :: Developers',
3737
'License :: OSI Approved :: BSD License',
3838
'Operating System :: OS Independent',
39+
'Programming Language :: Python :: 2',
3940
'Programming Language :: Python :: 3',
4041
'Topic :: Documentation :: Sphinx',
4142
'Topic :: Software Development :: Documentation',
4243
'Topic :: Text Processing :: Markup :: reStructuredText',
4344
],
4445
platforms='any',
45-
python_requires='>=3.5',
46+
python_requires='>=2.7, !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
4647
packages=find_packages(exclude=['tests']),
4748
include_package_data=True,
4849
install_requires=requires,

tests/test_rst_formatting.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from tests.utils import run_parse_test
22

3+
import pytest
34
import sphinx
45

56

@@ -23,12 +24,7 @@ def test_superscript(src_dir, expected_dir, output_dir):
2324
run_parse_test(src_dir, expected_dir, output_dir, 'common', ['superscript'])
2425

2526

27+
@pytest.mark.skipif(sphinx.version_info < (1, 6), reason="Smart quotes were introduces in Sphinx 1.6")
2628
def test_smart_quotes(src_dir, expected_dir, output_dir):
27-
# Smart quotes were only introduces in Sphinx 1.6
28-
if sphinx.version_info >= (1, 6):
29-
run_parse_test(src_dir, expected_dir, output_dir, 'common', ['smart-quotes'])
30-
else:
31-
# Support for Sphinx < 1.6
32-
# no modification, test against src_dir instead of expected_dir
33-
run_parse_test(src_dir, src_dir, output_dir, 'common', ['smart-quotes'])
29+
run_parse_test(src_dir, expected_dir, output_dir, 'common', ['smart-quotes'])
3430

tests/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
from os.path import join
2-
from itertools import zip_longest
2+
try:
3+
from itertools import zip_longest
4+
except ImportError:
5+
# Python 2.7 support.
6+
from itertools import izip_longest as zip_longest
7+
import io
38

49
import docutils
510
from docutils.frontend import OptionParser
@@ -92,7 +97,7 @@ def assert_doc_equal(output_doc, expected_doc):
9297

9398
def parse_doc(dir, file):
9499
parser = Parser()
95-
with open(join(dir, file + '.rst')) as fh:
100+
with io.open(join(dir, file + '.rst'), encoding='utf-8') as fh:
96101
doc = new_document(
97102
file,
98103
OptionParser(

tox.ini

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tox]
22
; If you change the test matrix, also change it in .github/workflows/tests.yml
33
envlist =
4+
python2.7-sphinx{1.4,1.8} # Supported by Sphinx 1.0-1.8
45
python3.5-sphinx{1.4,2.0,3.4} # Supported by Sphinx 1.4-3.4
56
python3.6-sphinx{1.5,3.4} # Supported by Sphinx 1.5-4.x
67
python3.7-sphinx{3.4} # Supported by Sphinx 1.8-4.x
@@ -9,6 +10,7 @@ envlist =
910

1011
[testenv]
1112
basepython =
13+
python2.7: python2.7
1214
python3.5: python3.5
1315
python3.6: python3.6
1416
python3.7: python3.7
@@ -18,19 +20,19 @@ basepython =
1820

1921
deps =
2022
pytest
21-
sphinx1.4: Sphinx >= 1.4, < 1.5
22-
sphinx1.5: Sphinx >= 1.5, < 1.6
23-
sphinx1.6: Sphinx >= 1.6, < 1.7
24-
sphinx1.7: Sphinx >= 1.7, < 1.8
25-
sphinx1.8: Sphinx >= 1.8, < 2.0
26-
sphinx2.0: Sphinx >= 2.0, < 2.1
27-
sphinx2.1: Sphinx >= 2.1, < 2.2
28-
sphinx2.2: Sphinx >= 2.2, < 2.3
29-
sphinx2.3: Sphinx >= 2.3, < 2.4
30-
sphinx2.4: Sphinx >= 2.4, < 3.0
31-
sphinx3.0: Sphinx >= 3.0, < 3.1
32-
sphinx3.4: Sphinx >= 3.4, < 4.0
33-
sphinx4.0: Sphinx >= 4.0, < 4.1
23+
sphinx1.4: Sphinx >= 1.4, < 1.5 # Supports Python 2.6, 2.7, 3.3, 3.4, 3.5
24+
sphinx1.5: Sphinx >= 1.5, < 1.6 # Supports Python 2.7, 3.4, 3.5
25+
sphinx1.6: Sphinx >= 1.6, < 1.7 # Supports Python 2.7, 3.4, 3.5, 3.6
26+
sphinx1.7: Sphinx >= 1.7, < 1.8 # Supports Python 2.7, 3.4, 3.5, 3.6
27+
sphinx1.8: Sphinx >= 1.8, < 2.0 # Supports Python 2.7, 3.4, 3.5, 3.6, 3.7, 3.8
28+
sphinx2.0: Sphinx >= 2.0, < 2.1 # Supports Python 3.4, 3.5, 3.6, 3.7, 3.8
29+
sphinx2.1: Sphinx >= 2.1, < 2.2 # Supports Python 3.5, 3.6, 3.7, 3.8
30+
sphinx2.2: Sphinx >= 2.2, < 2.3 # Supports Python 3.5, 3.6, 3.7, 3.8
31+
sphinx2.3: Sphinx >= 2.3, < 2.4 # Supports Python 3.5, 3.6, 3.7, 3.8
32+
sphinx2.4: Sphinx >= 2.4, < 3.0 # Supports Python 3.5, 3.6, 3.7, 3.8, 3.9
33+
sphinx3.0: Sphinx >= 3.0, < 3.1 # Supports Python 3.5, 3.6, 3.7, 3.8, 3.9
34+
sphinx3.4: Sphinx >= 3.4, < 4.0 # Supports Python 3.5, 3.6, 3.7, 3.8, 3.9
35+
sphinx4.0: Sphinx >= 4.0, < 4.1 # Supports Python 3.6, 3.7, 3.8, 3.9
3436
commands =
3537
pytest -v
3638

0 commit comments

Comments
 (0)