Skip to content

Commit

Permalink
Merge pull request #2823 from hugovk/features-rm-2.6
Browse files Browse the repository at this point in the history
 Remove code for unsupported Python versions
  • Loading branch information
RonnyPfannschmidt authored Oct 10, 2017
2 parents dd45f8b + be0e213 commit 1480aed
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 108 deletions.
4 changes: 1 addition & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[run]
omit =
omit =
# standlonetemplate is read dynamically and tested by test_genscript
*standalonetemplate.py
# oldinterpret could be removed, as it is no longer used in py26+
*oldinterpret.py
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Grig Gheorghiu
Grigorii Eremeev (budulianin)
Guido Wesdorp
Harald Armin Massa
Hugo van Kemenade
Hui Wang (coldnight)
Ian Bicking
Jaap Broekhuizen
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Features
- Can run `unittest <http://docs.pytest.org/en/latest/unittest.html>`_ (or trial),
`nose <http://docs.pytest.org/en/latest/nose.html>`_ test suites out of the box;

- Python2.6+, Python3.3+, PyPy-2.3, Jython-2.5 (untested);
- Python 2.7, Python 3.4+, PyPy 2.3, Jython 2.5 (untested);

- Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community;

Expand Down
3 changes: 0 additions & 3 deletions _pytest/_argcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
to find the magic string, so _ARGCOMPLETE env. var is never set, and
this does not need special code.
argcomplete does not support python 2.5 (although the changes for that
are minor).
Function try_argcomplete(parser) should be called directly before
the call to ArgumentParser.parse_args().
Expand Down
2 changes: 0 additions & 2 deletions _pytest/_code/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,6 @@ def get_statement_startend2(lineno, node):
def getstatementrange_ast(lineno, source, assertion=False, astnode=None):
if astnode is None:
content = str(source)
if sys.version_info < (2, 7):
content += "\n"
try:
astnode = compile(content, "source", "exec", 1024) # 1024 for AST
except ValueError:
Expand Down
6 changes: 2 additions & 4 deletions _pytest/assertion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ def __init__(self, config, mode):

def install_importhook(config):
"""Try to install the rewrite hook, raise SystemError if it fails."""
# Both Jython and CPython 2.6.0 have AST bugs that make the
# assertion rewriting hook malfunction.
if (sys.platform.startswith('java') or
sys.version_info[:3] == (2, 6, 0)):
# Jython has an AST bug that make the assertion rewriting hook malfunction.
if (sys.platform.startswith('java')):
raise SystemError('rewrite not supported')

config._assertstate = AssertionState(config, 'rewrite')
Expand Down
5 changes: 0 additions & 5 deletions _pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
PYC_EXT = ".py" + (__debug__ and "c" or "o")
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT

REWRITE_NEWLINES = sys.version_info[:2] != (2, 7) and sys.version_info < (3, 2)
ASCII_IS_DEFAULT_ENCODING = sys.version_info[0] < 3

if sys.version_info >= (3, 5):
Expand Down Expand Up @@ -321,10 +320,6 @@ def _rewrite_test(config, fn):
return None, None
finally:
del state._indecode
# On Python versions which are not 2.7 and less than or equal to 3.1, the
# parser expects *nix newlines.
if REWRITE_NEWLINES:
source = source.replace(RN, N) + N
try:
tree = ast.parse(source)
except SyntaxError:
Expand Down
5 changes: 1 addition & 4 deletions _pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
from _pytest.outcomes import fail, TEST_OUTCOME
from _pytest.compat import FuncargnamesCompatAttr

if sys.version_info[:2] == (2, 6):
from ordereddict import OrderedDict
else:
from collections import OrderedDict
from collections import OrderedDict


def pytest_sessionstart(session):
Expand Down
8 changes: 2 additions & 6 deletions _pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,9 @@ def pytest_runtest_protocol(self, item):
# XXX copied from execnet's conftest.py - needs to be merged
winpymap = {
'python2.7': r'C:\Python27\python.exe',
'python2.6': r'C:\Python26\python.exe',
'python3.1': r'C:\Python31\python.exe',
'python3.2': r'C:\Python32\python.exe',
'python3.3': r'C:\Python33\python.exe',
'python3.4': r'C:\Python34\python.exe',
'python3.5': r'C:\Python35\python.exe',
'python3.6': r'C:\Python36\python.exe',
}


Expand All @@ -143,8 +140,7 @@ def getexecutable(name, cache={}):
return executable


