Return iterables throughout for consistency.

This commit is contained in:
Jason R. Coombs 2016-09-03 14:59:58 -04:00
parent 1a4dc2fc62
commit e1ae854faf
4 changed files with 6 additions and 7 deletions

View File

@ -7,8 +7,8 @@
* ``Client.query`` now accepts keyword arguments
and parameters passed directly to Wolfram|Alpha
as URL parameters.
* ``Result.pods`` now returns an iterator and not
a list.
* ``Result.pods`` and ``Pod.subpods`` now returns
an iterator and not a list.
* ``Pod`` objects are no longer iterable. To access
the subpods of a pod, simply use the ``Pod.subpod``
property.

View File

@ -34,7 +34,6 @@ setup_params = dict(
install_requires=[
'six',
'xmltodict',
'jaraco.functools',
],
extras_require={
},

View File

@ -3,7 +3,6 @@ import itertools
from six.moves import urllib, map
import xmltodict
from jaraco.functools import compose
from . import compat
@ -122,7 +121,7 @@ class Subpod(Document):
Holds a specific answer or additional information relevant to said answer.
"""
_attr_types = dict(
img=compose(list, Image.from_doc),
img=Image.from_doc,
)
@ -141,7 +140,7 @@ class Pod(ErrorHandler, Document):
_attr_types = dict(
position=float,
numsubpods=int,
subpod=compose(list, Subpod.from_doc),
subpod=Subpod.from_doc,
)
def __init__(self, *args, **kwargs):
super(Pod, self).__init__(*args, **kwargs)

View File

@ -71,7 +71,8 @@ def test_pod_attributes(temp_result):
pod = next(temp_result.pods)
assert isinstance(pod.position, float)
assert isinstance(pod.id, six.text_type)
assert isinstance(pod.subpod[0].img[0].height, int)
img = next(next(pod.subpod).img)
assert isinstance(img.height, int)
def test_invalid_app_id():