Merge pull request #2823 from hugovk/features-rm-2.6

Remove code for unsupported Python versions
This commit is contained in:
Ronny Pfannschmidt 2017-10-10 09:42:32 +02:00 committed by GitHub
commit 1480aed781
24 changed files with 45 additions and 108 deletions

View File

@ -2,5 +2,3 @@
omit = omit =
# standlonetemplate is read dynamically and tested by test_genscript # standlonetemplate is read dynamically and tested by test_genscript
*standalonetemplate.py *standalonetemplate.py
# oldinterpret could be removed, as it is no longer used in py26+
*oldinterpret.py

View File

@ -71,6 +71,7 @@ Grig Gheorghiu
Grigorii Eremeev (budulianin) Grigorii Eremeev (budulianin)
Guido Wesdorp Guido Wesdorp
Harald Armin Massa Harald Armin Massa
Hugo van Kemenade
Hui Wang (coldnight) Hui Wang (coldnight)
Ian Bicking Ian Bicking
Jaap Broekhuizen Jaap Broekhuizen

View File

@ -76,7 +76,7 @@ Features
- Can run `unittest <http://docs.pytest.org/en/latest/unittest.html>`_ (or trial), - 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; `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; - Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community;

View File

@ -4,9 +4,6 @@ needs argcomplete>=0.5.6 for python 3.2/3.3 (older versions fail
to find the magic string, so _ARGCOMPLETE env. var is never set, and to find the magic string, so _ARGCOMPLETE env. var is never set, and
this does not need special code. 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 Function try_argcomplete(parser) should be called directly before
the call to ArgumentParser.parse_args(). the call to ArgumentParser.parse_args().

View File

@ -342,8 +342,6 @@ def get_statement_startend2(lineno, node):
def getstatementrange_ast(lineno, source, assertion=False, astnode=None): def getstatementrange_ast(lineno, source, assertion=False, astnode=None):
if astnode is None: if astnode is None:
content = str(source) content = str(source)
if sys.version_info < (2, 7):
content += "\n"
try: try:
astnode = compile(content, "source", "exec", 1024) # 1024 for AST astnode = compile(content, "source", "exec", 1024) # 1024 for AST
except ValueError: except ValueError:

View File

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

View File

@ -34,7 +34,6 @@ else:
PYC_EXT = ".py" + (__debug__ and "c" or "o") PYC_EXT = ".py" + (__debug__ and "c" or "o")
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT 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 ASCII_IS_DEFAULT_ENCODING = sys.version_info[0] < 3
if sys.version_info >= (3, 5): if sys.version_info >= (3, 5):
@ -321,10 +320,6 @@ def _rewrite_test(config, fn):
return None, None return None, None
finally: finally:
del state._indecode 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: try:
tree = ast.parse(source) tree = ast.parse(source)
except SyntaxError: except SyntaxError:

View File

@ -19,10 +19,7 @@ from _pytest.compat import (
from _pytest.outcomes import fail, TEST_OUTCOME from _pytest.outcomes import fail, TEST_OUTCOME
from _pytest.compat import FuncargnamesCompatAttr from _pytest.compat import FuncargnamesCompatAttr
if sys.version_info[:2] == (2, 6): from collections import OrderedDict
from ordereddict import OrderedDict
else:
from collections import OrderedDict
def pytest_sessionstart(session): def pytest_sessionstart(session):

View File

@ -112,12 +112,9 @@ class LsofFdLeakChecker(object):
# XXX copied from execnet's conftest.py - needs to be merged # XXX copied from execnet's conftest.py - needs to be merged
winpymap = { winpymap = {
'python2.7': r'C:\Python27\python.exe', '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.4': r'C:\Python34\python.exe',
'python3.5': r'C:\Python35\python.exe', 'python3.5': r'C:\Python35\python.exe',
'python3.6': r'C:\Python36\python.exe',
} }
@ -143,8 +140,7 @@ def getexecutable(name, cache={}):
return executable return executable
@pytest.fixture(params=['python2.6', 'python2.7', 'python3.3', "python3.4", @pytest.fixture(params=['python2.7', 'python3.4', 'pypy', 'pypy3'])
'pypy', 'pypy3'])
def anypython(request): def anypython(request):
name = request.param name = request.param
executable = getexecutable(name) executable = getexecutable(name)

View File

@ -453,8 +453,7 @@ def raises(expected_exception, *args, **kwargs):
This helper produces a ``ExceptionInfo()`` object (see below). This helper produces a ``ExceptionInfo()`` object (see below).
If using Python 2.5 or above, you may use this function as a You may use this function as a context manager::
context manager::
>>> with raises(ZeroDivisionError): >>> with raises(ZeroDivisionError):
... 1/0 ... 1/0
@ -609,13 +608,6 @@ class RaisesContext(object):
__tracebackhide__ = True __tracebackhide__ = True
if tp[0] is None: if tp[0] is None:
fail(self.message) 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) self.excinfo.__init__(tp)
suppress_exception = issubclass(self.excinfo.type, self.expected_exception) suppress_exception = issubclass(self.excinfo.type, self.expected_exception)
if sys.version_info[0] == 2 and suppress_exception: if sys.version_info[0] == 2 and suppress_exception:

View File

@ -6,7 +6,7 @@ import py
import pytest import pytest
import _pytest._code import _pytest._code
pythonlist = ['python2.6', 'python2.7', 'python3.4', 'python3.5'] pythonlist = ['python2.7', 'python3.4', 'python3.5']
@pytest.fixture(params=pythonlist) @pytest.fixture(params=pythonlist)
def python1(request, tmpdir): def python1(request, tmpdir):
picklefile = tmpdir.join("data.pickle") picklefile = tmpdir.join("data.pickle")

View File

@ -1,7 +1,7 @@
Installation and Getting Started 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 **Platforms**: Unix/Posix and Windows
@ -9,8 +9,6 @@ Installation and Getting Started
**dependencies**: `py <http://pypi.python.org/pypi/py>`_, **dependencies**: `py <http://pypi.python.org/pypi/py>`_,
`colorama (Windows) <http://pypi.python.org/pypi/colorama>`_, `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>`_ **documentation as PDF**: `download latest <https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf>`_