@pytest.fixture(params=['python2.6', 'python2.7', 'python3.3', "python3.4",
'pypy', 'pypy3'])
@pytest.fixture(params=['python2.7', 'python3.4', 'pypy', 'pypy3'])
def anypython(request):
name = request.param
executable = getexecutable(name)
Expand Down
10 changes: 1 addition & 9 deletions _pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,7 @@ def raises(expected_exception, *args, **kwargs):
This helper produces a ``ExceptionInfo()`` object (see below).
If using Python 2.5 or above, you may use this function as a
context manager::
You may use this function as a context manager::
>>> with raises(ZeroDivisionError):
... 1/0
Expand Down Expand Up @@ -609,13 +608,6 @@ def __exit__(self, *tp):
__tracebackhide__ = True
if tp[0] is None:
fail(self.message)
if sys.version_info < (2, 7):
# py26: on __exit__() exc_value often does not contain the
# exception value.
# http://bugs.python.org/issue7853
if not isinstance(tp[1], BaseException):
exc_type, value, traceback = tp
tp = exc_type, exc_type(value), traceback
self.excinfo.__init__(tp)
suppress_exception = issubclass(self.excinfo.type, self.expected_exception)
if sys.version_info[0] == 2 and suppress_exception:
Expand Down
2 changes: 1 addition & 1 deletion doc/en/example/multipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
import _pytest._code

pythonlist = ['python2.6', 'python2.7', 'python3.4', 'python3.5']
pythonlist = ['python2.7', 'python3.4', 'python3.5']
@pytest.fixture(params=pythonlist)
def python1(request, tmpdir):
picklefile = tmpdir.join("data.pickle")
Expand Down
24 changes: 11 additions & 13 deletions doc/en/getting-started.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
Installation and Getting Started
===================================

**Pythons**: Python 2.6,2.7,3.3,3.4,3.5, Jython, PyPy-2.3
**Pythons**: Python 2.7, 3.4, 3.5, 3.6, Jython, PyPy-2.3

**Platforms**: Unix/Posix and Windows

**PyPI package name**: `pytest <http://pypi.python.org/pypi/pytest>`_

**dependencies**: `py <http://pypi.python.org/pypi/py>`_,
`colorama (Windows) <http://pypi.python.org/pypi/colorama>`_,
`argparse (py26) <http://pypi.python.org/pypi/argparse>`_,
`ordereddict (py26) <http://pypi.python.org/pypi/ordereddict>`_.

**documentation as PDF**: `download latest <https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf>`_

Expand Down Expand Up @@ -50,17 +48,17 @@ That's it. You can execute the test function now::
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile:
collected 1 item

test_sample.py F

======= FAILURES ========
_______ test_answer ________

def test_answer():
> assert func(3) == 5
E assert 4 == 5
E + where 4 = func(3)

test_sample.py:5: AssertionError
======= 1 failed in 0.12 seconds ========

Expand Down Expand Up @@ -129,15 +127,15 @@ run the module by passing its filename::
.F
======= FAILURES ========
_______ TestClass.test_two ________

self = <test_class.TestClass object at 0xdeadbeef>

def test_two(self):
x = "hello"
> assert hasattr(x, 'check')
E AssertionError: assert False
E + where False = hasattr('hello', 'check')

test_class.py:8: AssertionError
1 failed, 1 passed in 0.12 seconds

Expand Down Expand Up @@ -166,14 +164,14 @@ before performing the test function call. Let's just run it::
F
======= FAILURES ========
_______ test_needsfiles ________

tmpdir = local('PYTEST_TMPDIR/test_needsfiles0')

def test_needsfiles(tmpdir):
print (tmpdir)
> assert 0
E assert 0

test_tmpdir.py:3: AssertionError
--------------------------- Captured stdout call ---------------------------
PYTEST_TMPDIR/test_needsfiles0
Expand Down
10 changes: 5 additions & 5 deletions doc/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ To execute it::
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR, inifile:
collected 1 item

test_sample.py F

======= FAILURES ========
_______ test_answer ________

def test_answer():
> assert inc(3) == 5
E assert 4 == 5
E + where 4 = inc(3)

test_sample.py:5: AssertionError
======= 1 failed in 0.12 seconds ========

Expand All @@ -57,7 +57,7 @@ Features

- Can run :ref:`unittest <unittest>` (including trial) and :ref:`nose <noseintegration>` test suites out of the box;

- Python2.6+, Python3.3+, PyPy-2.3, Jython-2.5 (untested);
- Python 2.7, Python 3.4+, PyPy 2.3, Jython 2.5 (untested);

- Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community;

Expand Down
16 changes: 8 additions & 8 deletions doc/en/skipping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ during import time.

If you wish to skip something conditionally then you can use ``skipif`` instead.
Here is an example of marking a test function to be skipped
when run on a Python3.3 interpreter::
when run on a Python3.6 interpreter::

import sys
@pytest.mark.skipif(sys.version_info < (3,3),
reason="requires python3.3")
@pytest.mark.skipif(sys.version_info < (3,6),
reason="requires python3.6")
def test_function():
...

Expand Down Expand Up @@ -250,8 +250,8 @@ You can change the default value of the ``strict`` parameter using the
As with skipif_ you can also mark your expectation of a failure
on a particular platform::

@pytest.mark.xfail(sys.version_info >= (3,3),
reason="python3.3 api changes")
@pytest.mark.xfail(sys.version_info >= (3,6),
reason="python3.6 api changes")
def test_function():
...

