Skip to content

Commit 2b9d290

Browse files
committed
Fix collections.abc DeprecationWarning
1 parent f1ccc47 commit 2b9d290

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

nested_admin/tests/utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import collections
1+
from collections import namedtuple
2+
try:
3+
from collections.abc import Sequence
4+
except ImportError:
5+
from collections import Sequence
26

37
import six
48
from nested_admin.tests.compat import python_2_unicode_compatible
@@ -18,7 +22,7 @@ def xpath_item(model_name=None):
1822

1923

2024
def is_sequence(o):
21-
return isinstance(o, collections.Sequence)
25+
return isinstance(o, Sequence)
2226

2327

2428
def is_integer(o):
@@ -29,15 +33,15 @@ def is_str(o):
2933
return isinstance(o, six.string_types)
3034

3135

32-
Position = collections.namedtuple('Position', ['x', 'y'])
36+
Position = namedtuple('Position', ['x', 'y'])
3337

3438

35-
class Size(collections.namedtuple('Size', ['width', 'height'])):
39+
class Size(namedtuple('Size', ['width', 'height'])):
3640
w = property(lambda self: self.width)
3741
h = property(lambda self: self.height)
3842

3943

40-
class Rect(collections.namedtuple('Rect', [
44+
class Rect(namedtuple('Rect', [
4145
'left', 'top', 'right', 'bottom', 'width', 'height', 'visible'])):
4246
x = property(lambda self: self.left)
4347
y = property(lambda self: self.top)

0 commit comments

Comments
 (0)