View File

@ -57,7 +57,7 @@ Features
- Can run :ref:`unittest <unittest>` (including trial) and :ref:`nose <noseintegration>` test suites out of the box; - 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; - Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community;

View File

@ -64,11 +64,11 @@ during import time.
If you wish to skip something conditionally then you can use ``skipif`` instead. 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 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 import sys
@pytest.mark.skipif(sys.version_info < (3,3), @pytest.mark.skipif(sys.version_info < (3,6),
reason="requires python3.3") reason="requires python3.6")
def test_function(): def test_function():
... ...
@ -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 As with skipif_ you can also mark your expectation of a failure
on a particular platform:: on a particular platform::
@pytest.mark.xfail(sys.version_info >= (3,3), @pytest.mark.xfail(sys.version_info >= (3,6),
reason="python3.3 api changes") reason="python3.6 api changes")
def test_function(): def test_function():
... ...

View File

@ -16,7 +16,7 @@ classifiers = [
'Topic :: Utilities', 'Topic :: Utilities',
] + [ ] + [
('Programming Language :: Python :: %s' % x) ('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: with open('README.rst') as fd:

View File

@ -344,7 +344,7 @@ class TestGeneralUsage(object):
Importing a module that didn't exist, even if the ImportError was Importing a module that didn't exist, even if the ImportError was
gracefully handled, would make our test crash. 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 ImportWarning: Not importing directory '...\not_a_package': missing __init__.py
""" """
testdir.mkdir('not_a_package') testdir.mkdir('not_a_package')

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import sys
import operator import operator
import _pytest import _pytest
import py import py
@ -345,9 +344,6 @@ def test_excinfo_no_sourcecode():
except ValueError: except ValueError:
excinfo = _pytest._code.ExceptionInfo() excinfo = _pytest._code.ExceptionInfo()
s = str(excinfo.traceback[-1]) 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"
@ -1244,9 +1240,6 @@ def test_no_recursion_index_on_recursion_error():
except: except:
from _pytest._code.code import ExceptionInfo from _pytest._code.code import ExceptionInfo
exc_info = 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: else:
assert 0 assert 0

View File

@ -273,7 +273,6 @@ class TestSourceParsingAndCompiling(object):
assert getstatement(2, source).lines == source.lines[2:3] assert getstatement(2, source).lines == source.lines[2:3]
assert getstatement(3, source).lines == source.lines[3:4] 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): def test_getstatementrange_out_of_bounds_py3(self):
source = Source("if xxx:\n from .collections import something") source = Source("if xxx:\n from .collections import something")
r = source.getstatementrange(1) r = source.getstatementrange(1)
@ -283,7 +282,6 @@ class TestSourceParsingAndCompiling(object):
source = Source(":") source = Source(":")
pytest.raises(SyntaxError, lambda: source.getstatementrange(0)) pytest.raises(SyntaxError, lambda: source.getstatementrange(0))
@pytest.mark.skipif("sys.version_info < (2,6)")
def test_compile_to_ast(self): def test_compile_to_ast(self):
import ast import ast
source = Source("x = 4") source = Source("x = 4")

View File

@ -24,11 +24,8 @@ class MyDocTestRunner(doctest.DocTestRunner):
class TestApprox(object): class TestApprox(object):
def test_repr_string(self): 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'+-' plus_minus = u'\u00b1' if sys.version_info[0] > 2 else u'+-'
tol1, tol2, infr = '1.0e-06', '2.0e-06', 'inf' 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)) == '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( assert repr(approx([1.0, 2.0])) == 'approx([1.0 {pm} {tol1}, 2.0 {pm} {tol2}])'.format(
pm=plus_minus, tol1=tol1, tol2=tol2) pm=plus_minus, tol1=tol1, tol2=tol2)
@ -375,9 +372,6 @@ class TestApprox(object):
assert [3] == [pytest.approx(4)] assert [3] == [pytest.approx(4)]
""") """)
expected = '4.0e-06' 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 = testdir.runpytest()
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
'*At index 0 diff: 3 != 4 * {0}'.format(expected), '*At index 0 diff: 3 != 4 * {0}'.format(expected),

