fix collection imports for python2.5
This commit is contained in:
parent
72a48d69cd
commit
cbbbfcd101
|
@ -4,7 +4,11 @@ import py
|
|||
try:
|
||||
from collections.abc import Sequence
|
||||
except ImportError:
|
||||
from collections import Sequence
|
||||
try:
|
||||
from collections import Sequence
|
||||
except ImportError:
|
||||
Sequence = list
|
||||
|
||||
|
||||
BuiltinAssertionError = py.builtin.builtins.AssertionError
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ def pytest_generate_tests(metafunc):
|
|||
for val in l:
|
||||
metafunc.addcall(funcargs={name: val})
|
||||
elif 'anypython' in metafunc.fixturenames:
|
||||
for name in ('python2.4', 'python2.5', 'python2.6',
|
||||
for name in ('python2.5', 'python2.6',
|
||||
'python2.7', 'python3.2', "python3.3",
|
||||
'pypy', 'jython'):
|
||||
metafunc.addcall(id=name, param=name)
|
||||
|
|
|
@ -3,12 +3,6 @@ import sys
|
|||
import py, pytest
|
||||
import _pytest.assertion as plugin
|
||||
from _pytest.assertion import reinterpret, util
|
||||
try:
|
||||
from collections.abc import MutableSequence
|
||||
except ImportError:
|
||||
from collections import MutableSequence
|
||||
|
||||
|
||||
needsnewassert = pytest.mark.skipif("sys.version_info < (2,6)")
|
||||
|
||||
|
||||
|
@ -122,6 +116,14 @@ class TestAssert_reprcompare:
|
|||
assert len(expl) > 1
|
||||
|
||||
def test_Sequence(self):
|
||||
col = py.builtin._tryimport(
|
||||
"collections.abc",
|
||||
"collections",
|
||||
"sys")
|
||||
if not hasattr(col, "MutableSequence"):
|
||||
pytest.skip("cannot import MutableSequence")
|
||||
MutableSequence = col.MutableSequence
|
||||
|
||||
class TestSequence(MutableSequence): # works with a Sequence subclass
|
||||
def __init__(self, iterable):
|
||||
self.elements = list(iterable)
|
||||
|
|
Loading…
Reference in New Issue