Skip to content

Commit

Permalink
Drop support for EOL Python 2.6 and 3.2. (#314)
Browse files Browse the repository at this point in the history
Fixes #308.

Stops testing them on the CI, update python_requries and remove some code specifically for those versions.

Not done anything to remove any six functionality that's only a benefit on those versions, that should be in a separate PR and would be a breaking change that should ideally deprecate first.
  • Loading branch information
hugovk authored and benjaminp committed Jan 8, 2020
1 parent 422fc7a commit ac4bdc5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 65 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ python:
- pypy
- pypy3
install:
- pip install --upgrade --force-reinstall "setuptools; python_version != '3.2' and python_version != '3.3'" "setuptools < 30; python_version == '3.2'" "setuptools < 40; python_version == '3.3'"
- pip install --upgrade --force-reinstall "setuptools; python_version != '3.3'" "setuptools < 40; python_version == '3.3'"
- pip uninstall --yes six || true
- pip install --upgrade --force-reinstall --ignore-installed -e .
- pip install pytest==2.9.2 typing
Expand All @@ -26,10 +26,6 @@ script:
jobs:
fast_finish: true
include:
- python: 2.6
dist: trusty
- python: 3.2
dist: trusty
- python: 3.3
dist: trusty
- stage: upload new version of python package to PYPI (only for tagged commits)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ for smoothing over the differences between the Python versions with the goal of
writing Python code that is compatible on both Python versions. See the
documentation for more information on what is provided.

Six supports every Python version since 2.6. It is contained in only one Python
Six supports Python 2.7 and 3.3+. It is contained in only one Python
file, so it can be easily copied into your project. (The copyright and license
notice must be retained.)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
long_description=six_long_description,
license="MIT",
classifiers=six_classifiers,
python_requires=">=2.6, !=3.0.*, !=3.1.*",
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*",
)
11 changes: 1 addition & 10 deletions six.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,16 +719,7 @@ def exec_(_code_, _globs_=None, _locs_=None):
""")


if sys.version_info[:2] == (3, 2):
exec_("""def raise_from(value, from_value):
try:
if from_value is None:
raise value
raise value from from_value
finally:
value = None
""")
elif sys.version_info[:2] > (3, 2):
if sys.version_info[:2] > (3,):
exec_("""def raise_from(value, from_value):
try:
raise value from from_value
Expand Down
53 changes: 6 additions & 47 deletions test_six.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,70 +121,55 @@ def test_move_items(item_name):
item = getattr(six.moves, item_name)
if isinstance(item, types.ModuleType):
__import__("six.moves." + item_name)
except AttributeError:
if item_name == "zip_longest" and sys.version_info < (2, 6):
pytest.skip("zip_longest only available on 2.6+")
except ImportError:
if item_name == "winreg" and not sys.platform.startswith("win"):
pytest.skip("Windows only module")
if item_name.startswith("tkinter"):
if not have_tkinter:
pytest.skip("requires tkinter")
if item_name == "tkinter_ttk" and sys.version_info[:2] <= (2, 6):
pytest.skip("ttk only available on 2.7+")
if item_name.startswith("dbm_gnu") and not have_gdbm:
pytest.skip("requires gdbm")
raise
if sys.version_info[:2] >= (2, 6):
assert item_name in dir(six.moves)
assert item_name in dir(six.moves)


@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_parse_moved_attributes])
def test_move_items_urllib_parse(item_name):
"""Ensure that everything loads correctly."""
if item_name == "ParseResult" and sys.version_info < (2, 5):
pytest.skip("ParseResult is only found on 2.5+")
if item_name in ("parse_qs", "parse_qsl") and sys.version_info < (2, 6):
pytest.skip("parse_qs[l] is new in 2.6")
if sys.version_info[:2] >= (2, 6):
assert item_name in dir(six.moves.urllib.parse)
assert item_name in dir(six.moves.urllib.parse)
getattr(six.moves.urllib.parse, item_name)


@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_error_moved_attributes])
def test_move_items_urllib_error(item_name):
"""Ensure that everything loads correctly."""
if sys.version_info[:2] >= (2, 6):
assert item_name in dir(six.moves.urllib.error)
assert item_name in dir(six.moves.urllib.error)
getattr(six.moves.urllib.error, item_name)


@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_request_moved_attributes])
def test_move_items_urllib_request(item_name):
"""Ensure that everything loads correctly."""
if sys.version_info[:2] >= (2, 6):
assert item_name in dir(six.moves.urllib.request)
assert item_name in dir(six.moves.urllib.request)
getattr(six.moves.urllib.request, item_name)


