Remove code for unsupported Python versions

This commit is contained in:
hugovk
2017-10-10 08:54:56 +03:00
parent dd45f8ba6c
commit ef732fc51d
23 changed files with 44 additions and 107 deletions

View File

@@ -344,7 +344,7 @@ class TestGeneralUsage(object):
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')

View File

@@ -345,10 +345,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):
@@ -1244,9 +1241,6 @@ def test_no_recursion_index_on_recursion_error():
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

View File

@@ -273,7 +273,6 @@ class TestSourceParsingAndCompiling(object):
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)
@@ -283,7 +282,6 @@ class TestSourceParsingAndCompiling(object):
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")

View File

@@ -24,11 +24,8 @@ class MyDocTestRunner(doctest.DocTestRunner):
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)
@@ -375,9 +372,6 @@ class TestApprox(object):
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),

View File

@@ -164,17 +164,10 @@ class TestClass(object):
assert fix == 1
""")
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([
"*collected 2 items*",
"*2 passed in*",
])
result.stdout.fnmatch_lines([
"*collected 2 items*",
"*2 passed in*",
])
def test_setup_teardown_class_as_classmethod(self, testdir):
testdir.makepyfile(test_mod1="""

View File

@@ -640,7 +640,7 @@ def test_rewritten():
testdir.tmpdir.join("test_newlines.py").write(b, "wb")
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')
def test_package_without__init__py(self, testdir):
pkg = testdir.mkdir('a_package_without_init_py')

View File

@@ -139,7 +139,7 @@ class TestConfigAPI(object):
assert config.getoption(x) == "this"
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):
testdir.makeconftest("""
from __future__ import unicode_literals

View File

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

View File

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