View File

@ -164,13 +164,6 @@ class TestClass(object):
assert fix == 1 assert fix == 1
""") """)
result = testdir.runpytest() result = testdir.runpytest()
if sys.version_info < (2, 7):
# in 2.6, the code to handle static methods doesn't work
result.stdout.fnmatch_lines([
"*collected 0 items*",
"*cannot collect static method*",
])
else:
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
"*collected 2 items*", "*collected 2 items*",
"*2 passed in*", "*2 passed in*",

View File

@ -640,7 +640,7 @@ def test_rewritten():
testdir.tmpdir.join("test_newlines.py").write(b, "wb") testdir.tmpdir.join("test_newlines.py").write(b, "wb")
assert testdir.runpytest().ret == 0 assert testdir.runpytest().ret == 0
@pytest.mark.skipif(sys.version_info < (3, 3), @pytest.mark.skipif(sys.version_info < (3, 4),
reason='packages without __init__.py not supported on python 2') reason='packages without __init__.py not supported on python 2')
def test_package_without__init__py(self, testdir): def test_package_without__init__py(self, testdir):
pkg = testdir.mkdir('a_package_without_init_py') pkg = testdir.mkdir('a_package_without_init_py')

View File

@ -139,7 +139,7 @@ class TestConfigAPI(object):
assert config.getoption(x) == "this" assert config.getoption(x) == "this"
pytest.raises(ValueError, "config.getoption('qweqwe')") pytest.raises(ValueError, "config.getoption('qweqwe')")
@pytest.mark.skipif('sys.version_info[:2] not in [(2, 6), (2, 7)]') @pytest.mark.skipif('sys.version_info[0] < 3')
def test_config_getoption_unicode(self, testdir): def test_config_getoption_unicode(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
from __future__ import unicode_literals from __future__ import unicode_literals

View File

@ -300,13 +300,7 @@ def test_argcomplete(testdir, monkeypatch):
elif not result.stdout.str(): elif not result.stdout.str():
pytest.skip("bash provided no output, argcomplete not available?") pytest.skip("bash provided no output, argcomplete not available?")
else: else:
if py.std.sys.version_info < (2, 7):
result.stdout.lines = result.stdout.lines[0].split('\x0b')
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"]) result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
else:
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
if py.std.sys.version_info < (2, 7):
return
os.mkdir('test_argcomplete.d') os.mkdir('test_argcomplete.d')
arg = 'test_argc' arg = 'test_argc'
monkeypatch.setenv('COMP_LINE', "pytest " + arg) monkeypatch.setenv('COMP_LINE', "pytest " + arg)

View File

@ -168,7 +168,6 @@ def test_teardown_issue1649(testdir):
assert type(obj).__name__ != 'TestCaseObjectsShouldBeCleanedUp' assert type(obj).__name__ != 'TestCaseObjectsShouldBeCleanedUp'
@pytest.mark.skipif("sys.version_info < (2,7)")
def test_unittest_skip_issue148(testdir): def test_unittest_skip_issue148(testdir):
testpath = testdir.makepyfile(""" testpath = testdir.makepyfile("""
import unittest import unittest
@ -629,7 +628,6 @@ def test_unittest_typerror_traceback(testdir):
assert result.ret == 1 assert result.ret == 1
@pytest.mark.skipif("sys.version_info < (2,7)")
@pytest.mark.parametrize('runner', ['pytest', 'unittest']) @pytest.mark.parametrize('runner', ['pytest', 'unittest'])
def test_unittest_expected_failure_for_failing_test_is_xfail(testdir, runner): def test_unittest_expected_failure_for_failing_test_is_xfail(testdir, runner):
script = testdir.makepyfile(""" script = testdir.makepyfile("""
@ -656,7 +654,6 @@ def test_unittest_expected_failure_for_failing_test_is_xfail(testdir, runner):
assert result.ret == 0 assert result.ret == 0
@pytest.mark.skipif("sys.version_info < (2,7)")
@pytest.mark.parametrize('runner', ['pytest', 'unittest']) @pytest.mark.parametrize('runner', ['pytest', 'unittest'])
def test_unittest_expected_failure_for_passing_test_is_fail(testdir, runner): def test_unittest_expected_failure_for_passing_test_is_fail(testdir, runner):
script = testdir.makepyfile(""" script = testdir.makepyfile("""
@ -787,7 +784,6 @@ def test_issue333_result_clearing(testdir):
reprec.assertoutcome(failed=1) reprec.assertoutcome(failed=1)
@pytest.mark.skipif("sys.version_info < (2,7)")
def test_unittest_raise_skip_issue748(testdir): def test_unittest_raise_skip_issue748(testdir):
testdir.makepyfile(test_foo=""" testdir.makepyfile(test_foo="""
import unittest import unittest
@ -803,7 +799,6 @@ def test_unittest_raise_skip_issue748(testdir):
""") """)
@pytest.mark.skipif("sys.version_info < (2,7)")
def test_unittest_skip_issue1169(testdir): def test_unittest_skip_issue1169(testdir):
testdir.makepyfile(test_foo=""" testdir.makepyfile(test_foo="""
import unittest import unittest