mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-16 19:40:39 +03:00
Improved tests
This commit is contained in:
parent
5282627537
commit
dfc2bc4ac3
|
@ -31,7 +31,7 @@ class LazyMap(object):
|
|||
return self.__next__()
|
||||
|
||||
def __getitem__(self, key):
|
||||
item = self._origin.__getitem__(key)
|
||||
item = self._origin[key]
|
||||
if isinstance(key, slice):
|
||||
return LazyMap(item, self._map)
|
||||
return self._map(item)
|
||||
|
|
0
graphene/utils/tests/__init__.py
Normal file
0
graphene/utils/tests/__init__.py
Normal file
23
graphene/utils/tests/test_lazymap.py
Normal file
23
graphene/utils/tests/test_lazymap.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from py.test import raises
|
||||
|
||||
from ..lazymap import LazyMap
|
||||
|
||||
|
||||
def test_lazymap():
|
||||
data = list(range(10))
|
||||
lm = LazyMap(data, lambda x: 2 * x)
|
||||
assert len(lm) == 10
|
||||
assert lm[1] == 2
|
||||
assert isinstance(lm[1:4], LazyMap)
|
||||
assert lm.append == data.append
|
||||
assert repr(lm) == '<LazyMap [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>'
|
||||
|
||||
|
||||
def test_lazymap_iter():
|
||||
data = list(range(2))
|
||||
lm = LazyMap(data, lambda x: 2 * x)
|
||||
iter_lm = iter(lm)
|
||||
assert iter_lm.next() == 0
|
||||
assert iter_lm.next() == 2
|
||||
with raises(StopIteration):
|
||||
iter_lm.next()
|
|
@ -1,8 +1,9 @@
|
|||
import collections
|
||||
|
||||
from graphene.utils.misc import enum_to_graphql_enum
|
||||
from graphql.core.type import GraphQLEnumType
|
||||
|
||||
from ..misc import enum_to_graphql_enum
|
||||
|
||||
item = collections.namedtuple('type', 'name value')
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from py.test import raises
|
||||
|
||||
from graphene.utils import ProxySnakeDict
|
||||
from ..proxy_snake_dict import ProxySnakeDict
|
||||
|
||||
|
||||
def test_proxy_snake_dict():
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from graphene.utils import to_camel_case, to_snake_case
|
||||
from ..str_converters import to_camel_case, to_snake_case
|
||||
|
||||
|
||||
def test_snake_case():
|
||||
|
|
Loading…
Reference in New Issue
Block a user