@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_response_moved_attributes])
def test_move_items_urllib_response(item_name):
"""Ensure that everything loads correctly."""
if sys.version_info[:2] >= (2, 6):
assert item_name in dir(six.moves.urllib.response)
assert item_name in dir(six.moves.urllib.response)
getattr(six.moves.urllib.response, item_name)


@pytest.mark.parametrize("item_name",
[item.name for item in six._urllib_robotparser_moved_attributes])
def test_move_items_urllib_robotparser(item_name):
"""Ensure that everything loads correctly."""
if sys.version_info[:2] >= (2, 6):
assert item_name in dir(six.moves.urllib.robotparser)
assert item_name in dir(six.moves.urllib.robotparser)
getattr(six.moves.urllib.robotparser, item_name)


Expand Down Expand Up @@ -244,7 +229,6 @@ def test_zip():
assert six.advance_iterator(zip(range(2), range(2))) == (0, 0)


@pytest.mark.skipif("sys.version_info < (2, 6)")
def test_zip_longest():
from six.moves import zip_longest
it = zip_longest(range(2), range(1))
Expand Down Expand Up @@ -417,8 +401,6 @@ def with_kw(*args, **kw):
monkeypatch.undo()


@pytest.mark.skipif("sys.version_info[:2] < (2, 7)",
reason="view methods on dictionaries only available on 2.7+")
def test_dictionary_views():
d = dict(zip(range(10), (range(11, 20))))
for name in "keys", "values", "items":
Expand Down Expand Up @@ -636,7 +618,6 @@ def test_raise_from():
# We should have done a raise f from None equivalent.
assert val.__cause__ is None
assert val.__context__ is ctx
if sys.version_info[:2] >= (3, 3):
# And that should suppress the context on the exception.
assert val.__suppress_context__
# For all versions the outer exception should have raised successfully.
Expand Down Expand Up @@ -682,24 +663,6 @@ def flush(self):
assert out.flushed


@pytest.mark.skipif("sys.version_info[:2] >= (2, 6)")
def test_print_encoding(monkeypatch):
# Fool the type checking in print_.
monkeypatch.setattr(six, "file", six.BytesIO, raising=False)
out = six.BytesIO()
out.encoding = "utf-8"
out.errors = None
six.print_(six.u("\u053c"), end="", file=out)
assert out.getvalue() == six.b("\xd4\xbc")
out = six.BytesIO()
out.encoding = "ascii"
out.errors = "strict"
pytest.raises(UnicodeEncodeError, six.print_, six.u("\u053c"), file=out)
out.errors = "backslashreplace"
six.print_(six.u("\u053c"), end="", file=out)
assert out.getvalue() == six.b("\\u053c")


def test_print_exceptions():
pytest.raises(TypeError, six.print_, x=3)
pytest.raises(TypeError, six.print_, end=3)
Expand Down Expand Up @@ -737,7 +700,6 @@ class Y(six.with_metaclass(MetaSub, X)):
assert Y.__mro__ == (Y, X, object)


@pytest.mark.skipif("sys.version_info[:2] < (2, 7)")
def test_with_metaclass_typing():
try:
import typing
Expand Down Expand Up @@ -954,7 +916,6 @@ class B: pass
assert A.B.__qualname__ == expected


@pytest.mark.skipif("sys.version_info[:2] < (2, 7) or sys.version_info[:2] in ((3, 0), (3, 1))")
def test_assertCountEqual():
class TestAssertCountEqual(unittest.TestCase):
def test(self):
Expand All @@ -966,7 +927,6 @@ def test(self):
TestAssertCountEqual('test').test()


@pytest.mark.skipif("sys.version_info[:2] < (2, 7)")
def test_assertRegex():
class TestAssertRegex(unittest.TestCase):
def test(self):
Expand All @@ -978,7 +938,6 @@ def test(self):
TestAssertRegex('test').test()


@pytest.mark.skipif("sys.version_info[:2] < (2, 7)")
def test_assertRaisesRegex():
class TestAssertRaisesRegex(unittest.TestCase):
def test(self):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist=py26,py27,py32,py33,py34,py35,py36,py37,py38,pypy,flake8
envlist=py27,py33,py34,py35,py36,py37,py38,pypy,flake8

[testenv]
deps= pytest
Expand Down

0 comments on commit ac4bdc5

Please sign in to comment.