Return iterables throughout for consistency.

master
Jason R. Coombs 8 years ago
parent 1a4dc2fc62
commit e1ae854faf
  1. 4
      CHANGES.rst
  2. 1
      setup.py
  3. 5
      wolframalpha/__init__.py
  4. 3
      wolframalpha/test_client.py

@ -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.

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

@ -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)

@ -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():

Loading…
Cancel
Save