Skip to content

Commit dfc2bc4

Browse files
committed
Improved tests
1 parent 5282627 commit dfc2bc4

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

graphene/utils/lazymap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def next(self):
3131
return self.__next__()
3232

3333
def __getitem__(self, key):
34-
item = self._origin.__getitem__(key)
34+
item = self._origin[key]
3535
if isinstance(key, slice):
3636
return LazyMap(item, self._map)
3737
return self._map(item)

graphene/utils/tests/__init__.py

Whitespace-only changes.

graphene/utils/tests/test_lazymap.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from py.test import raises
2+
3+
from ..lazymap import LazyMap
4+
5+
6+
def test_lazymap():
7+
data = list(range(10))
8+
lm = LazyMap(data, lambda x: 2 * x)
9+
assert len(lm) == 10
10+
assert lm[1] == 2
11+
assert isinstance(lm[1:4], LazyMap)
12+
assert lm.append == data.append
13+
assert repr(lm) == '<LazyMap [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>'
14+
15+
16+
def test_lazymap_iter():
17+
data = list(range(2))
18+
lm = LazyMap(data, lambda x: 2 * x)
19+
iter_lm = iter(lm)
20+
assert iter_lm.next() == 0
21+
assert iter_lm.next() == 2
22+
with raises(StopIteration):
23+
iter_lm.next()

graphene/utils/tests/test_misc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import collections
22

3-
from graphene.utils.misc import enum_to_graphql_enum
43
from graphql.core.type import GraphQLEnumType
54

5+
from ..misc import enum_to_graphql_enum
6+
67
item = collections.namedtuple('type', 'name value')
78

89

graphene/utils/tests/test_proxy_snake_dict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from py.test import raises
22

3-
from graphene.utils import ProxySnakeDict
3+
from ..proxy_snake_dict import ProxySnakeDict
44

55

66
def test_proxy_snake_dict():

graphene/utils/tests/test_str_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from graphene.utils import to_camel_case, to_snake_case
1+
from ..str_converters import to_camel_case, to_snake_case
22

33

44
def test_snake_case():

0 commit comments

Comments
 (0)