Expand Down Expand Up @@ -311,12 +311,12 @@ Running it with the report-on-xfail option gives this output::
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
rootdir: $REGENDOC_TMPDIR/example, inifile:
collected 7 items

xfail_demo.py xxxxxxx
======= short test summary info ========
XFAIL xfail_demo.py::test_hello
XFAIL xfail_demo.py::test_hello2
reason: [NOTRUN]
reason: [NOTRUN]
XFAIL xfail_demo.py::test_hello3
condition: hasattr(os, 'sep')
XFAIL xfail_demo.py::test_hello4
Expand All @@ -326,7 +326,7 @@ Running it with the report-on-xfail option gives this output::
XFAIL xfail_demo.py::test_hello6
reason: reason
XFAIL xfail_demo.py::test_hello7

======= 7 xfailed in 0.12 seconds ========

.. _`skip/xfail with parametrize`:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'Topic :: Utilities',
] + [
('Programming Language :: Python :: %s' % x)
for x in '2.7 3 3.4 3.5 3.6'.split()
for x in '2 2.7 3 3.4 3.5 3.6'.split()
]

with open('README.rst') as fd:
Expand Down
2 changes: 1 addition & 1 deletion testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def test_namespace_import_doesnt_confuse_import_hook(self, testdir):
Importing a module that didn't exist, even if the ImportError was
gracefully handled, would make our test crash.
Use recwarn here to silence this warning in Python 2.6 and 2.7:
Use recwarn here to silence this warning in Python 2.7:
ImportWarning: Not importing directory '...\not_a_package': missing __init__.py
"""
testdir.mkdir('not_a_package')
Expand Down
11 changes: 2 additions & 9 deletions testing/code/test_excinfo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

import sys
import operator
import _pytest
import py
Expand Down Expand Up @@ -345,10 +344,7 @@ def test_excinfo_no_sourcecode():
except ValueError:
excinfo = _pytest._code.ExceptionInfo()
s = str(excinfo.traceback[-1])
if py.std.sys.version_info < (2, 5):
assert s == " File '<string>':1 in ?\n ???\n"
else:
assert s == " File '<string>':1 in <module>\n ???\n"
assert s == " File '<string>':1 in <module>\n ???\n"


def test_excinfo_no_python_sourcecode(tmpdir):
Expand Down Expand Up @@ -1244,9 +1240,6 @@ def __getattr__(self, attr):
except:
from _pytest._code.code import ExceptionInfo
exc_info = ExceptionInfo()
if sys.version_info[:2] == (2, 6):
assert "'RecursionDepthError' object has no attribute '___" in str(exc_info.getrepr())
else:
assert 'maximum recursion' in str(exc_info.getrepr())
assert 'maximum recursion' in str(exc_info.getrepr())
else:
assert 0
2 changes: 0 additions & 2 deletions testing/code/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ def test_some():
assert getstatement(2, source).lines == source.lines[2:3]
assert getstatement(3, source).lines == source.lines[3:4]

@pytest.mark.skipif("sys.version_info < (2,6)")
def test_getstatementrange_out_of_bounds_py3(self):
source = Source("if xxx:\n from .collections import something")
r = source.getstatementrange(1)
Expand All @@ -283,7 +282,6 @@ def test_getstatementrange_with_syntaxerror_issue7(self):
source = Source(":")
pytest.raises(SyntaxError, lambda: source.getstatementrange(0))

@pytest.mark.skipif("sys.version_info < (2,6)")
def test_compile_to_ast(self):
import ast
source = Source("x = 4")
Expand Down
6 changes: 0 additions & 6 deletions testing/python/approx.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ def report_failure(self, out, test, example, got):
class TestApprox(object):

def test_repr_string(self):
# for some reason in Python 2.6 it is not displaying the tolerance representation correctly
plus_minus = u'\u00b1' if sys.version_info[0] > 2 else u'+-'
tol1, tol2, infr = '1.0e-06', '2.0e-06', 'inf'
if sys.version_info[:2] == (2, 6):
tol1, tol2, infr = '???', '???', '???'
assert repr(approx(1.0)) == '1.0 {pm} {tol1}'.format(pm=plus_minus, tol1=tol1)
assert repr(approx([1.0, 2.0])) == 'approx([1.0 {pm} {tol1}, 2.0 {pm} {tol2}])'.format(
pm=plus_minus, tol1=tol1, tol2=tol2)
Expand Down Expand Up @@ -375,9 +372,6 @@ def test_foo():
assert [3] == [pytest.approx(4)]
""")
expected = '4.0e-06'
# for some reason in Python 2.6 it is not displaying the tolerance representation correctly
if sys.version_info[:2] == (2, 6):
expected = '???'
result = testdir.runpytest()
result.stdout.fnmatch_lines([
'*At index 0 diff: 3 != 4 * {0}'.format(expected),
Expand Down
Loading

0 comments on commit 1480aed

Please sign in to comment.